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

Content deleted Content added
No edit summary
No edit summary
Line 5:
*/
 
// <nowiki>
$(function()
{
Line 20 ⟶ 21:
$(".mw-contributions-list").children().each(function()
{
$(this).children().first().text(partitionrxReplace($(this).children().first().text()));
});
break;
Line 29 ⟶ 30:
$("ul").children().each(function()
{
$(this).html(regexpReplacerxReplace($(this).html()));
});
break;
case "Listusers":
var index, html, time;
$("ul").children().each(function()
{
$(this).html = ($(this).html().replace(/(on \d{1,2} \w+ \d{4} at )(\d\d:\d\d)()/g, rxPartition));
index = html.indexOf("Created on ");
time = partition(html.substring(index));
html = html.substring(0, index);
$(this).html(html + time);
});
break;
Line 56 ⟶ 51:
$("td > a").each(function()
{
$(this).html(regexpReplace($(this).html().replace(/()(\d\d:\d\d)(, \d{1,2} \w+ \d{4})/g, rxPartition));
});
break;
Line 76 ⟶ 71:
if($(this).attr("class") == "mw-changeslist-date")
{
$(this).text(partitionrxReplace($(this).text()));
}
});
Line 85 ⟶ 80:
if(document.title.indexOf("Difference between revisions") > -1)
{
$("#mw-diff-ntitle1 > strong > a").html(regexpReplacerxReplace($("#mw-diff-ntitle1 > strong > a").html()));
$("#mw-diff-otitle1 > strong > a").html(regexpReplacerxReplace($("#mw-diff-otitle1 > strong > a").html()));
$(".diff-currentversion-title").text(partitionrxReplace($(".diff-currentversion-title").text()));
}
Line 93 ⟶ 88:
if($("div").hasClass("mw-revision"))
{
$("#mw-revision-date").html(regexpReplacerxReplace($("#mw-revision-date").html()));
}
// 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, partitionrxPartition));
break;
Line 114 ⟶ 109:
$(".mw-warning-with-logexcerpt.mw-content-ltr > ul").children().each(function()
{
$(this).html(regexpReplacerxReplace($(this).html()));
});
}
Line 121 ⟶ 116:
if($("#footer-info-lastmod").length)
{
$("#footer-info-lastmod").text(partitionrxReplace($("#footer-info-lastmod").text()));
}
});
 
/*
function partition(text)
* Used when it is unlikely non-times will be matched.
*/
function partitionrxReplace(texthtml)
{
return html.replace(/(\d\d:\d\d)/g, convert);
var front = text.substr(0, text.indexOf(":") - 2);
var time = convert(text.substr(text.indexOf(":") - 2, 5));
var end = text.substr(text.indexOf(":") + 3, text.length);
return (front + time + end);
}
 
/*
function regexpReplace(html) // Regexp param?
* Used when a very specific match needs to be made and
{
* only a substring of the match should be modified.
return html.replace(/(\d\d:\d\d)/g, convert);
*/
function rxPartition(match, p1, p2, p3)
{
return (frontp1 + timeconvert(p2) + endp3);
}
 
Line 160 ⟶ 158:
return (hour + time.substr(2, 5) + " AM");
}
// </nokiki>