User:Guywan/Scripts/12HourFormat.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
/*
* Install with:
* <code><nowiki>{{subst:Iusc|User:Guywan/Scripts/12HourFormat.js}}</nowiki></code>
* or:
* <code><nowiki>importScript("User:Guywan/Scripts/12HourFormat.js"); // Backlink: [[User:Guywan/Scripts/12HoursFormat.js]]</nowiki></code>
*
* This script was originally authored by User:Bility, [[User:Bility/convert24hourtime.js]].
* Considerable contributions by User:DannyS712, [[User:DannyS712/12Hours.js]], whose version I have forked.
Line 31 ⟶ 26:
case "Log":
case "Userrights":
$("ul").children().each(function()
{
$(this).html(regexpReplace($(this).html(), 1, 5));
});
break;
case "AbuseLog":
$("ul").children().each(function()
{
$(this).html(regexpReplace($(this).html(), 0, 5));
});
break;
Line 67 ⟶ 56:
$("td > a").each(function()
{
var text = $(this).texthtml(regexpReplace($(this).html()));
var index = text.indexOf(":");
if(index > -1)
{
var time = text.substr(index - 2, 6);
// Will convert anything in a table matching the pattern "dd:dd," where d is a digit.
if(time.match(/\d\d:\d\d,/))
{
$(this).text(partition(text));
}
}
});
break;
Line 108 ⟶ 85:
if(document.title.indexOf("Difference between revisions") > -1)
{
var$("#mw-diff-ntitle1 comp> =strong > a").html(regexpReplace($("#mw-diff-ntitle1 > strong > a").html()));
$("#mw-diff-otitle1 > strong > a").html(regexpReplace($("#mw-diff-otitle1 > strong > a").html()));
var temp;
for(i = 0; i < 2; i++)
{
temp = ($(comp).html());
$(comp).html(temp.replace(/(\d\d:\d\d)/g, convert(temp.substr(temp.indexOf(":") - 2, 5))));
comp = "#mw-diff-otitle1 > strong > a";
}
$(".diff-currentversion-title").text(partition($(".diff-currentversion-title").text()));
}
Line 125 ⟶ 93:
if($("div").hasClass("mw-revision"))
{
$("#mw-revision-date").html(regexpReplace($("#mw-revision-date").html(), 0, 5));
}
// Modify user signatures.
$("#mw-content-text").html = ($("#mw-content-text").html().replace(/(<\/a>\)\s\d\d:\d\d,\s\d{1,2}\s\w+\s\d{4}\s)/g, partition));
switch(mw.config.get("wgDefaultDateFormat"))
{
case "dmy":
// HH:MM, DD MM YY //
html = html.replace(/(<\/a>\)\s\d\d:\d\d,\s\d{1,2}\s\w+\s\d{4}\s)/g, partition);
break;
case "mdy":
// HH:MM, MM DD YY //
html = html.replace(/(<\/a>\)\s\d\d:\d\d,\s\w+\s\d{1,2}\s\d{4}\s)/g, partition);
break;
case "ymd":
// HH:MM, YY MM DD //
html = html.replace(/(<\/a>\)\s\d\d:\d\d,\s\d{4}\s\w+\s\d{1,2}\s)/g, partition);
break;
}
$("#mw-content-text").html(html);
break;
Line 166 ⟶ 114:
$(".mw-warning-with-logexcerpt.mw-content-ltr > ul").children().each(function()
{
$(this).html(regexpReplace($(this).html(), 1, 5));
});
}
Line 186 ⟶ 134:
}
 
function regexpReplace(html,) start,// num)Regexp param?
{
return html.replace(/(\d\d:\d\d)/g, convert(html.substr(start, num)));
}