User:Shane/bsgbook.js/tabs.js
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
< User:Shane | bsgbook.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* <pre><nowiki> */
// ========== Hardcoded Vars Needed =============
pre_noinclude_var = "<noinclude>";
suf_noinclude_var = "</noinclude>";
// ========== Content Relating to this Script Only ============
function checkContent() {
if (document.editform.wpTextbox1.value == "") {
return false;
} else {
return true;
}
}
if (document.title.indexOf("Editing ") == 0) {
addLoadEvent(loadTabs);
}
if (window.location.href.indexOf("Special") == -1) {
addLoadEvent(loadNonEdit);
}
function loadTabs() {
sNamespace = getNameSpace();
bContent = checkContent();
if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
if (bContent) {
if (shortwikiloc != "md") {
addQdd(); // Mark as "Delete"
addQcl(); // Mark as "Cleanup"
addQrp(); // Revert Page Option
addQrpp(); // Add {{request protected}}
}
}
}
if (sNamespace == "Image") {
if (shortwikiloc != "md") {
addQfp(); // Mark as Featured Picture
addQrp(); // Revert Page Option
} else {
addQnt(); // Add {{no tag}}
// Add {{no source}}
// Add {{no copyright}}
addQrpp(); // Add {{request protected}}
}
}
if ((sNamespace == "User") || (sNamespace == "Category")) {
if (bContent) {
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
addQrp(); // Revert Page Option
}
}
if (shortwikiloc != "md") {
if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki") || (sNamespace == "Sources")) {
if (bContent) {
addQdd(); // Mark as "Delete"
addQcl(); // Mark as "Cleanup"
addQsd(); // Mark as "Speedy Delete"
if (sNamespace == "Article") {
addQfa(); // Mark as Featured Article
addQqa(); // Mark as Quaility Article
}
addQae(); // Mark as "Expantion"
addQrt(); // Replace Text Option
addQrp(); // Revert Page Option
addQrpp(); // Add {{request protected}}
} else {
addQar(); // Mark as "Requested"
addQrd(); // Create shortcut.
}
}
}
}
function loadNonEdit() {
sNamespace = getNameSpace();
if ((sNamespace == "User") || (sNamespace == "User talk")) {
addQru();
}
addLastDiff(); // Last Diff Button
addQpp(); // Purge Page Button
}
// ========== Add Last Diff ==========
function doLastDiff() {
var nurl = wikiloc + "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";
}
// ========== Report User ===========
function addQru() {
username = location.href.split(':')[2];
if (!username) {
username = document.getElementsByTagName('h1')[0].innerHTML.split(':')[1];
}
if (username.indexOf("&action=edit") != -1){
username = username.split('&')[0];
} else if (username.indexOf("&action=submit") != -1){
username = username.split('&')[0];
}
if (username.indexOf("#") != -1){
username = username.split('#')[0];
}
if (username.indexOf("&") != -1){
username = username.split('&')[0];
}
addTab("javascript:AIVandal('"+ username + "')", "report user", "ca-ru", "Report User to BW:AN", "");
}
// ========== Repalce ==========
function doQrt() {
var obj = document.editform;
sPagename = "[["+getPname()+"]]";
var sReplace_input = prompt('Please enter the text you are looking for and that you will be replacing. (Case Sensitive)', '');
var sReplace_new = prompt('Plase enter the text that is new.', '');
if ( ((sReplace_input != null) || (sReplace_new != null)) && (sReplace_input != sReplace_new) ) {
// Working on this..
obj.wpSummary.value = "Replaced '''" + sReplace_input + "''' with '''" + sReplace_new + "''' on " + sPagename + ".";
//obj.submit();
}
}
function addQrt() {
//addTab("javascript:doQrt()", "replace", "ca-rt", "Do a mass replace.", "");
}
// ========== Request Protected ==========
function doQrpp() {
sPagename = "[["+getPname()+"]]";
if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{rp}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
} else {
document.editform.wpTextbox1.value = "{{rp}}\n\n" + document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = "Marked for request protected status of " + sPagename;
document.editform.submit();
}
function addQrpp() {
addTab("javascript:doQrpp()", "protect req", "ca-rpp", "Request Protection Status.", "");
}
// ========== Revert ==========
function doQrp() {
sPagename = "[["+getPname()+"]]";
document.editform.wpSummary.value = "Reverted to an old version of " + sPagename;
document.editform.submit();
}
function addQrp() {
if (window.location.href.indexOf("&oldid=") != -1) {
addTab("javascript:doQrp()", "revert", "ca-rp", "Revert this page to this version.", "");
}
}
// ========== 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.", "");
}
// ========== 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.", "");
}
// ========== Quick Speedy delete ==========
function doQsd() {
sPagename = "[["+getPname()+"]]";
if ((sNamespace == "Quotes") || (sNamespace == "Template")) {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{speedydelete}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
} else {
document.editform.wpTextbox1.value = "{{speedydelete}}\n\n" + document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = sPagename + " - marked for speedy deletion.";
document.editform.submit();
}
function addQsd() {
addTab("javascript:doQsd()", "sd", "ca-sd", "Mark for speedy deletion.", "");
}
// ========== 'No Tag' ==========
function doQnt() {
document.editform.wpTextbox1.value = "{{subst:no tag syntax}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "[[BW:ITP|Tag]] needs to be updated.";
document.editform.submit();
}
function addQnt() {
addTab("javascript:doQnt()", "nt", "ca-nt", "Tag needs to be updated.", "");
}
// ========== 'No Source' ==========
function doQns() {
document.editform.wpTextbox1.value = "{{subst:no source syntax}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "[[BW:ITP|Tag]] needs to be updated.";
document.editform.submit();
}
function addQns() {
addTab("javascript:doQns()", "ns", "ca-ns", "Tag needs to be updated.", "");
}
// ========== 'No Copyright' ==========
function doQnp() {
document.editform.wpTextbox1.value = "{{subst:no copyright syntax}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "[[BW:ITP|Tag]] needs to be updated.";
document.editform.submit();
}
function addQnp() {
addTab("javascript:doQnp()", "np", "ca-np", "Tag needs to be updated.", "");
}
// ========== FA/FP/QA Candidate Buttons ==========
function doQqa() {
sPagename = "[["+getPname()+"|"+getPname('name')+"]]";
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{quality candidate}}";
document.editform.wpSummary.value = "Marked " + sPagename + " as [[Battlestar Wiki:Quality Articles|quality article candidate.]]";
document.editform.submit();
}
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 addQqa() {
addTab("javascript:doQqa()", "qa", "ca-qa", "Mark as Quality Article Candidate.", "");
}
function addQfa() {
addTab("javascript:doQfa()", "fa", "ca-fa", "Mark as Featured Article Candidate.", "");
}
function addQfp() {
addTab("javascript:doQfp()", "fp", "ca-fp", "Mark as Featured Picture Candidate.", "");
}
// ========== 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 doQrd() {
var sRedirect = prompt('Plase enter the page you want the redirect to go to.', '');
sPagename = getPname();
document.editform.wpTextbox1.value = "#REDIRECT [[" + sRedirect + "]]";
document.editform.wpSummary.value = "Marked [[" + sPagename + "]] as [[BW:SHORT|a shortcut.]]";
}
function addQar() {
addTab("javascript:doQar()", "req", "ca-ar", "Mark as Requested.", "");
}
function addQrd() {
addTab("javascript:doQrd()", "shortcut", "ca-rd", "Create shortcut.", "");
}
// ========== Expansion ==========
function doQae() {
sPagename = getPname();
document.editform.wpTextbox1.value = "{{expansion}}\n\n" + document.editform.wpTextbox1.value;
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.", "");
}
// ========== Purge Button ==========
function doQpp() {
var nurl = wikiloc + "index.php?title=" + getPname() + "&action=purge";
document.location = nurl;
}
function addQpp() {
addTab("javascript:doQpp()", "purge", "ca-pp", "Purge this page.", "");
}
/* </nowiki></pre> */