User:Back on the list/custom.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
function preloadTextInSection() {
if (window.preloadedText) {
return;
} else {
window.preloadedText = true;
}
var pretext = "";
var lang = "";
if (! (window.location.search && window.location.search.split("?")[1])) {
return;
}
try {
parts = window.location.search.split("?")[1].split("&");
} catch (e) {
return;
}
for (var k = 0; k < parts.length; k++) {
pair = parts[k].split("=");
if (pair[0] == "plt") {
pretext = decodeURIComponent(pair[1].replace(/\+/gi," "));
} else if (pair[0]=="lang") {
lang = decodeURIComponent(pair[1].replace(/\+/gi," "));
}
}
if (pretext.length > 0) {
var lines = document.editform.wpTextbox1.value.split("\n");
var langsec;
var done = false;
var ft = "";
for (var c1 = 0; c1 < lines.length; c1++) {
if (!done) {
if (/^\[\[[a-z\-]{2,7}:[^\[]*\]\]$/.exec(lines[c1])) {
ft += "----\n\n" + pretext + "\n\n";
done = true;
} else if (lines[c1][0] == '=' && lines[c1][1] == '=' && lines[c1][2] != '=') {
langsec = lines[c1].substring(2, lines[c1].length-2);
if (langsec != "English" && langsec != "Translingual" && lang < langsec) {
ft += pretext + "\n\n----\n\n";
done = true;
}
}
}
ft += lines[c1]
if (c1 < lines.length-1) ft += '\n';
}
if (!done) {
if (lines.length > 1) ft += "\n----\n\n";
ft += pretext;
}
document.editform.wpTextbox1.value = ft;
}
}
$(preloadTextInSection);