]> _ Git - fluidbook-html5.git/commitdiff
wait #4160 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Dec 2020 08:24:47 +0000 (09:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 31 Dec 2020 08:24:47 +0000 (09:24 +0100)
js/libs/fluidbook/fluidbook.links.js

index 377af80ca0720b8046d264e690279db116056ab1..ed8a7825a7e498c18d2ea27f6e1094e516f0d6c9 100644 (file)
@@ -148,11 +148,18 @@ FluidbookLinks.prototype = {
             }
 
             var showid;
-            if (mode === 'shownext' || mode === 'shownextcycle') {
+            if (mode === 'pickrandom') {
+                while (true) {
+                    var ids = $(this).data('showid').split(',');
+                    var idx = Math.floor(Math.random() * ids.length);
+                    showid = ids[idx];
+                    if ($('div.link[data-hidden="1"][data-id$="' + showid + '"].show').length === 0 || ids.length === 0) {
+                        break;
+                    }
+                }
+            } else if (mode === 'shownext' || mode === 'shownextcycle') {
                 var ids = $(this).data('showid').split(',');
-                console.log(ids);
                 var current = $(this).data('current-showid');
-                console.log(current);
                 if (current === undefined) {
                     showid = ids[0];
                 } else {
@@ -166,14 +173,13 @@ FluidbookLinks.prototype = {
                     }
                     showid = ids[idx];
                 }
-                console.log(showid);
                 $(this).data('current-showid', showid);
             } else {
                 showid = $(this).data('showid');
             }
 
-            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle') {
-                $('div.link[data-hidden="1"].show').each(function () {
+            if (mode === 'exclusiveshow' || mode === 'shownext' || mode === 'shownextcycle' || mode === 'pickrandom') {
+                $('div.link[data-hidden="1"].show:not([data-id$="' + showid + '"])').each(function () {
                     $this.hidePlacedLink(this, (mode === 'shownext' || mode === 'shownextcycle') ? 500 : 0);
                 });
             }