From 0a18ee1c89962cfee6b81b018d9bb7d007d486f7 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 10 Jan 2024 11:34:30 +0800 Subject: globaled mainInterval --- public/js/randomblob.js | 4 +++- src/js/randomblob.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/js/randomblob.js b/public/js/randomblob.js index 5ea80ed1..a32045f2 100644 --- a/public/js/randomblob.js +++ b/public/js/randomblob.js @@ -1,6 +1,7 @@ "use strict"; var isFirstTime = true; +var mainInterval; function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); @@ -50,9 +51,10 @@ function main() { resetBlob(); isFirstTime = false; } - setTimeout(main, getRandomInt(7500, 30000)); + mainInterval = setTimeout(main, getRandomInt(7500, 30000)); } blob.addEventListener('click', function () { + clearTimeout(mainInterval); main(getRandomInt(7500, 30000)); }); main(); \ No newline at end of file diff --git a/src/js/randomblob.js b/src/js/randomblob.js index 3e068255..4c9dbc07 100644 --- a/src/js/randomblob.js +++ b/src/js/randomblob.js @@ -1,4 +1,5 @@ let isFirstTime = true; +var mainInterval; function getRandomInt(min, max) { min = Math.ceil(min); @@ -59,7 +60,7 @@ function main() { resetBlob() isFirstTime = false; } - let mainInterval = setTimeout(main, getRandomInt(7500, 30000)); + mainInterval = setTimeout(main, getRandomInt(7500, 30000)); } blob.addEventListener('click', function() { -- cgit v1.2.3