mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Loading messages won't repeat as often and cycle more slowly
This commit is contained in:
parent
3affce8f98
commit
fef446687a
1 changed files with 17 additions and 4 deletions
|
@ -35,7 +35,7 @@
|
||||||
// Load theme before the preloader is shown
|
// Load theme before the preloader is shown
|
||||||
document.querySelector(":root").className = JSON.parse(localStorage.getItem("options")).theme;
|
document.querySelector(":root").className = JSON.parse(localStorage.getItem("options")).theme;
|
||||||
|
|
||||||
// Cycle loading messages
|
// Define loading messages
|
||||||
const loadingMsgs = [
|
const loadingMsgs = [
|
||||||
"Proving P = NP...",
|
"Proving P = NP...",
|
||||||
"Computing 6 x 9...",
|
"Computing 6 x 9...",
|
||||||
|
@ -49,15 +49,28 @@
|
||||||
"Navigating neural network...",
|
"Navigating neural network...",
|
||||||
"Importing machine learning..."
|
"Importing machine learning..."
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Shuffle array using Durstenfeld algorithm
|
||||||
|
for (let i = loadingMsgs.length - 1; i > 0; --i) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
const temp = loadingMsgs[i];
|
||||||
|
loadingMsgs[i] = loadingMsgs[j];
|
||||||
|
loadingMsgs[j] = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show next loading message then move it to the end of the array
|
||||||
function changeLoadingMsg() {
|
function changeLoadingMsg() {
|
||||||
|
const msg = loadingMsgs.shift();
|
||||||
try {
|
try {
|
||||||
const el = document.getElementById("preloader-msg");
|
const el = document.getElementById("preloader-msg");
|
||||||
el.className = "loading"; // Causes CSS transition on first message
|
el.className = "loading"; // Causes CSS transition on first message
|
||||||
el.innerHTML = loadingMsgs[Math.floor(Math.random()*loadingMsgs.length)];
|
el.innerHTML = msg;
|
||||||
} catch (err) {}
|
} catch (err) {} // Ignore errors if DOM not yet ready
|
||||||
|
loadingMsgs.push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeLoadingMsg();
|
changeLoadingMsg();
|
||||||
window.loadingMsgsInt = setInterval(changeLoadingMsg, (Math.random()*500) + 500);
|
window.loadingMsgsInt = setInterval(changeLoadingMsg, (Math.random() * 1000) + 1000);
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue