From d6fee895525d1498f91b17e3f2d5e24a632ce3c0 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 31 Dec 2020 09:24:47 +0100 Subject: [PATCH] wait #4160 @0.25 --- js/libs/fluidbook/fluidbook.links.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.links.js b/js/libs/fluidbook/fluidbook.links.js index 377af80c..ed8a7825 100644 --- a/js/libs/fluidbook/fluidbook.links.js +++ b/js/libs/fluidbook/fluidbook.links.js @@ -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); }); } -- 2.39.5