Content deleted Content added
d'oh |
adjust |
||
Line 8:
importStylesheet('User:Anomie/lastmod.css');
var LastMod={
// Recognized values are "dmy" or "mdy"; anything else results in
// YYYY-MM-DD format output.
DateFormat:"dmy",
UseUTC:false,
if(wgNamespaceNumber<0) return;
var ins=document.getElementById('siteSub');
if(!ins) return;
var x = sajax_init_object();
if(!x) return;
x.open('POST', wgServer+wgScriptPath+'/api.php', true);
x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
x.onreadystatechange=function(){
if(x.readyState!=4) return;
var r;
if(typeof(window.JSON)!='undefined'){
r=JSON.parse(x.responseText);
} else {
r=x.responseText;
r=!(/[^,:{}\[\]0-9.\-+Eaeflnr-u\n\r\t]/.test(r.replace(/"(\\.|[^\x22\\])*"/g,''))) && eval('('+r+')');
}
if(typeof(r.query.pages[wgArticleId].revisions[0].timestamp)=='undefined') return;
m=r.query.pages[wgArticleId].revisions[0].timestamp.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/);
if(LastModUseUTC){
m[2]-=1;
} else {
var dt=new Date(Date.UTC(m[1],m[2]-1,m[3],m[4],m[5],m[6]));
m[1]=dt.getFullYear();
m[2]=dt.getMonth();
m[3]=dt.getDate();
m[4]=dt.getHours().toString(); if(m[4].length==1) m[4]='0'+m[4];
m[5]=dt.getMinutes().toString(); if(m[5].length==1) m[5]='0'+m[5];
m[6]=dt.getSeconds().toString(); if(m[6].length==1) m[6]='0'+m[6];
}
var dt;
if(LastModDateFormat=='dmy'){
dt=m[3]+' '+LastModMonths[m[2]]+' '+m[1];
} else if(LastModDateFormat=='dmy'){
dt=LastModMonths[m[2]]+' '+m[3]+', '+m[1];
} else {
dt=m[1]+'-'+m[2]+'-'+m[3];
}
dt+=' '+m[4]+':'+m[5];
var s=document.createElement('SPAN');
s.className='lastmodheader';
s.appendChild(document.createTextNode('Last modified '+dt));
ins.parentNode.insertBefore(s,ins);
};
x.send('action=query&format=json&titles='+encodeURIComponent(wgPageName)+'&prop=revisions&rvprop=timestamp');
}
}
addOnloadHook(LastMod.doIt);
|