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
removed extra breaks |
No edit summary |
||
| Line 9: | Line 9: | ||
function addlilink(tabs, url, name, id, title, key){ | function addlilink(tabs, url, name, id, title, key){ | ||
var na = document.createElement('a'); | |||
na.href = url; | na.href = url; | ||
na.appendChild(document.createTextNode(name)); | na.appendChild(document.createTextNode(name)); | ||
| Line 32: | Line 32: | ||
function getPname() { | function getPname() { | ||
z = document.getElementById("content").childNodes; | |||
for (var n = 0; n < z.length; n++) { | |||
if (z[n].className == "firstHeading") { return z[n].textContent; } | |||
}; | |||
} | } | ||
function getNameSpace() { | 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 "BattlestarWiki"; } | |||
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; } | |||
} | |||
}; | |||
} | |||
} | } | ||
if (document.title.indexOf("Editing ") == 0) { | if (document.title.indexOf("Editing ") == 0) { | ||
if (window.addEventListener) window.addEventListener("load", loadTabs, false); | |||
else if (window.attachEvent) window.attachEvent("onload", loadTabs); | |||
} | } | ||
function loadTabs() { | |||
function | sNamespace = getNameSpace(); | ||
if (sNamespace == "Template") { | |||
addQdd(); | |||
} | |||
} | } | ||
// ========== 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", "Marked for deletion", ""); | |||
akeytt(); | |||
function | |||
} | } | ||
/* </nowiki></pre> */ | /* </nowiki></pre> */ | ||
Revision as of 14:27, 6 June 2006
/* <pre><nowiki> */
// Hardcoded Vars Needed =============
pre_noinclude_var = "<noinclude>";
suf_noinclude_var = "</noinclude>";
// ========== 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 addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function getPname() {
z = document.getElementById("content").childNodes;
for (var n = 0; n < z.length; n++) {
if (z[n].className == "firstHeading") { return z[n].textContent; }
};
}
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 "BattlestarWiki"; }
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; }
}
};
}
if (document.title.indexOf("Editing ") == 0) {
if (window.addEventListener) window.addEventListener("load", loadTabs, false);
else if (window.attachEvent) window.attachEvent("onload", loadTabs);
}
function loadTabs() {
sNamespace = getNameSpace();
if (sNamespace == "Template") {
addQdd();
}
}
// ========== 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", "Marked for deletion", "");
akeytt();
}
/* </nowiki></pre> */