User:Shane/bsgbook.js: Difference between revisions
From the only original and legitimate Battlestar Wiki: the free-as-in-beer, non-corporate, open-content encyclopedia, analytical reference, and episode guide on all things Battlestar Galactica. Accept neither subpar substitutes nor subpar clones.
More actions
without admin boolen |
No edit summary |
||
| Line 12: | Line 12: | ||
To disable one, add: | To disable one, add: | ||
setOption('NAME'); | |||
below import_external('User:Shane/myskin.js'); | below import_external('User:Shane/myskin.js'); | ||
Bellow are the "codes" used in this script: | |||
setOption('delete'); | |||
Disables: {{delete}}, {{tfd}}, {{qfd}}, {{speedydelete}} | |||
*/ | */ | ||
var opt['delete'] = false; | |||
// ========== Basic Functions Needed ========== | // ========== Basic Functions Needed ========== | ||
| Line 38: | Line 46: | ||
else if (key) { na.title = '[' + pref + key + ']'; } | else if (key) { na.title = '[' + pref + key + ']'; } | ||
return li; | return li; | ||
} | |||
function addToolboxLink(url, name, id){ | |||
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; | |||
addlilink(tb, url, name, id); | |||
} | } | ||
| Line 64: | Line 77: | ||
if (z[n].textContent.indexOf("Template") != -1) { return "Template"; } | if (z[n].textContent.indexOf("Template") != -1) { return "Template"; } | ||
if (z[n].textContent.indexOf("Battlestar Wiki") != -1) { return "Battlestar Wiki"; } | if (z[n].textContent.indexOf("Battlestar Wiki") != -1) { return "Battlestar Wiki"; } | ||
if (z[n].textContent.indexOf("Podcast") != -1) { return "Podcast"; } | |||
if (z[n].textContent.indexOf("Sources") != -1) { return "Sources"; } | |||
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; } | if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; } | ||
if (z[n].textContent.indexOf("Image") != -1) { return "Image"; } | if (z[n].textContent.indexOf("Image") != -1) { return "Image"; } | ||
| Line 72: | Line 87: | ||
} | } | ||
function | function getContent() { | ||
if (document.editform.wpTextbox1.value == "") { | if (document.editform.wpTextbox1.value == "") { | ||
return false; | return false; | ||
| Line 78: | Line 93: | ||
return true; | return true; | ||
} | } | ||
} | |||
function setOption(data) { | |||
opt[data] = true; | |||
} | } | ||
| Line 93: | Line 112: | ||
function loadTabs() { | function loadTabs() { | ||
// get options | |||
sNamespace = getNameSpace(); | sNamespace = getNameSpace(); | ||
bContent = | bContent = getContent(); | ||
if (sNamespace == "Template") { | if (sNamespace == "Template") { | ||
if (bContent) { | if (bContent) { | ||
addQdd(); // Mark as "Delete" | if (!opt['delete']) { | ||
addQdd(); // Mark as "Delete" | |||
} | |||
addQcl(); // Mark as "Cleanup" | addQcl(); // Mark as "Cleanup" | ||
} | } | ||
| Line 103: | Line 126: | ||
if (sNamespace == "Quotes") { | if (sNamespace == "Quotes") { | ||
if (bContent) { | if (bContent) { | ||
addQdd(); // Mark as "Delete" | if (!opt['delete']) { | ||
addQdd(); // Mark as "Delete" | |||
} | |||
addQcl(); // Mark as "Cleanup" | addQcl(); // Mark as "Cleanup" | ||
} | } | ||
| Line 113: | Line 138: | ||
if (sNamespace == "User") { | if (sNamespace == "User") { | ||
if (bContent) { | if (bContent) { | ||
addQdd(); // Mark as "Delete" | if (!opt['delete']) { | ||
addQdd(); // Mark as "Delete" | |||
addQsd(); // Mark as "Speedy Delete" | |||
} | |||
} | } | ||
} | } | ||
if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki")) { | if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki")) { | ||
if (bContent) { | if (bContent) { | ||
addQdd(); // Mark as "Delete" | if (!opt['delete']) { | ||
addQdd(); // Mark as "Delete" | |||
addQsd(); // Mark as "Speedy Delete" | |||
} | |||
addQcl(); // Mark as "Cleanup" | addQcl(); // Mark as "Cleanup" | ||
if (sNamespace == "Article") { | if (sNamespace == "Article") { | ||
addQfa(); // Mark as Featured Article | addQfa(); // Mark as Featured Article | ||
Revision as of 14:40, 7 June 2006
/* <pre><nowiki> */
// ========== Hardcoded Vars Needed =============
pre_noinclude_var = "<noinclude>";
suf_noinclude_var = "</noinclude>";
// ========== Options ==========
/*
By default, all the options are enabled.
To disable one, add:
setOption('NAME');
below import_external('User:Shane/myskin.js');
Bellow are the "codes" used in this script:
setOption('delete');
Disables: {{delete}}, {{tfd}}, {{qfd}}, {{speedydelete}}
*/
var opt['delete'] = false;
// ========== Basic Functions Needed ==========
function addlilink(tabs, url, name, id, title, key) {
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if (id) {
li.id = id;
}
li.appendChild(na);
tabs.appendChild(li);
na.accesskey = key;
var pref = 'alt-';
if ((((clientPC.indexOf('AppleWebKit') != -1) && (clientPC.indexOf('spoofer') == -1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 )) { pref = 'control-'; }
if (clientPC.indexOf('opera') != -1) { pref = 'shift-esc-'; }
if (key && title) { na.title = title + ' [' + pref + key + ']'; }
else if (title) { na.title = title; }
else if (key) { na.title = '[' + pref + key + ']'; }
return li;
}
function addToolboxLink(url, name, id){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, url, name, id);
}
function addTab(url, name, id, title, key) {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function getPname(alt) {
z = document.getElementById("content").childNodes;
for (var n = 0; n < z.length; n++) {
if (z[n].className == "firstHeading") {
stmpPage = z[n].textContent.replace(/Editing /,"");
if (alt == "name") {
stmpPage = stmpPage.replace(getNameSpace()+":","");
}
return stmpPage;
}
};
}
function getNameSpace() {
z = document.getElementById("content").childNodes;
for (var n = 0; n < z.length; n++) {
if (z[n].className == "firstHeading") {
if (z[n].textContent.indexOf("Template") != -1) { return "Template"; }
if (z[n].textContent.indexOf("Battlestar Wiki") != -1) { return "Battlestar Wiki"; }
if (z[n].textContent.indexOf("Podcast") != -1) { return "Podcast"; }
if (z[n].textContent.indexOf("Sources") != -1) { return "Sources"; }
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; }
if (z[n].textContent.indexOf("Image") != -1) { return "Image"; }
if (z[n].textContent.indexOf("User") != -1) { return "User"; }
return "Article";
}
};
}
function getContent() {
if (document.editform.wpTextbox1.value == "") {
return false;
} else {
return true;
}
}
function setOption(data) {
opt[data] = true;
}
if (document.title.indexOf("Editing ") == 0) {
if (window.addEventListener) window.addEventListener("load", loadTabs, false);
else if (window.attachEvent) window.attachEvent("onload", loadTabs);
} else {
addEditSection0();
}
if (window.location.href.indexOf("Special") == -1) {
if (window.addEventListener) window.addEventListener("load", loadNonEdit, false);
else if (window.attachEvent) window.attachEvent("onload", loadNonEdit);
}
function loadTabs() {
// get options
sNamespace = getNameSpace();
bContent = getContent();
if (sNamespace == "Template") {
if (bContent) {
if (!opt['delete']) {
addQdd(); // Mark as "Delete"
}
addQcl(); // Mark as "Cleanup"
}
}
if (sNamespace == "Quotes") {
if (bContent) {
if (!opt['delete']) {
addQdd(); // Mark as "Delete"
}
addQcl(); // Mark as "Cleanup"
}
}
if (sNamespace == "Image") {
addQnt(); // Add {{no tag}} }
addQfp(); // Mark as Featured Picture
}
if (sNamespace == "User") {
if (bContent) {
if (!opt['delete']) {
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
}
}
}
if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki")) {
if (bContent) {
if (!opt['delete']) {
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
}
addQcl(); // Mark as "Cleanup"
if (sNamespace == "Article") {
addQfa(); // Mark as Featured Article
}
addQae(); // Mark as "Expantion"
} else {
addQar(); // Mark as "Requested"
}
}
}
function loadNonEdit() {
addLastDiff(); // Last Diff Button
addQpp(); // Purge Page Button
}
// ========== Add Last Diff ==========
function doLastDiff() {
var nurl = "http://www.battlestarwiki.org/en/index.php?title=" + getPname() + "&diff=cur&oldid=prev";
document.location = nurl;
}
function addLastDiff() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var l = addlilink(tabs, "javascript:doLastDiff()", 'last', '');
l.lastChild.title = "Show most recent diff";
}
// ========== Delete ==========
function doQdd() {
sNamespace = getNameSpace();
sPagename = "[["+getPname()+"]]";
if (sNamespace == "Template") {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{tfd}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
} else if (sNamespace == "Quotes") {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{qfd}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
} else {
document.editform.wpTextbox1.value = "{{delete}}\n\n" + document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = sPagename + " - marked for deletion.";
document.editform.submit();
}
function addQdd() {
addTab("javascript:doQdd()", "del", "ca-dd", "Mark for deletion.", "");
akeytt();
}
// ========== Cleanup==========
function doQcl() {
sNamespace = getNameSpace();
sPagename = "[["+getPname()+"]]";
if ((sNamespace == "Quotes") || (sNamespace == "Template")) {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{cleanup}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
} else {
document.editform.wpTextbox1.value = "{{cleanup}}\n\n" + document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = sPagename + " - marked for cleanup.";
document.editform.submit();
}
function addQcl() {
addTab("javascript:doQcl()", "clp", "ca-cp", "Mark for Cleanup.", "");
akeytt();
}
// ========== Quick Speedy delete ==========
function doQsd() {
document.editform.wpTextbox1.value = "{{speedydelete}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Marked for speedy deletion.";
document.editform.submit();
}
function addQsd() {
addTab("javascript:doQsd()", "sd", "ca-sd", "Mark for speedy deletion.", "");
akeytt();
}
// ========== 'No Tag' ==========
function doQnt() {
document.editform.wpTextbox1.value = "{{no tag|{{subst:CURRENTDAYNAME}}, {{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}, {{subst:CURRENTYEAR}} at {{subst:CURRENTTIME}}}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Tag needs to be updated.";
document.editform.submit();
}
function addQnt() {
addTab("javascript:doQnt()", "nt", "ca-nt", "Tag needs to be updated.", "");
akeytt();
}
// ========== FA Candidate Buttons ==========
function doQfa() {
sPagename = "[["+getPname()+"|"+getPname('name')+"]]";
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{featured article candidate}}";
document.editform.wpSummary.value = "Marked " + sPagename + " as [[Battlestar Wiki:Featured articles|featured article candidate.]]";
document.editform.submit();
}
function doQfp() {
sPagename = "[["+getPname()+"|"+getPname('name')+"]]";
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{featured picture candidate}}";
document.editform.wpSummary.value = "Marked " + sPagename + " as [[Battlestar Wiki:Featured pictures|featured picture candidate.]]";
document.editform.submit();
}
function addQfa() {
addTab("javascript:doQfa()", "fa", "ca-fa", "Mark as Featured Article Candidate.", "");
akeytt();
}
function addQfp() {
addTab("javascript:doQfp()", "fp", "ca-fp", "Mark as Featured Picture Candidate.", "");
akeytt();
}
// ========== Requested ==========
function doQar() {
sPagename = getPname();
document.editform.wpTextbox1.value = "{{requested}}";
document.editform.wpSummary.value = "Marked [[" + sPagename + "]] as [[Battlestar Wiki:Requested pages|a requested pages.]]";
document.editform.submit();
}
function addQar() {
addTab("javascript:doQar()", "req", "ca-ar", "Mark as Requested.", "");
akeytt();
}
// ========== Requested ==========
function doQae() {
sPagename = getPname();
document.editform.wpTextbox1.value = "{{expansion}}";
document.editform.wpSummary.value = "Marked [[" + sPagename + "]] as [[Battlestar Wiki:Requests for expansion|a expansion request.]]";
document.editform.submit();
}
function addQae() {
addTab("javascript:doQae()", "exp", "ca-ae", "Mark as Expansion.", "");
akeytt();
}
// ========== Edit Section 0 ==========
function addEditSection0() {
ta['ca-edit-0'] = ['', 'Edit the 0th section of this page.'];
if (!document.getElementById) { return; }
x = document.getElementById('ca-edit');
if (!x) { return; }
y = document.createElement('LI');
y.id = 'ca-edit-0';
if (x.className == 'selected') {
if (/&action=edit§ion=0$/.test(window.location.href)) {
x.className = 'istalk';
y.className = 'selected';
} else {
x.className = 'selected istalk';
}
} else if (x.className == 'selected istalk') {
if (/&action=edit§ion=0$/.test(window.location.href)) {
x.className = 'istalk';
y.className = 'selected istalk';
} else {
y.className = 'istalk';
}
} else {
y.className = x.className;
x.className = 'istalk';
}
z = document.createElement('A');
if (x.children) {
z.href = x.children[0].href + '§ion=0';
z.appendChild(document.createTextNode('Edit Section 0'));
y.appendChild(z);
document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
} else {
z.href = x.childNodes[0].href + '§ion=0';
z.appendChild(document.createTextNode('Edit Section 0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
// ========== Purge Button ==========
function doQpp() {
var nurl = "http://www.battlestarwiki.org/en/index.php?title=" + getPname() + "&action=purge";
document.location = nurl;
}
function addQpp() {
addTab("javascript:doQpp()", "purge", "ca-pp", "Purge this page.", "");
akeytt();
}
/* </nowiki></pre> */