User:Anomie/lastmod.js: Difference between revisions

Content deleted Content added
jQuery-ize
maintenance: more info TypeError: Cannot read property '0' of undefined
 
(2 intermediate revisions by one other user not shown)
Line 15:
if(typeof(window.LastModMonths)=='undefined') window.LastModMonths=['January','February','March','April','May','June','July','August','September','October','November','December'];
 
if(mw.config.get('wgNamespaceNumber')>=0) mw.loader.using('mwmediawiki.util', function(){
$(document).ready(function(){
var ins=document.getElementById('siteSub');
Line 33:
},
success:function(r, sts, xhr){
try {
if(typeof( var ts = r.query.pages[articleId].revisions[0].timestamp)=='undefined') return;
} catch (e) {
return; // unexpected response e.g. TypeError: Cannot read property '0' of undefined
}
if(typeof(ts)=='undefined') return;
m=r.query.pages[articleId].revisions[0].timestamp.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/);
var dt;
if(window.LastModRelative){
dt=[];
var n=new Date();
Line 61 ⟶ 66:
else dt='about '+dt.join(', ')+' ago';
} else {
if(window.LastModUseUTC){
m[2]-=1;
} else {
Line 73 ⟶ 78:
}
 
if(window.LastModDateFormat=='dmy'){
dt=m[3]+' '+window.LastModMonths[m[2]]+' '+m[1];
} else if(window.LastModDateFormat=='dmy'){
dt=window.LastModMonths[m[2]]+' '+m[3]+', '+m[1];
} else {
m[2]++; if(m[2]<10) m[2]='0'+m[2];