The iPhone Wiki is no longer updated. Visit this article on The Apple Wiki for current information. |
Difference between revisions of "MediaWiki:Common.js"
m (fix for "jony" skin) |
m (copyright update) |
||
Line 2: | Line 2: | ||
* The iPhone Wiki MediaWiki:Common.js |
* The iPhone Wiki MediaWiki:Common.js |
||
* - JavaScript to fix common issues on The iPhone Wiki |
* - JavaScript to fix common issues on The iPhone Wiki |
||
− | * Copyright (c) 2013- |
+ | * Copyright (c) 2013-2017 Cole Johnson <coleharrisjohnson@gmail.com> |
* Licensed under CC-BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0/> |
* Licensed under CC-BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0/> |
||
**/ |
**/ |
Revision as of 15:47, 12 September 2017
/**
* The iPhone Wiki MediaWiki:Common.js
* - JavaScript to fix common issues on The iPhone Wiki
* Copyright (c) 2013-2017 Cole Johnson <coleharrisjohnson@gmail.com>
* Licensed under CC-BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0/>
**/
// Removes the "1 This is an Archive Page" element from the TOC on Talk Archives
function fixTalkArchiveToc() {
// Is there a "This is an Archive Page" header block?
if ($(".archive-page-notice").length == 0)
return;
// Is there a TOC?
var toc = $("#toc li");
if (toc.length == 0)
return;
// Remove "This is an Archive Page" entry
toc[0].remove();
// Decrement the outermost section number for each TOC entry
var sec = $(".tocnumber");
for (var i = 0; i < sec.length; i++) {
var arr = sec[i].innerText.split(".");
arr[0]--;
sec[i].innerText = arr.join(".");
}
}
// Removes the "/20##" part of the "Page" link on talk archives
function fixTalkArchiveNSLinks() {
// Are we an archive?
// Would work by checking $(".archive-page-notice").length
var page = $(".firstHeading")[0].innerHTML;
if (page.trim().match(/\/20[0-9]{2}$/) == null)
return;
var ns = $("#p-namespaces .new");
if (ns.length == 0) {
console.log("Can't find namespace selector link.");
return;
}
ns[0].className = ns[0].className.replace("new", "");
ns = ns.find("a")[0];
ns.href = ns.href.replace(
/w[\/\\]index.php\?title=(.*?)(\/20[0-9]{2}).*$/,
"wiki/$1");
}
fixTalkArchiveToc();
fixTalkArchiveNSLinks();