-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00c2b73
commit 2e59e14
Showing
89 changed files
with
3,291 additions
and
3,426 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', ]}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.