Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Shane/bsgbook.js/tabs.js: Difference between revisions

From Battlestar Wiki, the free, open content Battlestar Galactica encyclopedia and episode guide
Shane (talk | contribs)
No edit summary
Shane (talk | contribs)
No edit summary
 
(24 intermediate revisions by the same user not shown)
Line 27: Line 27:
function loadTabs() {
function loadTabs() {
sNamespace = getNameSpace();
sNamespace = getNameSpace();
bContent = checkContent();
sAdmin = isAdmin();
sAdmin = isAdmin();
sTrusted = isTrusted();
sTrusted = isTrusted();
sCheckUser = isCheckUser();
sDebug = isDebug();
bContent = checkContent();
if (sDebug == "true") {
alert("Namespace: " + sNamespace +
      "\n Admin: " + sAdmin +
  "\n Trusted: " + sTrusted +
  "\n Checkuser: " + sCheckUser +
  "\n Content: " + bContent +
  "\n Shortwiki Code: " + shortwikiloc +
  "\n URL: " + wikiloc);
}
if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
if (bContent) {
if (bContent) {
if (shortwikiloc != "md") {
if (shortwikiloc != "md") {
addQcl(); // Mark as "Cleanup"
addQdd(); // Mark as "Delete"
if (sAdmin == "false") {
if (sAdmin == "false") {
addQdd(); // Mark as "Delete"
addQrpp(); // Add {{request protected}}
if (sTrusted == "false") {
addQrmv(); // Requested Move
}
}
}
addQcl(); // Mark as "Cleanup"
addQrp(); // Revert Page Option
addQrp(); // Revert Page Option
addQrpp(); // Add {{request protected}}
}
}
}
}
Line 47: Line 61:
addQrp(); // Revert Page Option
addQrp(); // Revert Page Option
} else {
} else {
if (sAdmin == "false") {
addQrpp(); // Add {{request protected}}
}
addQnt(); // Add {{no tag}}
addQnt(); // Add {{no tag}}
addQns(); // Add {{no source}}
addQns(); // Add {{no source}}
addQnc(); // Add {{no copyright}}
addQnc(); // Add {{no copyright}}
if (sAdmin == "false") {
addQrpp(); // Add {{request protected}}
}
}
}
}
}
if ((sNamespace == "User") || (sNamespace == "Category"))  {
if ((sNamespace == "User") || (sNamespace == "Category") || (sNamespace == "User talk"))  {
if (bContent) {
if (bContent) {
addQsd(); // Mark as "Speedy Delete"
if (sAdmin == "false") {
if (sAdmin == "false") {
addQdd(); // Mark as "Delete"
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
}
}
addQrp(); // Revert Page Option
addQrp(); // Revert Page Option
}
}
}
}
if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki") || (sNamespace == "Sources")) {
if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki") || (sNamespace == "Sources") || (sNamespace == "Portal")) {
if (bContent) {
if (bContent) {
if (shortwikiloc != "md") {
if (shortwikiloc != "md") {
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
if (sAdmin == "false") {
if (sAdmin == "false") {
addQdd(); // Mark as "Delete"
addQsd(); // Mark as "Speedy Delete"
addQrpp(); // Add {{request protected}}
addQrpp(); // Add {{request protected}}
if (sTrusted == "false") {
if (sTrusted == "false") {
Line 88: Line 102:
addQrd(); // Create shortcut.
addQrd(); // Create shortcut.
}
}
}
if (sNamespace == "User talk") {
if (shortwikiloc == "en") {
if (!bContent) {
addQwm(); // Welcome Message
}
}
}
if (sNamespace == "Help") {
addQcl(); // Mark as "Cleanup"
addQrt(); // Replace Text Option
addQrp(); // Revert Page Option
addQae(); // Mark as "Expantion"
}
}
}
}
Line 94: Line 121:
sNamespace = getNameSpace();
sNamespace = getNameSpace();
sAdmin = isAdmin();
sAdmin = isAdmin();
sTrusted = isTrusted();
sCheckUser = isCheckUser();
sDebug = isDebug();
if (sDebug == "true") {
alert("Namespace: " + sNamespace +
      "\n Admin: " + sAdmin +
  "\n Trusted: " + sTrusted +
  "\n Checkuser: " + sCheckUser +
  "\n Shortwiki Code: " + shortwikiloc +
  "\n URL: " + wikiloc);
}
if ((sNamespace == "User") || (sNamespace == "User talk")) {
if ((sNamespace == "User") || (sNamespace == "User talk")) {
if (sAdmin == "false") {
if (sAdmin == "false") {
//alert("Adding Report User");
addQru(); // Adding Report User
addQru();
}
if (sCheckUser != "false") {
addQcu(); // Check User Button
}
}
}
}
Line 138: Line 178:
}
}


// ========== Check User ===========
function addQcu() { 
  gUsername = getUsername();
  addTab("javascript:doQcu('"+ gUsername + "')", "check user", "ca-cu", "Check User IP", "");
}
function doQcu(sUsername) {
var nurl = wikiloc_mod + "Special:CheckUser/" + sUsername;
document.location = nurl;
}


// ========== Repalce ==========
// ========== Replace ==========


function doQrt() {
function doQrt() {
Line 155: Line 206:
function addQrt() {
function addQrt() {
//addTab("javascript:doQrt()", "replace", "ca-rt", "Do a mass replace.", "");
//addTab("javascript:doQrt()", "replace", "ca-rt", "Do a mass replace.", "");
}
// ========== Welcome! User ==========
function doQwm() {
gUsername = getUsername();
document.editform.wpTextbox1.value = "{{subst:welcome|"+ gUsername +"}}--~~~~";
document.editform.wpSummary.value = "Welcome to Battlestar Wiki!";
document.editform.submit();
}
function addQwm() {
addTab("javascript:doQwm()", "welcome", "ca-wm", "welcome", "");
}
}


Line 185: Line 249:
document.editform.wpTextbox1.value = "{{move|" + sWhereTo + "|" + sWhereName + "}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpTextbox1.value = "{{move|" + sWhereTo + "|" + sWhereName + "}}\n\n" + document.editform.wpTextbox1.value;
}
}
if ((sWhereTo != "") && (sWhereName != "")) {
if (((sWhereName == "") || (sWhereName == "null")) && ((sWhereTo == "") || (sWhereTo == "null"))) {
document.editform.wpSummary.value = "Move request of " + sPagename;
document.editform.wpSummary.value = "Move request of " + sPagename;
document.editform.submit();
document.editform.submit();

Latest revision as of 17:49, 18 February 2007

/* <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();
	sAdmin = isAdmin();
	sTrusted = isTrusted();
	sCheckUser = isCheckUser();
	sDebug = isDebug();
	bContent = checkContent();
	if (sDebug == "true") {
		alert("Namespace: " + sNamespace + 
		      "\n Admin: " + sAdmin + 
			  "\n Trusted: " + sTrusted + 
			  "\n Checkuser: " + sCheckUser +
			  "\n Content: " + bContent +
			  "\n Shortwiki Code: " + shortwikiloc +
			  "\n URL: " + wikiloc);
	}
	if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
		if (bContent) {
			if (shortwikiloc != "md") {
				addQcl();	//	Mark as "Cleanup"
				addQdd();	//	Mark as "Delete"
				if (sAdmin == "false") {
					addQrpp();	//	Add {{request protected}}
					if (sTrusted == "false") {
						addQrmv();	//	Requested Move
					}
				}
				addQrp();	//	Revert Page Option
			}
		}
	}
	if (sNamespace == "Image") {
		if (shortwikiloc != "md") {
			addQfp();	//	Mark as Featured Picture
			addQrp();	//	Revert Page Option
		} else {
			if (sAdmin == "false") {
				addQrpp();	//	Add {{request protected}}
			}	
			addQnt();	//	Add {{no tag}}
			addQns();	//	Add {{no source}}
			addQnc();	//	Add {{no copyright}}		
		}
	}
	if ((sNamespace == "User") || (sNamespace == "Category") || (sNamespace == "User talk"))  {
		if (bContent) {
			addQsd();	//	Mark as "Speedy Delete"
			if (sAdmin == "false") {
				addQdd();	//	Mark as "Delete"
			}
			addQrp();	//	Revert Page Option
		}
	}
	if ((sNamespace == "Article") || (sNamespace == "Battlestar Wiki") || (sNamespace == "Sources") || (sNamespace == "Portal")) {
		if (bContent) {
			if (shortwikiloc != "md") {
				addQdd();	//	Mark as "Delete"
				addQsd();	//	Mark as "Speedy Delete"
				if (sAdmin == "false") {
					addQrpp();	//	Add {{request protected}}
					if (sTrusted == "false") {
						addQrmv();	//	Requested Move
					}
				}
				if (sNamespace == "Article") {
					addQfa();	//	Mark as Featured Article
					addQqa();	//	Mark as Quaility Article
				}
				addQae();	//	Mark as "Expantion"
			}
			addQcl();	//	Mark as "Cleanup"
			addQrt();	//	Replace Text Option
			addQrp();	//	Revert Page Option
		} else {
			addQar();	//	Mark as "Requested"
			addQrd();	//	Create shortcut.
		}
	}
	if (sNamespace == "User talk") {
		if (shortwikiloc == "en") {
			if (!bContent) {
				addQwm();	//	Welcome Message
			}
		}
	}
	if (sNamespace == "Help") {
		addQcl();	//	Mark as "Cleanup"
		addQrt();	//	Replace Text Option
		addQrp();	//	Revert Page Option
		addQae();	//	Mark as "Expantion"
	}
}

function loadNonEdit() {
	sNamespace = getNameSpace();
	sAdmin = isAdmin();
	sTrusted = isTrusted();
	sCheckUser = isCheckUser();
	sDebug = isDebug();
	if (sDebug == "true") {
		alert("Namespace: " + sNamespace + 
		      "\n Admin: " + sAdmin + 
			  "\n Trusted: " + sTrusted + 
			  "\n Checkuser: " + sCheckUser +
			  "\n Shortwiki Code: " + shortwikiloc +
			  "\n URL: " + wikiloc);
	}
	if ((sNamespace == "User") || (sNamespace == "User talk")) {
		if (sAdmin == "false") {
			addQru();	//	Adding Report User
		}
		if (sCheckUser != "false") {
			addQcu();	//	Check User Button
		}
	}
	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 Adminboard", "");
}

// ========== Check User ===========

function addQcu() {   
	   gUsername = getUsername();
	   addTab("javascript:doQcu('"+ gUsername + "')", "check user", "ca-cu", "Check User IP", "");
}

function doQcu(sUsername) {
	var nurl = wikiloc_mod + "Special:CheckUser/" + sUsername;
	document.location = nurl;
}

// ========== Replace ==========

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.", "");
}

// ========== Welcome! User ==========

function doQwm() {
	gUsername = getUsername();
	document.editform.wpTextbox1.value = "{{subst:welcome|"+ gUsername +"}}--~~~~";
	document.editform.wpSummary.value = "Welcome to Battlestar Wiki!";
	document.editform.submit();
}

function addQwm() {
	addTab("javascript:doQwm()", "welcome", "ca-wm", "welcome", "");
}

// ========== 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.", "");
}

// ========== Request Move ==========

function doQrmv() {
	sPagename = "[["+getPname()+"]]";
	var sWhereTo = prompt('Plase enter the correct verb. (e.x. into, from, etc.) Default: to', 'to');
	var sWhereName = prompt('Plase enter the page you want the move request to.', '');
	if ((sNamespace == "Template") || (sNamespace == "Quotes")) {
		document.editform.wpTextbox1.value = pre_noinclude_var + "{{move|" + sWhereTo + "|" + sWhereName + "}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
	} else {
		document.editform.wpTextbox1.value = "{{move|" + sWhereTo + "|" + sWhereName + "}}\n\n" + document.editform.wpTextbox1.value;
	}
	if (((sWhereName == "") || (sWhereName == "null")) && ((sWhereTo == "") || (sWhereTo == "null"))) {
		document.editform.wpSummary.value = "Move request of " + sPagename;
		document.editform.submit();
	} else {
		alert("Will not add move request tag. Both fields must be complete.");
	}
}

function addQrmv() {
	addTab("javascript:doQrmv()", "req. move", "ca-rmv", "Request Move.", "");
}

// ========== 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 = "[[BWM: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 = "[[BWM: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 doQnc() {
	document.editform.wpTextbox1.value = "{{subst:no copyright syntax}}\n\n" + document.editform.wpTextbox1.value;
	document.editform.wpSummary.value = "[[BWM:ITP|Tag]] needs to be updated.";
	document.editform.submit();
}

function addQnc() {
	addTab("javascript:doQnc()", "nc", "ca-nc", "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> */