Bmansurov has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/327122 )

Change subject: WIP: Add reading depth
......................................................................

WIP: Add reading depth

Bug: T147314
Change-Id: Ib9ec7bd0e60aa34a04e32222b025347f6ee31794
---
M resources/ext.popups/actions.js
M resources/ext.popups/boot.js
2 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/22/327122/1

diff --git a/resources/ext.popups/actions.js b/resources/ext.popups/actions.js
index aa71472..0805ae0 100644
--- a/resources/ext.popups/actions.js
+++ b/resources/ext.popups/actions.js
@@ -3,6 +3,7 @@
        var actions = {},
                types = {
                        BOOT: 'BOOT',
+                       CHECKIN: 'CHECKIN',
                        LINK_DWELL: 'LINK_DWELL',
                        LINK_ABANDON_START: 'LINK_ABANDON_START',
                        LINK_ABANDON_END: 'LINK_ABANDON_END',
@@ -87,6 +88,14 @@
                };
        };
 
+       actions.checkin = function ( checkinTime, pageVisibility ) {
+               return {
+                       type: types.CHECKIN,
+                       checkin: checkinTime,
+                       pageVisibility: pageVisibility
+               };
+       };
+
        /**
         * Represents Page Previews fetching data via the 
[gateway](./gateway.js).
         *
diff --git a/resources/ext.popups/boot.js b/resources/ext.popups/boot.js
index 5c8ae30..513242b 100644
--- a/resources/ext.popups/boot.js
+++ b/resources/ext.popups/boot.js
@@ -9,6 +9,28 @@
                '.cancelLink a'
        ];
 
+       function getPageVisibilityState() {
+               switch ( document.visibilityState ) {
+                       case "visible":
+                       case "hidden":
+                               return document.visibilityState;
+                       default:
+                               return 'unknown';
+               }
+       }
+
+       function setupCheckinActions( checkinAction ) {
+               var CHECKIN_TIMES = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 
233,
+                       377, 610, 987, 1597, 2584, 4181, 6765];
+
+               $.each( CHECKIN_TIMES, function( checkinTime ) {
+                       setTimeout( checkinAction, checkinTime, {
+                               checkinTime: checkinTime,
+                               pageVisibility: getPageVisibilityState()
+                       } );
+               } );
+       }
+
        /**
         * Creates a gateway with sensible values for the dependencies.
         *
@@ -74,6 +96,7 @@
         * 2. Binding the actions to such store
         * 3. Trigger the boot action to bootstrap the system
         * 4. When the page content is ready:
+        *   - Setup `checkin` actions
         *   - Process the eligible links for page previews
         *   - Initialize the renderer
         *   - Bind hover and click events to the eligible links to trigger 
actions
@@ -126,6 +149,8 @@
                                        mw.config
                                );
 
+                       setupCheckinActions( actions.checkin );
+
                        mw.popups.renderer.init();
 
                        previewLinks

-- 
To view, visit https://gerrit.wikimedia.org/r/327122
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9ec7bd0e60aa34a04e32222b025347f6ee31794
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to