u.twoha.cc/static/util.js

22 lines
521 B
JavaScript
Raw Normal View History

2024-09-13 03:24:53 -04:00
export function span(text) {
const s = document.createElement('span');
s.textContent = text;
return s;
}
export function popup(text) {
const d = document.createElement('div');
d.className = 'popup';
const s = span(text);
d.appendChild(s);
d.onanimationend = () => {
d.remove();
};
document.body.appendChild(d);
}
export function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}