}
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 {
}
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);
});
}