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

Content deleted Content added
No edit summary
No edit summary
Line 3:
* <code><nowiki>{{subst:Iusc|User:Guywan/Scripts/12HourFormat.js}}</nowiki></code>
* or:
* <code><nowiki>importScript("User:Guywan/Scripts/12HourFormat.js"); // BacklingBacklink: [[User:Guywan/Scripts/12HoursFormat.js]]</nowiki></code>
*
* This script was originally authored by User:Bility, [[User:Bility/convert24hourtime.js]].
Line 9:
* I have mainly streamlined the code and introduced more functionality.
*/
 
var config =
{
name : "[[User:Guywan/Scripts/12HourFormat]]",
version : 3.0,
debug : false
};
 
$(function()
{
////////////////
if(mw.config.get("wgCanonicalNamespace") == "Special")
// NAMESPACES //
////////////////
switch(mw.config.get("wgCanonicalNamespace"))
{
case "Special":
switch(mw.config.get("wgCanonicalSpecialPageName"))
{
switch(mw.config.get("wgCanonicalSpecialPageName"))
case "Contributions":
{
$(".mw-contributions-list").children().each(function()
case "Contributions":
{
$(this)".children().first().text(partition($(thismw-contributions-list").children().firsteach().textfunction()));
}); {
$(this).children().first().text(partition($(this).children().first().text()));
break;
});
case "Log": break;
case "Userrights":
case "Log":
$("ul").children().each(function()
case "Userrights":
{
$(this"ul").htmlchildren(regexpReplace($(this).htmleach(function(), 1, 5));
}); {
$(this).html(regexpReplace($(this).html(), 1, 5));
break;
});
break;
case "Project":
// TODO
break;case "Project":
// TODO
}
break;
}
}
else if(mw.config.get("wgCanonicalNamespace") == "File")
break;
{
// Modify time in file history table.
$("td > a").each(function()
{
var text = $(this).text();
case "File":
var index = text.indexOf(":");
// Modify time in file history table.
if(index > -1)
$("td > a").each(function()
{
var timetext = $(this).text.substr(index - 2, 6);
var index = text.indexOf(":");
// Will convert anything in a table matching the pattern "dd:dd," where d is a digit.
if(time.match(/\d\d:\d\d,/)index > -1)
{
var time = text.substr(index - 2, 6);
$(this).text(partition(text));
// 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;
}
case "User":
else if(mw.config.get("wgCanonicalNamespace") == "User")
// TODO
{
// TODO break;
}
/////////////
// ACTIONS //
/////////////
switch(mw.config.get("wgAction"))
Line 81 ⟶ 85:
case "view":
if(document.title.indexOf("Difference between revisions") > -1)
{
Line 97 ⟶ 102:
}
// Modify time in permalink pages.
if($("div").hasClass("#mw-revision"))
{
$("#mw-revision-date").html(regexpReplace($("#mw-revision-date").html(), 0, 5));
}
// Modify user signatures.
var html = $("#mw-content-text").html();
html = 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 106 ⟶ 136:
break;
}
///////////
// OTHER //
///////////
// Modify time in warning banners.