Difference between revisions of "MediaWiki:Common.js"

From SgWiki
Jump to navigation Jump to search
m
m
Line 5: Line 5:
if (hour <= 2) { d.setTime(d.getTime() - 7200000); }
if (hour <= 2) { d.setTime(d.getTime() - 7200000); }


var day = d.getDate();
var x = ('00' + d.getDate()).substr(-2) + ('00' + (d.getMonth() + 1)).substr(-2) + d.getFullYear().substr(-2);
var month = d.getMonth() + 1;
var year = d.getFullYear();
var x = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()];
 
if ((day + ' ' + month + ' ' + year) == '29 5 2018') x = 'PH'; //Vesak Day
else if ((day + ' ' + month + ' ' + year) == '15 6 2018') x = 'PH'; //Hari Raya Puasa
else if ((day + ' ' + month + ' ' + year) == '9 8 2018') x = 'PH'; //National Day
else if ((day + ' ' + month + ' ' + year) == '22 8 2018') x = 'PH'; //Hari Raya Haji
else if ((day + ' ' + month + ' ' + year) == '6 11 2018') x = 'PH'; //Deepavali
else if ((day + ' ' + month + ' ' + year) == '25 12 2018') x = 'PH'; //Christmas Day
 
if ((day + ' ' + month + ' ' + year) == '28 5 2018') x = 'Eve'; //Vesak Day
else if ((day + ' ' + month + ' ' + year) == '14 6 2018') x = 'Eve'; //Hari Raya Puasa
else if ((day + ' ' + month + ' ' + year) == '8 8 2018') x = 'Eve'; //National Day
else if ((day + ' ' + month + ' ' + year) == '21 8 2018') x = 'Eve'; //Hari Raya Haji
else if ((day + ' ' + month + ' ' + year) == '5 11 2018') x = 'Eve'; //Deepavali
else if ((day + ' ' + month + ' ' + year) == '24 12 2018') x = 'Eve'; //Christmas Day


$('span.Advisory').each(function () {
$('span.Advisory').each(function () {
if (!$(this).hasClass(x)) $(this).remove();
if (!$(this).hasClass(x)) {
if ($(this).hasClass('train') || $(this).hasClass('event')) $(this).remove();
};
})
})
$('span.Advisory:last-of-type').find('hr').remove();
$('span.Advisory:last-of-type').find('hr').remove();
 
if ($('span.Advisory').length == 0) $('table#TravelAdvisory').remove();
if ($('span.Advisory').length == 0) {
$('table#TravelAdvisory').remove();
}

Revision as of 11:08, 22 August 2018

/* Any JavaScript here will be loaded for all users on every page load. */

var d = new Date();
var hour = d.getHours();
if (hour <= 2) { d.setTime(d.getTime() - 7200000); }

var x = ('00' + d.getDate()).substr(-2) + ('00' + (d.getMonth() + 1)).substr(-2) + d.getFullYear().substr(-2);

$('span.Advisory').each(function () {
	if (!$(this).hasClass(x)) {
		if ($(this).hasClass('train') || $(this).hasClass('event')) $(this).remove();
	};
})
$('span.Advisory:last-of-type').find('hr').remove();
if ($('span.Advisory').length == 0) $('table#TravelAdvisory').remove();