]> _ Git - fluidbook-html5.git/commitdiff
wip #6316 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Nov 2023 08:16:22 +0000 (09:16 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Nov 2023 08:16:22 +0000 (09:16 +0100)
js/libs/fluidbook/stats/fluidbook.stats.esm.js

index fc8301ab97d8f52eefb86ef368f34a6760e66d97..ded04f9d19bd4d5dc52f70879fe0b0cafc7c660e 100644 (file)
@@ -1,5 +1,6 @@
 function FluidbookStatsEsm(fluidbook) {
     this.fluidbook = fluidbook;
+    this.lastSentPage = null;
     this.init();
 }
 
@@ -9,7 +10,10 @@ FluidbookStatsEsm.prototype = {
 
         // Page change
         $(this.fluidbook).on('fluidbook.page.change.end', function (e, page) {
-            $this.changePage(page);
+            if (page !== $this.lastSentPage) {
+                $this.lastSentPage = page;
+                $this.changePage();
+            }
             return true;
         });
 
@@ -91,10 +95,17 @@ FluidbookStatsEsm.prototype = {
 
     },
 
-    changePage: function (page) {
-        window.tc_vars.magazine_page = page;
-        window.tc_vars.env_url = window.tc_vars.magazine_name + '/' + window.tc_vars.magazine_region + '/' + window.tc_vars.magazine_page;
-        tC.container.reload({events: {page: [{}, {}]}});
+    changePage: function () {
+        let pages = this.fluidbook.getDisplayedPages();
+
+        console.log('esm pages', pages);
+
+        for (let i in pages) {
+            let page = pages[i];
+            window.tc_vars.magazine_page = page;
+            window.tc_vars.env_url = window.tc_vars.magazine_name + '/' + window.tc_vars.magazine_region + '/' + window.tc_vars.magazine_page;
+            tC.container.reload({events: {page: [{}, {}]}});
+        }
     },
 
     clickNav: function (id) {