Skip to content

Commit

Permalink
Updating sitewide JavaScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 13, 2024
1 parent 00c2b73 commit 2e59e14
Show file tree
Hide file tree
Showing 89 changed files with 3,291 additions and 3,426 deletions.
124 changes: 61 additions & 63 deletions dist/100orangejuice/Countdown.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,76 @@
// https://vincoding.com/weekly-repeating-countdown-timer-javascript/
// ToDo: Remove date variable by fixing second calculation
(function(mw) {
'use strict';

var countdown, curday, secTime, ticker;
var countdowns = [];

function getSeconds(cd) {
var tmpDate = new Date();
var nowDate = new Date(
tmpDate.getUTCFullYear(),
tmpDate.getUTCMonth(),
tmpDate.getUTCDate(),
tmpDate.getUTCHours(),
tmpDate.getUTCMinutes(),
tmpDate.getUTCSeconds()
);
var dy = Number(countdown[cd].dataset.day) || tmpDate.getUTCDay() ; //Sunday through Saturday, 0 to 6
function getSeconds(index) {
var curday,
cd = countdowns[index],
ele = cd[2],
tmpDate = new Date(),
nowDate = new Date(
tmpDate.getUTCFullYear(),
tmpDate.getUTCMonth(),
tmpDate.getUTCDate(),
tmpDate.getUTCHours(),
tmpDate.getUTCMinutes(),
tmpDate.getUTCSeconds()
),
dy = Number(ele.getAttribute('data-day')) || tmpDate.getUTCDay(), // Sunday through Saturday, 0 to 6
countertime = new Date(
tmpDate.getUTCFullYear(),
tmpDate.getUTCMonth(),
tmpDate.getUTCDate(),
(Number(ele.getAttribute('data-hour')) || tmpDate.getUTCHours()),
(Number(ele.getAttribute('data-minute')) || tmpDate.getUTCMinutes()),
tmpDate.getUTCSeconds()
),
curtime = nowDate.getTime(), //current time
atime = countertime.getTime(), //countdown time
diff = parseInt((atime - curtime) / 1000);
if (diff > 0) { curday = dy - tmpDate.getUTCDay(); }
else { curday = dy - tmpDate.getUTCDay() -1; } //after countdown time
if (curday < 0) curday += (ele.getAttribute('data-day') ? 7 : 1 ); //already after countdown time, switch to next week
if (diff <= 0) diff += (86400 * 7);

var countertime = new Date(
tmpDate.getUTCFullYear(),
tmpDate.getUTCMonth(),
tmpDate.getUTCDate(),
(Number(countdown[cd].dataset.hour) || tmpDate.getUTCHours()),
(Number(countdown[cd].dataset.minute) || tmpDate.getUTCMinutes()),
tmpDate.getUTCSeconds()
);

var curtime = nowDate.getTime(); //current time
var atime = countertime.getTime(); //countdown time
var diff = parseInt((atime - curtime) / 1000);
if (diff > 0) { curday[cd] = dy - tmpDate.getUTCDay(); }
else { curday[cd] = dy - tmpDate.getUTCDay() -1; } //after countdown time
if (curday[cd] < 0) { curday[cd] += (countdown[cd].dataset.day ? 7 : 1 ); } //already after countdown time, switch to next week
if (diff <= 0) { diff += (86400 * 7); }
startTimer (cd, diff);
cd[0] = diff;
cd[1] = curday;
}

function startTimer(cd, secs) {
secTime[cd] = parseInt(secs);
ticker[cd] = setInterval(function() {tick(cd);}, 1000);
tick(cd); //initial count display
}
function tick() {
countdowns.forEach(function(cd, index) {
var secs = cd[0];

function tick(cd) {
var secs = secTime[cd];
if (secs > 0) {
secTime[cd]--;
} else {
clearInterval(ticker[cd]);
getSeconds(cd); //start over
}
if (secs > 0) {
cd[0]--;
} else {
getSeconds(index);
secs = cd[0];
}
var days = cd[1];

//var days = Math.floor(secs / 86400);
secs %= 86400;
var hours= Math.floor(secs / 3600);
secs %= 3600;
var mins = Math.floor(secs / 60);
secs %= 60;
//var days = Math.floor(secs / 86400);
secs %= 86400;
var hours = Math.floor(secs / 3600);
secs %= 3600;
var mins = Math.floor(secs / 60);
secs %= 60;

//update the time display
countdown[cd].textContent = (curday[cd] === 0 ? '' : curday[cd] + 'd ') +
((curday[cd] + hours) === 0 ? '' : hours + 'h ') +
mins + 'm';
cd[2].textContent = (days === 0 ? '' : days + 'd ') +
((days + hours) === 0 ? '' : hours + 'h ') +
mins + 'm';
});
}

function init($content) {
countdown = $content.find('.customCountdown');
if (!countdown.length) return;
tick();
setInterval(tick, 60000); // Update every minute

curday = [];
secTime = [];
ticker = [];
for (var i=0; i<countdown.length; i++) {
getSeconds(i);
}
}
mw.hook('wikipage.content').add(init);
mw.hook('wikipage.content').add(function($content) {
$content.find('.customCountdown:not(.loaded)').each(function(_, ele) {
ele.classList.add('loaded');
countdowns.push([0, 0, ele]); // seconds, days, element
});
});
})(window.mediaWiki);
13 changes: 13 additions & 0 deletions dist/acepedia/Common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Any JavaScript here will be loaded for all users on every page load. */

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:UCXSearchBar.js', ]});

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:Sofix.js', ]});

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:FixFeaturedArticlesImages.js', ]});

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:FixPhalanxBlockLinks.js', ]});

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:BalancedTabber.js', ]});

importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:FastDelete/code.js', ]});
49 changes: 49 additions & 0 deletions dist/afk-journey/Gadget-Tooltip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
mw.hook('wikipage.content').add(function() {
// add class to body as hook for any further styling or detection
var body = document.querySelector('body');
body.classList.add('gadget-toggle-tooltip');

// only run if page has any tooltip to avoid wasting resources
if (!document.querySelector('.custom-tt-wrapper')) {return;}

// Update tooltips to be above all content due to no overflow in most containers (e.g., tables)
var res = document.querySelector('body > .main-container > .resizable-container');
function updatePos(el) {
el = $(el);
if (el.length==0){return;}
if(!el.hasClass('mw-collapsed')) {
var togl = el.children('.mw-collapsible-toggle')[0];
var cont = el.children('.mw-collapsible-content');
el.css({position: 'unset'}); // make tooltip offset to page not toggle
cont.css({top: '', right: '', 'max-width': ''}); // remove any prev values for proper positioning and resizing
var parenPos = togl.offsetParent.getBoundingClientRect();
var pos = togl.getBoundingClientRect();
var w = Math.floor(el.outerWidth());
cont.css({
top: pos.top - parenPos.top,
right: parenPos.right - pos.right + w/2,
});
var pos2 = cont[0].getBoundingClientRect();
if (pos2.left<0) {
cont.css('max-width', cont.outerWidth()+pos2.left);
}
}
}

// run code on toggle by observing class change
var observer = new MutationObserver(function (m) {
if (m[0] && m[0].type === 'attributes' && m[0].attributeName === 'class' && m[0].target) {
updatePos(m[0].target);
}
});
$('.custom-tt-wrapper').each(function(_, element){
observer.observe(element, {attributes: true});
});

// update on page change too so it doesnt look off
$(window).on('scroll.tt resize.tt', function(e){
$('.custom-tt-wrapper:not(.mw-collapsed)').each(function(_, el){
updatePos(el);
});
});
});
File renamed without changes.
6 changes: 6 additions & 0 deletions dist/among-us/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ window.dev.VerifyUser = {
command: '$verify',
channel: 'verification'
};
// AUW Bot doesn't support pomelo yet
window.dev = window.dev || {};
window.dev.i18n = window.dev.i18n || {};
window.dev.i18n.overrides = window.dev.i18n.overrides || {};
window.dev.i18n.overrides['VerifyUser'] = window.dev.i18n.overrides['VerifyUser'] || {};
window.dev.i18n.overrides['VerifyUser']['verify-instructions'] = 'To verify, please enter your Discord username (IMPORTANT: you must include #0000 at the end to properly link your account) in the box below.';

// We have our own rollbacks
window.RollbackWikiDisable = true;
Expand Down
7 changes: 7 additions & 0 deletions dist/arcane-odyssey-ocs/Common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* Any JavaScript here will be loaded for all users on every page load. */
mw.hook("wikipage.content").add(function () {
$("span.import-css").each(function () {
var css = mw.util.addCSS($(this).attr("data-css"));
$(css.ownerNode).addClass("import-css").attr("data-css-hash", $("span.import-css").attr("data-css-hash")).attr("data-from", $("span.import-css").attr("data-from"));
});
});
Empty file.
11 changes: 7 additions & 4 deletions dist/clashofclans/GoldPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ $(document).ready(function() {
$("span#eventTrainingBoostHarness").html('<div id="eventTrainingBoostInput">Training Boost: <select name="eventTrainingBoost" id="eventTrainingBoost">' +
'<option value="0">0</option>' +
// '<option value="15">15</option>' +
// '<option value="30">30</option>' +
'<option value="50">50</option>' +
'<option value="30">30</option>' +
// '<option value="50">50</option>' +
'</select> %</div>');
$("span#starBonusHarness").html('<div id="starBonusInput"">Star Bonus Multiplier: <select name="starBonusBoost" id="starBonusBoost">' +
'<option value="1">1</option>' +
Expand Down Expand Up @@ -243,6 +243,7 @@ $(document).ready(function() {
"Rage Gem": [18,15],
"Healing Tome": [18,15],
"Fireball": [27,21],
"Lavaloon Puppet": [27,21],
"Royal Gem": [18,15],
"Seeking Shield": [18,15],
"Hog Rider Puppet": [18,15],
Expand All @@ -260,13 +261,13 @@ $(document).ready(function() {
heroGearOptions = ["Archer Puppet", "Invisibility Vial", "Giant Arrow", "Healer Puppet", "Frozen Arrow", "Magic Mirror"];
break;
case ("Grand Warden"):
heroGearOptions = ["Eternal Tome", "Life Gem", "Rage Gem", "Healing Tome", "Fireball"];
heroGearOptions = ["Eternal Tome", "Life Gem", "Rage Gem", "Healing Tome", "Fireball", "Lavaloon Puppet"];
break;
case ("Royal Champion"):
heroGearOptions = ["Royal Gem", "Seeking Shield", "Hog Rider Puppet", "Haste Vial", "Rocket Spear"];
break;
default: // Having all options in one makes it excellent for testing
heroGearOptions = ["Barbarian Puppet", "Rage Vial", "Earthquake Boots", "Vampstache", "Giant Gauntlet", "Spiky Ball", "Archer Puppet", "Invisibility Vial", "Giant Arrow", "Healer Puppet", "Frozen Arrow", "Magic Mirror", "Eternal Tome", "Life Gem", "Rage Gem", "Healing Tome", "Fireball", "Royal Gem", "Seeking Shield", "Hog Rider Puppet", "Haste Vial", "Rocket Spear"];
heroGearOptions = ["Barbarian Puppet", "Rage Vial", "Earthquake Boots", "Vampstache", "Giant Gauntlet", "Spiky Ball", "Archer Puppet", "Invisibility Vial", "Giant Arrow", "Healer Puppet", "Frozen Arrow", "Magic Mirror", "Eternal Tome", "Life Gem", "Rage Gem", "Healing Tome", "Fireball", "Lavaloon Puppet", "Royal Gem", "Seeking Shield", "Hog Rider Puppet", "Haste Vial", "Rocket Spear"];
}
// Insert options
for (i = 0; i < heroGearOptions.length; i++) {
Expand Down Expand Up @@ -971,6 +972,7 @@ $(document).ready(function() {
"Life Gem": [10,12,14,16,18,20,22,24,28,32,38,42,46,50,54,58,62,66],
"Rage Gem": [12,14,16,18,20,22,24,26,30,36,43,49,56,62,69,75,82,88],
"Fireball": [21,24,27,30,33,36,40,44,47,51,56,60,63,67,71,74,77,80,82,84,87,89,92,94,96,99,101],
"Lavaloon Puppet": [10,12,13,15,16,18,20,22,23,25,28,30,31,33,35,37,38,40,41,42,43,45,46,47,48,49,50],
"Royal Gem": [20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105],
"Frozen Arrow": [35,40,45,50,55,60,66,72,78,85,92,99,105,111,117,122,127,132,136,140,144,148,152,156,160,164,168],
"Haste Vial": [20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88],
Expand All @@ -986,6 +988,7 @@ $(document).ready(function() {
"Magic Mirror": [88,96,113,131,157,184,228,272,307,342,377,412,448,483,518,553,588,624,650,676,703,729,756,782,808,835,861],
"Life Gem": [150,163,172,181,192,203,225,249,275,304,336,351,366,381,396,411,426,441],
"Healing Tome": [92,107,122,137,153,168,183,198,229,280,330,381,432,482,533,584,634,685],
"Lavaloon Puppet": [50,55,57,60,65,67,70,75,77,80,85,87,90,95,97,100,105,107,110,115,117,120,125,127,130,135,150],
"Royal Gem": [40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380],
"Seeking Shield": [40,60,80,100,120,140,160,180,200,220,240,260,280,300,320,340,360,380],
"Hog Rider Puppet": [60,90,120,150,180,210,240,270,300,330,360,390,420,450,480,510,540,570],
Expand Down
8 changes: 1 addition & 7 deletions dist/clubpenguinjourney/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
window.UserTagsJS = {
modules: {},
tags: {
'cpjstaff': { u:'CPJ Staff', order: -1/0 },
'wikifounder': { u:'Wiki Founder', order: (-1/0)+1 },
'topmonth': { u:'Top Monthly Editor', order: (-1/0)+2 },
bureaucrat: { order: 0 },
sysop: { order: 1 },
Expand All @@ -15,13 +13,9 @@ window.UserTagsJS = {
oasisPlaceBefore: ''
};
UserTagsJS.modules.custom = {
'AmmanCPJ': ['cpjstaff'],
'DropPT': ['cpjstaff'],
'Pifflez': ['cpjstaff'],
'Hermbeurg': ['wikifounder'],
'Tuna Takoyaki': ['topmonth'],
'Tenny407': ['trialmoderator'], // need to check if they're still here tbh
};

UserTagsJS.modules.mwGroups = ['content-moderator', 'threadmoderator'];
UserTagsJS.modules.inactive = 90; // 90 days

Expand Down
2 changes: 1 addition & 1 deletion dist/control-army-2/Common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Any JavaScript here will be loaded for all users on every page load. */
window.tooltips_config = {
events: ['CustomEvent'],
events: ['mouseover'],
noCSS: true,
offsetX: 5,
offsetY: 10,
Expand Down
Loading

0 comments on commit 2e59e14

Please sign in to comment.