Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m |
m |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
try { | |||
var d = new Date(); | var d = new Date(); | ||
var hour = d.getHours(); | var hour = d.getHours(); | ||
Line 18: | Line 19: | ||
if ($('table#TravelAdvisory span.Advisory').length == 0) $('table#TravelAdvisory').remove(); | if ($('table#TravelAdvisory span.Advisory').length == 0) $('table#TravelAdvisory').remove(); | ||
$('table#TravelAdvisory u>span').html(' (' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ')'); | $('table#TravelAdvisory u>span').html(' (' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ')'); | ||
} catch (e) {}; | |||
//try { | |||
//$('#n-mainpage-description').after("<li id='n-advisory'><a href='/wiki/Template:Travel Advisory' title='COVID-19'>COVID-19 Advisory</a></li>"); | |||
//} catch (e) {}; | |||
/* Custom Auto Redirect */ | /* Custom Auto Redirect */ | ||
try { | |||
if ($('#mw-content-text span.redirect').length == 1 && $('table.diff').length == 0) setTimeout(function () { location.href = $('#mw-content-text span.redirect a').attr('href'); }, 5000); //auto-redirect in 5s | if ($('#mw-content-text span.redirect').length == 1 && $('table.diff').length == 0) setTimeout(function () { location.href = $('#mw-content-text span.redirect a').attr('href'); }, 5000); //auto-redirect in 5s | ||
} catch (e) {}; | |||
/* Infobox */ | /* Infobox */ | ||
try { | |||
if ($('.infobox tr:first-of-type img').length == 0) $('.infobox .img-alt').remove(); | if ($('.infobox tr:first-of-type img').length == 0) $('.infobox .img-alt').remove(); | ||
} catch (e) {}; | |||
/*Partial Hide*/ | /*Partial Hide*/ | ||
try { | |||
$('.exc').on('click', function () { $(this).nextUntil('.exc').find('.ex').toggle(); }) | $('.exc').on('click', function () { $(this).nextUntil('.exc').find('.ex').toggle(); }) | ||
$('.ex').hide(); | $('.ex').hide(); | ||
} catch (e) {}; | |||
/*Hidden Removal*/ | /*Hidden Removal*/ | ||
try { | |||
$('.hide').remove(); | $('.hide').remove(); | ||
if ($('#mw-content-text>p:first-child').html() | if ($('#mw-content-text>p:first-child').html().indexOf('<br>') === 0) $('#mw-content-text>p:first-child').remove(); | ||
} catch (e) {}; | |||
/* Customised sgWiki Theme */ | /* Customised sgWiki Theme */ | ||
/*Christmas | /*Christmas | ||
if (d.getMinutes() >= 0 && d.getMinutes() <= 10) $('div#bodyContent').append('<div id="snowflakes"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div>');*/ | if (d.getMinutes() >= 0 && d.getMinutes() <= 10) $('div#bodyContent').append('<div id="snowflakes"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div>');*/ |
Latest revision as of 16:29, 13 July 2020
/* Any JavaScript here will be loaded for all users on every page load. */ try { var d = new Date(); var hour = d.getHours(); if (hour <= 4) { d.setTime(d.getTime() - 7200000); } var x = ('00' + d.getDate()).substr(-2) + ('00' + (d.getMonth() + 1)).substr(-2) + ('00' + d.getFullYear()).substr(-2); $('span.Advisory,td.Advisory,th.Advisory').each(function () { if (!$(this).hasClass(x)) { if (($(this).hasClass('train') || $(this).hasClass('event')) && !$(this).hasClass('not')) $(this).remove(); } else { if (($(this).hasClass('train') || $(this).hasClass('event')) && $(this).hasClass('not')) $(this).remove(); }; }) if ($('table#TravelAdvisory span.showonly').length != 0 || $('table#TravelAdvisory').hasClass('partial')) $('table#TravelAdvisory span.Advisory:not(.showonly)').remove(); $('span.Advisory:last-of-type').find('hr').remove(); if ($('table#TravelAdvisory span.Advisory').length == 0) $('table#TravelAdvisory').remove(); $('table#TravelAdvisory u>span').html(' (' + d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear() + ')'); } catch (e) {}; //try { //$('#n-mainpage-description').after("<li id='n-advisory'><a href='/wiki/Template:Travel Advisory' title='COVID-19'>COVID-19 Advisory</a></li>"); //} catch (e) {}; /* Custom Auto Redirect */ try { if ($('#mw-content-text span.redirect').length == 1 && $('table.diff').length == 0) setTimeout(function () { location.href = $('#mw-content-text span.redirect a').attr('href'); }, 5000); //auto-redirect in 5s } catch (e) {}; /* Infobox */ try { if ($('.infobox tr:first-of-type img').length == 0) $('.infobox .img-alt').remove(); } catch (e) {}; /*Partial Hide*/ try { $('.exc').on('click', function () { $(this).nextUntil('.exc').find('.ex').toggle(); }) $('.ex').hide(); } catch (e) {}; /*Hidden Removal*/ try { $('.hide').remove(); if ($('#mw-content-text>p:first-child').html().indexOf('<br>') === 0) $('#mw-content-text>p:first-child').remove(); } catch (e) {}; /* Customised sgWiki Theme */ /*Christmas if (d.getMinutes() >= 0 && d.getMinutes() <= 10) $('div#bodyContent').append('<div id="snowflakes"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div>');*/