MediaWiki:Common.js: Difference between revisions
From PHIGHTING! Wiki
Content deleted Content added
Sillyvizion (talk | contribs) mNo edit summary |
Sillyvizion (talk | contribs) m Fixing JS relying on URLs |
||
(4 intermediate revisions by the same user not shown) | |||
Line 17:
Vine_Staff:"#FF5877",
Flipside:"
Valk:"#FDEA8D",
Dom:"#C79EFF",
Line 53:
if ($("h3:contains(Pronoun(s))").length > 0) {
pronouns = $("h3:contains(Pronoun(s))").next()[0].innerHTML.toLowerCase();
if (location.pathname.split('/')[
phighterName = pronounExclusions[location.pathname.split('/')[
$("h3:contains(Pronoun(s))").next()[0].title = 'While most demons are agender and use any pronouns, ' + phighterName + ' prefers ' + pronouns + ' pronouns!';
}
Line 67:
/* It is kind of bad practice because MW is IE11 compatible. Grr */
if (document.querySelectorAll("#ph-nav-dynamic-color").length > 0) {
const nodeList = document.querySelectorAll("#ph-nav-dynamic-color");
const dynamicColor = dynamicColorLibrary[location.pathname.split('/')[
nodeList.forEach(function (currentValue, currentIndex) {
nodeList[currentIndex].addEventListener("mouseover", function (e) {
if (dynamicColor === "Flipside") {▼
flipsideColors = [dynamicColorLibrary["Valk"], dynamicColorLibrary["Dom"]];▼
▲ if (dynamicColor == Flipside) {
▲ flipsideColors = [dynamicColorLibrary[Valk], dynamicColorLibrary[Dom]];
boxShadowColor = Math.floor(Math.random()*flipsideColors.length);
|
Revision as of 21:17, 3 July 2024
/* Any JavaScript here will be loaded for all users on every page load. */
const dynamicColorLibrary = {
Sword:"#D84C4C",
Skateboard:"#FF0000",
Biograft:"#FE6A00",
Katana:"#F95757",
Ban_Hammer:"#3A3A82",
Rocket:"#527CAE",
Slingshot:"#499FB8",
Hyperlaser:"#2A8DB0",
Shuriken:"#7CC740",
Scythe:"#23806F",
Medkit:"#2CBEA1",
Boombox:"#93BA49",
Subspace:"#FF006F",
Vine_Staff:"#FF5877",
Flipside:"Flipside",
Valk:"#FDEA8D",
Dom:"#C79EFF",
};
const pronounExclusions = {
"Lord_Pwnatious_%22Moneybags%22_the_III": "Pwnatious"
};
$( '.fp-discord' ).html( '<iframe src="https://discord.com/widget?id=933210573297057812&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>' );
/* Template:PhighterRainbow */
$(".pr-phighter").find("img").bind("webkitAnimationEnd mozAnimationEnd animationEnd", function(){
$(this).removeClass("pr-animated");
});
$(".pr-phighter").find("img").hover(function(){
$(this).addClass("pr-animated");
});
$(".pr-phighter").find("a").attr("href","javascript:void(0);");
/* NINJISY's silly little broker */
$(".ninjisy-broker").find("img").bind("webkitAnimationEnd mozAnimationEnd animationEnd", function(){
$(this).removeClass("pr-animated");
});
$(".ninjisy-broker").find("img").hover(function(){
$(this).addClass("pr-animated");
});
/* Pronoun tooltip */
if ($("h3:contains(Pronoun(s))").length > 0) {
pronouns = $("h3:contains(Pronoun(s))").next()[0].innerHTML.toLowerCase();
if (location.pathname.split('/')[1] in pronounExclusions) {
phighterName = pronounExclusions[location.pathname.split('/')[1]];
$("h3:contains(Pronoun(s))").next()[0].title = 'While most demons are agender and use any pronouns, ' + phighterName + ' prefers ' + pronouns + ' pronouns!';
}
else {
$("h3:contains(Pronoun(s))").next()[0].title = 'Demons are agender and use any pronouns - these are just the ones most commonly used for this particular demon!';
}
$("h3:contains(Pronoun(s))").next().eq(0).addClass("pr-tooltip");
}
/* Template:PhighterNav */
/* This JS handles the colour changing effect for the navbars on pages */
/* It is kind of bad practice because MW is IE11 compatible. Grr */
if (document.querySelectorAll("#ph-nav-dynamic-color").length > 0) {
const nodeList = document.querySelectorAll("#ph-nav-dynamic-color");
const dynamicColor = dynamicColorLibrary[location.pathname.split('/')[1]];
nodeList.forEach(function (currentValue, currentIndex) {
nodeList[currentIndex].addEventListener("mouseover", function (e) {
if (dynamicColor === "Flipside") {
flipsideColors = [dynamicColorLibrary["Valk"], dynamicColorLibrary["Dom"]];
boxShadowColor = Math.floor(Math.random()*flipsideColors.length);
nodeList[currentIndex].style.color = flipsideColors[boxShadowColor];
nodeList[currentIndex].style.boxShadow = "5px 5px 0px 0px " + flipsideColors[boxShadowColor];
nodeList[currentIndex].style.transition = "all 300ms ease";
}
else {
nodeList[currentIndex].style.color = dynamicColor;
nodeList[currentIndex].style.boxShadow = "5px 5px 0px 0px " + dynamicColor;
nodeList[currentIndex].style.transition = "all 300ms ease";
}
});
nodeList[currentIndex].addEventListener("mouseout", function (e)
{
nodeList[currentIndex].style.color = "inherit";
nodeList[currentIndex].style.boxShadow = "5px 5px 0px 0px #FFFFFF";
nodeList[currentIndex].style.transition = "all 750ms ease-in";
});
});
}