mirror of https://github.com/zulip/zulip.git
hello: Fix client logos not changing on hello page.
Since `zulip.com` doesn't has `/hello` in URL, the JS code for hello page events was not running. We extract it to a new file and just always run it.
This commit is contained in:
parent
02f3f73b0c
commit
cbb09f4ee6
|
@ -0,0 +1,54 @@
|
||||||
|
// 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_random_item_from_array(array) {
|
||||||
|
return array[Math.floor(Math.random() * array.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
const current_clint_logo_class_names = new Set([
|
||||||
|
"client-logos__logo_akamai",
|
||||||
|
"client-logos__logo_tum",
|
||||||
|
"client-logos__logo_wikimedia",
|
||||||
|
"client-logos__logo_rust",
|
||||||
|
"client-logos__logo_dr_on_demand",
|
||||||
|
"client-logos__logo_maria",
|
||||||
|
]);
|
||||||
|
const future_logo_class_names = new Set([
|
||||||
|
"client-logos__logo_pilot",
|
||||||
|
"client-logos__logo_recurse",
|
||||||
|
"client-logos__logo_level_up",
|
||||||
|
|
||||||
|
"client-logos__logo_layershift",
|
||||||
|
"client-logos__logo_julia",
|
||||||
|
"client-logos__logo_ucsd",
|
||||||
|
"client-logos__logo_lean",
|
||||||
|
"client-logos__logo_asciidoc",
|
||||||
|
]);
|
||||||
|
let current_clint_logo_class_namesIndex = 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 el = logos[current_clint_logo_class_namesIndex];
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(update_client_logo, 2500);
|
|
@ -14,59 +14,6 @@ export function path_parts() {
|
||||||
return window.location.pathname.split("/").filter((chunk) => chunk !== "");
|
return window.location.pathname.split("/").filter((chunk) => chunk !== "");
|
||||||
}
|
}
|
||||||
|
|
||||||
const hello_events = function () {
|
|
||||||
function get_new_rand(oldRand, max) {
|
|
||||||
const newRand = Math.floor(Math.random() * max);
|
|
||||||
return newRand === oldRand ? get_new_rand(newRand, max) : newRand;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_random_item_from_array(array) {
|
|
||||||
return array[Math.floor(Math.random() * array.length)];
|
|
||||||
}
|
|
||||||
|
|
||||||
const current_clint_logo_class_names = new Set([
|
|
||||||
"client-logos__logo_akamai",
|
|
||||||
"client-logos__logo_tum",
|
|
||||||
"client-logos__logo_wikimedia",
|
|
||||||
"client-logos__logo_rust",
|
|
||||||
"client-logos__logo_dr_on_demand",
|
|
||||||
"client-logos__logo_maria",
|
|
||||||
]);
|
|
||||||
const future_logo_class_names = new Set([
|
|
||||||
"client-logos__logo_pilot",
|
|
||||||
"client-logos__logo_recurse",
|
|
||||||
"client-logos__logo_level_up",
|
|
||||||
|
|
||||||
"client-logos__logo_layershift",
|
|
||||||
"client-logos__logo_julia",
|
|
||||||
"client-logos__logo_ucsd",
|
|
||||||
"client-logos__logo_lean",
|
|
||||||
"client-logos__logo_asciidoc",
|
|
||||||
]);
|
|
||||||
let current_clint_logo_class_namesIndex = 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 el = logos[current_clint_logo_class_namesIndex];
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
setInterval(update_client_logo, 2500);
|
|
||||||
};
|
|
||||||
|
|
||||||
const apps_events = function () {
|
const apps_events = function () {
|
||||||
const info = {
|
const info = {
|
||||||
windows: {
|
windows: {
|
||||||
|
@ -177,10 +124,6 @@ const events = function () {
|
||||||
if (path_parts().includes("apps")) {
|
if (path_parts().includes("apps")) {
|
||||||
apps_events();
|
apps_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_parts().includes("hello")) {
|
|
||||||
hello_events();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
],
|
],
|
||||||
"landing-page-hello": [
|
"landing-page-hello": [
|
||||||
"./src/bundles/hello",
|
"./src/bundles/hello",
|
||||||
|
"./src/portico/hello",
|
||||||
"./src/portico/landing-page",
|
"./src/portico/landing-page",
|
||||||
"./src/portico/header",
|
"./src/portico/header",
|
||||||
"./styles/portico/svg_icons.css",
|
"./styles/portico/svg_icons.css",
|
||||||
|
|
Loading…
Reference in New Issue