Commit b53dc87a authored by Alexander Nitsche's avatar Alexander Nitsche
Browse files

[BUGFIX] Fix JS error if no banners available

parent 0fd9ec62
Pipeline #22808 failed with stages
in 1 minute and 55 seconds
......@@ -6,12 +6,11 @@ let randombanners = {} || window.randombanners;
* @param {string} element
*/
randombanners.shuffle = function (element) {
$element = document.querySelector(element);
let $element = document.querySelector(element);
if ($(element).children.length > 1) {
$element = document.querySelector(element);
for (let i = $(element).children.length; i >= 0; i--) {
$element.appendChild($element.children[Math.random() * i | 0]);
if ($element !== null && $element.children.length > 0) {
for (let i = $element.children.length; i > 0; i--) {
$element.appendChild($element.children[Math.floor(Math.random() * i)]);
}
}
};
......@@ -19,9 +18,8 @@ randombanners.shuffle = function (element) {
(function () {
randombanners.shuffle('.t3js-banners');
// alert every 2 seconds
// shuffle every 8 seconds
setInterval(function () {
randombanners.shuffle('.t3js-banners')
}, 8000);
})();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment