MediaWiki:Common.js: Difference between revisions
From Comprehensible Input Wiki
Content added Content deleted
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
if(window.location.hostname == 'comprehensibleinput.miraheze.org'){ |
if(window.location.hostname == 'comprehensibleinput.miraheze.org'){ |
||
$('#bodyContent').prepend('<div id=" |
$('#bodyContent').prepend('<div id="popupLink">[[#redirectPopupModal|]]</div><div id="redirectPopupModal" class="modalDialog"><div><div class="close">[[#close2|X]]</div><div style="max-height:500px;overflow:auto;">New URL!<br>Redirecting to <b>comprehensibleinputwiki.org</b> in <span id="countdown"></span> seconds.</div></div></div>'); |
||
document.querySelector( |
document.querySelector("#popupLink").lastElementChild.click() |
||
var timeleft = 5000; |
var timeleft = 5000; |
||
var redirectTimer = setInterval(function(){ |
var redirectTimer = setInterval(function(){ |
||
if(timeleft <= 0){ |
|||
clearInterval(redirectTimer); |
|||
window.location.hostname='comprehensibleinputwiki.org' |
|||
} |
|||
document.getElementById("countdown").innerHTML = Math.ceil(timeleft/1000); |
|||
timeleft -= 100; |
|||
}, 100); |
}, 100); |
||
} |
} |
||
}); |
}); |
Revision as of 22:48, 23 January 2023
/* Any JavaScript here will be loaded for all users on every page load. */
//Wait for page to be parsed
$(document).ready( function () {
if(window.location.hostname == 'comprehensibleinput.miraheze.org'){
$('#bodyContent').prepend('<div id="popupLink">[[#redirectPopupModal|]]</div><div id="redirectPopupModal" class="modalDialog"><div><div class="close">[[#close2|X]]</div><div style="max-height:500px;overflow:auto;">New URL!<br>Redirecting to <b>comprehensibleinputwiki.org</b> in <span id="countdown"></span> seconds.</div></div></div>');
document.querySelector("#popupLink").lastElementChild.click()
var timeleft = 5000;
var redirectTimer = setInterval(function(){
if(timeleft <= 0){
clearInterval(redirectTimer);
window.location.hostname='comprehensibleinputwiki.org'
}
document.getElementById("countdown").innerHTML = Math.ceil(timeleft/1000);
timeleft -= 100;
}, 100);
}
});