From 03d349f7a8c5c1a57eb3a75fcf1ae9d284ed2c77 Mon Sep 17 00:00:00 2001 From: YozoraXCII <96386153+YozoraXCII@users.noreply.github.com> Date: Sun, 31 Dec 2023 17:36:10 +0000 Subject: [PATCH 1/2] [65] refactor branch detection --- VERSION | 2 +- docs/stylesheets/branch.js | 38 ++++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/VERSION b/VERSION index 6aea03b7..c1cd2503 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.19.1-develop64 +1.19.1-develop65 diff --git a/docs/stylesheets/branch.js b/docs/stylesheets/branch.js index 6343a05b..05c14e26 100644 --- a/docs/stylesheets/branch.js +++ b/docs/stylesheets/branch.js @@ -1,30 +1,32 @@ // custom.js -// Function to check if the current URL contains "config" or "metadata" +// Function to check if the current URL contains "nightly" or "develop" and adjust styles accordingly function checkURLForBranch() { const currentURL = window.location.href; - if (currentURL.indexOf("nightly") !== -1) { - // If "config" is found in the URL, change the CSS of .md-header to red - document.querySelector(".md-header").style.backgroundColor = "#262dbd"; - document.querySelector(".md-tabs").style.backgroundColor = "#262dbd"; - - // Change the text of + // Helper function to update style and text + function updateTheme(headerColor, tabsColor, textContent) { + const header = document.querySelector(".md-header"); + const tabs = document.querySelector(".md-tabs"); const ellipsisSpan = document.querySelector(".md-ellipsis"); - if (ellipsisSpan) { - ellipsisSpan.textContent = "PMM Nightly Wiki"; + + if (header && tabs) { // Check if elements exist + header.style.backgroundColor = headerColor; + tabs.style.backgroundColor = tabsColor; } - } else if (currentURL.indexOf("develop") !== -1) { - // If "metadata" is found in the URL, change the CSS of .md-header to yellow - document.querySelector(".md-header").style.backgroundColor = "#ffa724"; - document.querySelector(".md-tabs").style.backgroundColor = "#ffa724"; - // Change the text of - const ellipsisSpan = document.querySelector(".md-ellipsis"); - if (ellipsisSpan) { - ellipsisSpan.textContent = "PMM Develop Wiki"; + if (ellipsisSpan) { // Check if element exists + ellipsisSpan.textContent = textContent; } } + // Change theme based on URL segment + if (currentURL.includes("nightly")) { + updateTheme("#262dbd", "#262dbd", "PMM Nightly Wiki"); + } else if (currentURL.includes("develop")) { + updateTheme("#ffa724", "#ffa724", "PMM Develop Wiki"); + } +} + // Call the function on page load -window.addEventListener("load", checkURLForBranch); +window.addEventListener("load", checkURLForBranch); \ No newline at end of file From 653028d8deb32ff144327bfea9eb88dd29a4c7ea Mon Sep 17 00:00:00 2001 From: YozoraXCII <96386153+YozoraXCII@users.noreply.github.com> Date: Sun, 31 Dec 2023 17:38:17 +0000 Subject: [PATCH 2/2] [66] update --- VERSION | 2 +- docs/stylesheets/branch.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index c1cd2503..2688c141 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.19.1-develop65 +1.19.1-develop66 diff --git a/docs/stylesheets/branch.js b/docs/stylesheets/branch.js index 05c14e26..e0458f7f 100644 --- a/docs/stylesheets/branch.js +++ b/docs/stylesheets/branch.js @@ -21,9 +21,9 @@ function checkURLForBranch() { } // Change theme based on URL segment - if (currentURL.includes("nightly")) { + if (currentURL.includes("en/nightly")) { updateTheme("#262dbd", "#262dbd", "PMM Nightly Wiki"); - } else if (currentURL.includes("develop")) { + } else if (currentURL.includes("en/develop")) { updateTheme("#ffa724", "#ffa724", "PMM Develop Wiki"); } }