[22] remove discord widget and add version checking (#2141)

pull/2142/head^2
YozoraXCII 5 months ago committed by GitHub Action
parent 2a82bfcfcc
commit c43d7830e8

@ -1 +1 @@
2.0.2-build21 2.0.2-build22

@ -1,15 +1,25 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block extrahead %} {% block announce %}
<script src='https://cdn.jsdelivr.net/npm/@widgetbot/crate@3' async defer> <script>
const button = new Crate({ const currentURL = window.location.href;
server: '822460010649878528', // Funky Penguin
channel: '822460010649878531', // #elf-friends channel // Base announcement for Discord support
username: 'Kometa Website Visitor', let announceText = 'For any questions and support, please reach out to us on <a href="https://kometa.wiki/en/latest/discord/">Discord</a>';
indicator: true,
color: '#00bc8c', // Check if URL includes nightly or develop
location: ['bottom', 'left'] if (currentURL.includes("en/nightly") || currentURL.includes("en/develop")) {
})
</script> // Find the branch name ("nightly" or "develop")
let branchName = currentURL.includes("en/nightly") ? "NIGHTLY" : "DEVELOP";
// Create a new URL pointing to the "latest" version of the current page
let latestURL = currentURL.replace(/en\/(nightly|develop)\//, 'en/latest/');
// Update the announceText to include the custom link and branch name
announceText = `️⚠️ You are viewing the ${branchName} branch's wiki. <bold><a href="${latestURL}">Click here to go to the main wiki.</a></b> ⚠️️`;
}
document.write(announceText);
</script>
{% endblock %} {% endblock %}

@ -1,30 +1,29 @@
function checkURLForBranch() { function checkURLForBranch() {
const currentURL = window.location.href; const currentURL = window.location.href;
const ellipsisSpan = document.querySelector(".md-ellipsis");
const mdBanner = document.querySelector(".md-banner"); // Select the banner element
// Select elements for background and text changes // Default text
const headerAndTabs = document.querySelectorAll(".md-header, .md-tabs"); let ellipsisText = "Kometa Wiki";
const ellipsisSpan = document.querySelector(".md-ellipsis"); // Select ellipsisSpan let bannerColor = "#252525"; // Default banner color
if (headerAndTabs.length > 0) { if (currentURL.includes("en/nightly") || currentURL.includes("en/develop") {
let backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/background.jpg"; ellipsisText = currentURL.includes("en/nightly") ? "Kometa Nightly Wiki" : "Kometa Develop Wiki";
let ellipsisText = ""; // Initialize ellipsisText bannerColor = "#611423"; // Updated banner color
if (currentURL.includes("en/nightly")) {
backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/backgroundnightly.jpg";
ellipsisText = "Kometa Nightly Wiki"; // Set text for Nightly
} else if (currentURL.includes("en/develop")) {
backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/backgrounddevelop.jpg";
ellipsisText = "Kometa Develop Wiki"; // Set text for Develop
} }
headerAndTabs.forEach(element => { // Create ellipsisSpan if it doesn't exist
element.style.backgroundImage = `url(${backgroundImage})`; if (!ellipsisSpan) {
}); ellipsisSpan = document.createElement("span");
ellipsisSpan.classList.add("md-ellipsis");
document.body.appendChild(ellipsisSpan);
}
// Update ellipsisSpan text only if it exists
if (ellipsisSpan) {
ellipsisSpan.textContent = ellipsisText; ellipsisSpan.textContent = ellipsisText;
}
// Update banner color
if (mdBanner) {
mdBanner.style.backgroundColor = bannerColor;
} }
} }

Loading…
Cancel
Save