User:Xaradnam/monobook.js: Difference between revisions
Appearance
Content deleted Content added
m test |
m test |
||
Line 49: | Line 49: | ||
ts=ts.toUTCString(); |
ts=ts.toUTCString(); |
||
showTxt("ts2=" + ts); |
showTxt("ts2=" + ts); |
||
badts=badts.toUTCString(); |
|||
showTxt("badts2=" + badts); |
|||
mth=ts.substr(8, 3); |
mth=ts.substr(8, 3); |
||
//UTCtime: Sat, 06 Feb 2021 17 : 42 :00 GMT → 09:42, 6 February 2021 (UTC) |
//UTCtime: Sat, 06 Feb 2021 17 : 42 :00 GMT → 09:42, 6 February 2021 (UTC) |
Revision as of 08:39, 14 April 2022
// <nowiki>
CurPg=mw.config.get('wgPageName'); // Current page name
CurNSnum=mw.config.get('wgNamespaceNumber');
//==================================================
function printValue(txt, val)
{$('body').append('<center><h4><tt>' + txt + ': ' + val + ' </tt></h4></center>');}
// ========= DISPLAY AT BOTTOM (OR TOP) OF PAGE ==========
function showTxt(txt,top)
{
line='<h4 style="text-align:center;"><tt>'+txt+'</tt></h4>';
if (top) $('body').prepend(line);
else $('body').append(line);
}
// a convenient way to display test values
if (CurPg=="User:Xaradnam/monobook.js")
{
showTxt("This is "+CurPg, 1);
}
//==================================================
if (CurPg=="User:Xaradnam/monobook.js") printValue("CurPg", CurPg);
DiffOnly = {
watchlist: true,
diff: false
}
importScript('User:Mr. Stradivarius/gadgets/DiffOnly.js');
importScript('User:Theleekycauldron/DYKViews.js');
// ======== SHOW {{Unsigned}} AT BOTTOM OF DIFF TALK+ PAGES =========
// For potential unsigned comments on talk, WP, template (for DYK noms)
// Works with any of the four Wiki date formats available in Prefs
if (mw.config.get('wgDiffNewId') && (CurNSnum%2==1||CurNSnum==4||CurNSnum==10))
{
const month=[];
month["Jan"]="January"; month["Feb"]="February"; month["Mar"]="March";
month["Apr"]="April"; month["May"]="May"; month["Jun"]="June";
month["Jul"]="July"; month["Aug"]="August"; month["Sep"]="September";
month["Oct"]="October"; month["Nov"]="November"; month["Dec"]="December";
usr=document.getElementById('mw-diff-ntitle2').firstChild.firstChild.firstChild.nodeValue;
rev=document.getElementById('mw-diff-ntitle1').firstChild.firstChild.firstChild.nodeValue;
showTxt("rev=" + rev);
//Change 09:31, October 25, 2021 to format Apple accepts: October 25, 2021 09:31
var badts = new Date(rev);
showTxt("badts=" + badts);
var ts = new Date(rev.replace(/(Latest )?Revision as of (..:..), (.*)/i, "$3 $2"));
showTxt("ts=" + ts);
ts=ts.toUTCString();
showTxt("ts2=" + ts);
badts=badts.toUTCString();
showTxt("badts2=" + badts);
mth=ts.substr(8, 3);
//UTCtime: Sat, 06 Feb 2021 17 : 42 :00 GMT → 09:42, 6 February 2021 (UTC)
ts=ts.replace(/..., (\d+) (...) (\d+) (\d+):(\d+).*/, "$4:$5, $1 $2 $3 (UTC)");
ts=ts.replace(mth, month[mth]).replace(", 0", ", ");
showTxt("{{subst:Unsigned|" + usr + "|" + ts + "}}");
}
// </nowiki>