mirror of https://github.com/zulip/zulip.git
hello: Write better variable names.
This commit is contained in:
parent
cbb09f4ee6
commit
b9dd4a14c9
|
@ -1,16 +1,16 @@
|
|||
// Mark this as a module for ESLint and Webpack.
|
||||
export {};
|
||||
|
||||
function get_new_rand(oldRand, max) {
|
||||
const newRand = Math.floor(Math.random() * max);
|
||||
return newRand === oldRand ? get_new_rand(newRand, max) : newRand;
|
||||
function get_new_rand(old_random_int, max) {
|
||||
const random_int = Math.floor(Math.random() * max);
|
||||
return random_int === old_random_int ? get_new_rand(random_int, max) : random_int;
|
||||
}
|
||||
|
||||
function get_random_item_from_array(array) {
|
||||
return array[Math.floor(Math.random() * array.length)];
|
||||
}
|
||||
|
||||
const current_clint_logo_class_names = new Set([
|
||||
const current_client_logo_class_names = new Set([
|
||||
"client-logos__logo_akamai",
|
||||
"client-logos__logo_tum",
|
||||
"client-logos__logo_wikimedia",
|
||||
|
@ -18,7 +18,7 @@ const current_clint_logo_class_names = new Set([
|
|||
"client-logos__logo_dr_on_demand",
|
||||
"client-logos__logo_maria",
|
||||
]);
|
||||
const future_logo_class_names = new Set([
|
||||
const future_client_logo_class_names = new Set([
|
||||
"client-logos__logo_pilot",
|
||||
"client-logos__logo_recurse",
|
||||
"client-logos__logo_level_up",
|
||||
|
@ -29,26 +29,28 @@ const future_logo_class_names = new Set([
|
|||
"client-logos__logo_lean",
|
||||
"client-logos__logo_asciidoc",
|
||||
]);
|
||||
let current_clint_logo_class_namesIndex = 0;
|
||||
let current_client_logo_class_names_index = 0;
|
||||
function update_client_logo() {
|
||||
if (document.hidden) {
|
||||
return;
|
||||
}
|
||||
const logos = [...document.querySelectorAll("[class^='client-logos__']")];
|
||||
current_clint_logo_class_namesIndex = get_new_rand(
|
||||
current_clint_logo_class_namesIndex,
|
||||
logos.length,
|
||||
const client_logos = [...document.querySelectorAll("[class^='client-logos__']")];
|
||||
current_client_logo_class_names_index = get_new_rand(
|
||||
current_client_logo_class_names_index,
|
||||
client_logos.length,
|
||||
);
|
||||
const el = logos[current_clint_logo_class_namesIndex];
|
||||
const client_logo_elt = client_logos[current_client_logo_class_names_index];
|
||||
|
||||
const oldClass = el.className;
|
||||
el.className = "";
|
||||
current_clint_logo_class_names.delete(oldClass);
|
||||
const newClass = get_random_item_from_array([...future_logo_class_names.values()]);
|
||||
future_logo_class_names.delete(newClass);
|
||||
el.className = newClass;
|
||||
current_clint_logo_class_names.add(newClass);
|
||||
future_logo_class_names.add(oldClass);
|
||||
const current_logo_class = client_logo_elt.className;
|
||||
current_client_logo_class_names.delete(current_logo_class);
|
||||
|
||||
const next_logo_class = get_random_item_from_array([
|
||||
...future_client_logo_class_names.values(),
|
||||
]);
|
||||
future_client_logo_class_names.delete(next_logo_class);
|
||||
client_logo_elt.className = next_logo_class;
|
||||
current_client_logo_class_names.add(next_logo_class);
|
||||
future_client_logo_class_names.add(current_logo_class);
|
||||
}
|
||||
|
||||
setInterval(update_client_logo, 2500);
|
||||
|
|
Loading…
Reference in New Issue