No edit summary |
No edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 35: | Line 35: | ||
// Randomly select background from array (light only, no path, no extension) | // Randomly select background from array (light only, no path, no extension) | ||
var bgArray = [ | var bgArray = [ | ||
' | '/images/f/f1/Background2' | ||
]; | ]; | ||
var bg = bgArray[Math.floor(Math.random() * bgArray.length)]; | var bg = bgArray[Math.floor(Math.random() * bgArray.length)]; | ||
// Randomly select background from array (dark only, no path, no extension) | |||
var bgArray_dark = [ | |||
'/images/7/7f/Background2_dark' | |||
]; | |||
var bg_dark = bgArray_dark[Math.floor(Math.random() * bgArray_dark.length)]; | |||
// Page Header IMG | // Page Header IMG | ||
Line 52: | Line 58: | ||
var html = document.querySelector("html"); | var html = document.querySelector("html"); | ||
if (html.classList.contains("skin-citizen-dark")) { | if (html.classList.contains("skin-citizen-dark")) { | ||
document.documentElement.style.setProperty("--hero-image", "url( | document.documentElement.style.setProperty("--hero-image", "url(" + bg_dark + ".webp"); | ||
} else { | } else { | ||
document.documentElement.style.setProperty("--hero-image", "url( | document.documentElement.style.setProperty("--hero-image", "url(" + bg + ".webp"); | ||
} | } | ||
Line 61: | Line 67: | ||
var html = document.querySelector("html"); | var html = document.querySelector("html"); | ||
if (html.classList.contains("skin-citizen-dark")) { | if (html.classList.contains("skin-citizen-dark")) { | ||
document.documentElement.style.setProperty("--hero-image", "url(" + bg_dark + ".webp"); | |||
} else | } else { | ||
document.documentElement.style.setProperty("--hero-image", "url(" + bg + ".webp"); | |||
} | } | ||
}, 100); | }, 100); | ||
}, true); | }, true); | ||
}); | }); |
Latest revision as of 18:00, 24 May 2024
/* All JavaScript here will be loaded for users of the Citizen skin */
// Discord Button
$(document).ready( function () {
$('.citizen-drawer').after($('<div class="citizen-discord citizen-header__item mw-checkbox-hack-container"><a href="https://discord.gg/QYDSunbGNP"><div class="citizen-discord__button citizen-header__button"><label id="citizen-discord__buttonCheckbox" class="mw-checkbox-hack-button citizen-header__buttonCheckbox" for="citizen-discord__checkbox" title="Join us on Discord!" aria-hidden="true"><span>Join us on Discord!</span></label><span class="citizen-ui-icon mw-ui-icon-discord"></div></a></div>'));
});
// Sidebar Icons
//Search
$(document).ready( function () {
$('#n-Posts > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-news"></span>'));
$('#n-Search > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-search"></span>'));
//possibly excessive
$('#n-About > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-about"></span>'));
$('#n-Shop > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-shop"></span>'));
$('#n-Map > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-map"></span>'));
$('#n-Vote > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-vote"></span>'));
$('#n-Commands > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-commands"></span>'));
$('#n-Plugins > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-plugins"></span>'));
//
$('#n-Rules > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-rules"></span>'));
$('#n-FAQ > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-faq"></span>'));
$('#n-Staff > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-staff"></span>'));
$('#n-Forums > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-forums"></span>'));
$('#n-Discord > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-discord"></span>'));
$('#n-Punishments > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-punishments"></span>'));
//
$('#n-Getting-Started > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-start"></span>'));
$('#n-Economy > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-gem"></span>'));
$('#n-Levels > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-level"></span>'));
$('#n-mcMMO > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-swords"></span>'));
$('#n-Shops > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-shop2"></span>'));
$('#n-Claims > a:eq(0)').prepend($('<span class="citizen-ui-icon mw-ui-icon-claim"></span>'));
});
// Randomly select background from array (light only, no path, no extension)
var bgArray = [
'/images/f/f1/Background2'
];
var bg = bgArray[Math.floor(Math.random() * bgArray.length)];
// Randomly select background from array (dark only, no path, no extension)
var bgArray_dark = [
'/images/7/7f/Background2_dark'
];
var bg_dark = bgArray_dark[Math.floor(Math.random() * bgArray_dark.length)];
// Page Header IMG
// Get only pages with the category "Dynamic background"
$(document).ready( function () {
if ($.inArray("Dynamic background", mw.config.get("wgCategories")) > -1) {
var mwBody = document.getElementById("content");
var newDiv = document.createElement("div");
newDiv.setAttribute("class", "header-hero");
newDiv.innerHTML = '<div class="header-hero-image" style="background-image: linear-gradient(to top, var(--color-surface-0), transparent 150%), var(--hero-image);background-size: cover;background-position: 0 0, center;height: 50vh;margin-bottom: -50vh;"></div>';
mwBody.parentNode.insertBefore(newDiv, mwBody);
}
var html = document.querySelector("html");
if (html.classList.contains("skin-citizen-dark")) {
document.documentElement.style.setProperty("--hero-image", "url(" + bg_dark + ".webp");
} else {
document.documentElement.style.setProperty("--hero-image", "url(" + bg + ".webp");
}
document.addEventListener('click', function(event) {
setTimeout(function() {
var html = document.querySelector("html");
if (html.classList.contains("skin-citizen-dark")) {
document.documentElement.style.setProperty("--hero-image", "url(" + bg_dark + ".webp");
} else {
document.documentElement.style.setProperty("--hero-image", "url(" + bg + ".webp");
}
}, 100);
}, true);
});