MediaWiki:Common.js: Difference between revisions

From Future Of Mankind
Daniel Leech (talk | contribs)
No edit summary
Daniel Leech (talk | contribs)
No edit summary
Line 4: Line 4:
         console.log( "document loaded" );
         console.log( "document loaded" );


var monthNames = [ "January / Januar", "February / Februar", "March / März", "April", "May / Mai", "June / Juni", "July / Juli", "August", "September", "October / Oktober", "November", "December / Dezember" ];  
var monthNames = [ "January (Januar)", "February (Februar)", "March (März)", "April", "May (Mai)", "June (Juni)", "July (Juli)", "August", "September", "October (Oktober)", "November", "December (Dezember)" ];
var dayNames= ["Sunday / Sonntag,","Monday / Montag,","Tuesday / Dienstag,","Wednesday / Mittwoch,","Thursday / Donnerstag,","Friday / Freitag,","Saturday / Samstag,"]
 
var dayNames= ["Sunday (Sonntag)","Monday (Montag)","Tuesday (Dienstag)","Wednesday (Mittwoch)","Thursday (Donnerstag)","Friday (Freitag)","Saturday (Samstag)"]
 
function nth(n){return["st","nd","rd"][((n+90)%100-10)%10-1]||"th"}


var newDate = new Date();
var newDate = new Date();
Line 11: Line 14:
newDate.setDate(newDate.getDate());
newDate.setDate(newDate.getDate());


$('#FOMdate').html(dayNames[newDate.getDay()] + " " + newDate.getUTCDate() + ' ' + monthNames[newDate.getUTCMonth()] + ' ' + newDate.getUTCFullYear());
$('#FOMdate').html(dayNames[newDate.getDay()] + " the " + newDate.getUTCDate()+nth() + " of " + monthNames[newDate.getUTCMonth()] + ' ' + newDate.getUTCFullYear());


setInterval( function() {
setInterval( function() {
Line 32: Line 35:


$("#hours").html(( hours < 10 ? "0" : "" ) + hours);
$("#hours").html(( hours < 10 ? "0" : "" ) + hours);
}, 1000);
}, 1000)
});
});


Line 45: Line 48:
       $(this).show();
       $(this).show();
   });
   });
var dob = $('#agedate').val();
if(dob != ''){
    var str=dob.split('-');   
    var firstdate=new Date(str[0],str[1],str[2]);
    var today = new Date();       
    var dayDiff = Math.ceil(today.getTime() - firstdate.getTime()) / (1000 * 60 * 60 * 24 * 365);
    var age = parseInt(dayDiff);
    $('#age').html(age+' years old');
}
});
});

Revision as of 08:28, 4 June 2018

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

$( document ).ready(function() {
        console.log( "document loaded" );

var monthNames = [ "January (Januar)", "February (Februar)", "March (März)", "April", "May (Mai)", "June (Juni)", "July (Juli)", "August", "September", "October (Oktober)", "November", "December (Dezember)" ];

var dayNames= ["Sunday (Sonntag)","Monday (Montag)","Tuesday (Dienstag)","Wednesday (Mittwoch)","Thursday (Donnerstag)","Friday (Freitag)","Saturday (Samstag)"]

function nth(n){return["st","nd","rd"][((n+90)%100-10)%10-1]||"th"}

var newDate = new Date();

newDate.setDate(newDate.getDate());

$('#FOMdate').html(dayNames[newDate.getDay()] + " the " + newDate.getUTCDate()+nth() + " of " + monthNames[newDate.getUTCMonth()] + ' ' + newDate.getUTCFullYear());

setInterval( function() {

var seconds = new Date().getSeconds();

$("#sec").html(( seconds < 10 ? "0" : "" ) + seconds);
},1000);

setInterval( function() {

var minutes = new Date().getMinutes();

$("#min").html(( minutes < 10 ? "0" : "" ) + minutes);
},1000);

setInterval( function() {

var hours = new Date().getHours();

$("#hours").html(( hours < 10 ? "0" : "" ) + hours);
}, 1000)
});

$(function() {
  $(".DateDiv").each(function(index) {
    var sRange = $(this).find(".DateRange").html();
    var arrTemp = sRange.split(" to ");
    var dtFrom = new Date(arrTemp[0]);
    var dtTo = new Date(arrTemp[1]);
    var dtNow = new Date();
    if (dtNow >= dtFrom && dtNow <= dtTo)
      $(this).show();
  });

var dob = $('#agedate').val();
if(dob != ''){
    var str=dob.split('-');    
    var firstdate=new Date(str[0],str[1],str[2]);
    var today = new Date();        
    var dayDiff = Math.ceil(today.getTime() - firstdate.getTime()) / (1000 * 60 * 60 * 24 * 365);
    var age = parseInt(dayDiff);
    $('#age').html(age+' years old');
}
});