MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary Tag: Reverted |
||
| Line 82: | Line 82: | ||
} | } | ||
}); | }); | ||
}); | |||
/* Countdown (Test) */ | |||
$(document).ready(function() { | |||
var targetDate = new Date("March 15, 2025 00:00:00").getTime(); | |||
var countdown = setInterval(function() { | |||
var now = new Date().getTime(); | |||
var distance = targetDate - now; | |||
var days = Math.floor(distance / (1000 * 60 * 60 * 24)); | |||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | |||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | |||
var seconds = Math.floor((distance % (1000 * 60)) / 1000); | |||
// Display the countdown | |||
$('#countdown').html(days + "d " + hours + "h " + minutes + "m " + seconds + "s "); | |||
if (distance < 0) { | |||
clearInterval(countdown); | |||
$('#countdown').html("EXPIRED"); | |||
} | |||
}, 1000); | |||
}); | }); | ||
Revision as of 19:16, 27 February 2025
/* Any JavaScript here will be loaded for all users on every page load. */
/*style based on category*/
(function($, mw) {
var fn = function() {
var cats = mw.config.get('wgCategories'), newClasses;
if (cats) {
newClasses = $.map(cats, function(el) {
return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
}).join(' ');
// Add the new categories as classes to the body
$(document.body).addClass(newClasses);
// Check if "SG" category exists and dynamically load the SG-specific CSS
if (cats.includes("SG")) {
// Create a link element to load the SG-specific CSS
var sgStyleLink = document.createElement("link");
sgStyleLink.rel = "stylesheet";
sgStyleLink.href = "https://example.com/sg-category-styles.css"; // Replace with the actual path of your SG styles
sgStyleLink.type = "text/css";
// Add the link to the head to load it first
document.head.appendChild(sgStyleLink);
}
}
};
if (document.body) {
fn();
} else {
$(fn);
}
})(jQuery, mw);
/*Kyle image down there*/
$(document).ready(function() {
// Get categories for the current page
var cats = mw.config.get('wgCategories');
// Check if the page belongs to the "SG" category
if (cats && !cats.includes("SG")) {
// Create a div element for the image
var imageDiv = document.createElement('div');
imageDiv.className = 'bottom-left-image';
// Add the image markup to the div with CSS for size adjustment
imageDiv.innerHTML = '<a href="Kyle" title="Image"><img src="https://skullgirlz.wiki/images/1/1f/Kyle_Bloodworth-Thomason2.png" style="width: 115px; height: auto;" /></a>';
// Append the div to the body
document.body.appendChild(imageDiv);
}
});
/* Admin names text style */
$(function () {
// Define the admin usernames
var adminUsers = ["Ninespit", "Nacho-dipsauce14"];
// Check all user links and apply the 'admin' class
$(".mw-userlink").each(function () {
var username = $(this).text().trim();
if (adminUsers.includes(username)) {
$(this).addClass("admin");
}
});
});
/* Admin name text style icon */
$(function () {
// Define user-specific icons
var userIcons = {
"Ninespit": "image",
"Nacho-dipsauce14": "image",
"Ninimasurasilly": "image",
};
// Loop through all user links
$(".mw-userlink").each(function () {
var username = $(this).text().trim();
if (userIcons[username]) {
$(this).addClass("user-" + username);
}
});
});
/* Countdown (Test) */
$(document).ready(function() {
var targetDate = new Date("March 15, 2025 00:00:00").getTime();
var countdown = setInterval(function() {
var now = new Date().getTime();
var distance = targetDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the countdown
$('#countdown').html(days + "d " + hours + "h " + minutes + "m " + seconds + "s ");
if (distance < 0) {
clearInterval(countdown);
$('#countdown').html("EXPIRED");
}
}, 1000);
});