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: 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.
Shane (talk | contribs)
removed extra breaks
Shane (talk | contribs)
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');
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;
z = document.getElementById("content").childNodes;
  for (var n = 0; n < z.length; n++) {  
for (var n = 0; n < z.length; n++) {  
    if (z[n].className == "firstHeading") return z[n].textContent;
if (z[n].className == "firstHeading") { return z[n].textContent; }
  };
};
}
}


function getNameSpace() {
function getNameSpace() {
  z = document.getElementById("content").childNodes;
z = document.getElementById("content").childNodes;
  for (var n = 0; n < z.length; n++) {  
for (var n = 0; n < z.length; n++) {  
    if (z[n].className == "firstHeading") {  
if (z[n].className == "firstHeading") {  
      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 "BattlestarWiki"; }
  };
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; }
}
}
 
};
// ========== Delete ==========
function doQdd() {
  area = getNameSpace();
  if (area == "Template") {
  document.editform.wpTextbox1.value = pre_noinclude_var + "{{tfd}}" + 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 = "Marked for deletion.";
  document.editform.submit();
}
function addQdd() {
  addTab("javascript:doQdd()", "del", "ca-dd", "Marked for deletion", "");
  akeytt();
}
}


if (document.title.indexOf("Editing ") == 0) {
if (document.title.indexOf("Editing ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addQdd, false);
if (window.addEventListener) window.addEventListener("load", loadTabs, false);
  else if (window.attachEvent) window.attachEvent("onload", addQdd);
else if (window.attachEvent) window.attachEvent("onload", loadTabs);
}
}


// ========== Cleanup==========
function loadTabs() {
function doQcl() {
sNamespace = getNameSpace();
  document.editform.wpTextbox1.value = "{{cleanup}}\n\n" + document.editform.wpTextbox1.value;
if (sNamespace == "Template") {
  document.editform.wpSummary.value = "Marked for cleanup.";
addQdd();
  document.editform.submit();
}
}
function addQcl() {
  addTab("javascript:doQcl()", "clp", "ca-cp", "Marked for Cleanup", "");
  akeytt();
}
}


if (document.title.indexOf("Editing ") == 0) {
// ========== Delete ==========
  if (window.addEventListener) window.addEventListener("load", addQcl, false);
  else if (window.attachEvent) window.attachEvent("onload", addQcl);
}


// ========== Quick Speedy delete ==========
function doQdd() {
function doQsd() {
sNamespace = getNameSpace();
  document.editform.wpTextbox1.value = "{{speedydelete}}\n\n" + document.editform.wpTextbox1.value;
sPagename = "[["+getPname()+"]]";
  document.editform.wpSummary.value = "Marked for speedy deletion.";
if (sNamespace == "Template") {
  document.editform.submit();
document.editform.wpTextbox1.value = pre_noinclude_var + "{{tfd}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
}
} else if (sNamespace == "Quotes") {
function addQsd() {
document.editform.wpTextbox1.value = pre_noinclude_var + "{{qfd}}" + suf_noinclude_var + "\n\n" + document.editform.wpTextbox1.value;
  addTab("javascript:doQsd()", "sd", "ca-sd", "Marked for speedy deletion", "");
} else {
  akeytt();
document.editform.wpTextbox1.value = "{{delete}}\n\n" + document.editform.wpTextbox1.value;
}
document.editform.wpSummary.value = sPagename + " - marked for deletion.";
//document.editform.submit();
}
}


if (document.title.indexOf("Editing ") == 0) {
function addQdd() {
  if (window.addEventListener) window.addEventListener("load", addQsd, false);
addTab("javascript:doQdd()", "del", "ca-dd", "Marked for deletion", "");
  else if (window.attachEvent) window.attachEvent("onload", addQsd);
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();
}
 
if (document.title.indexOf("Editing ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addQnt, false);
  else if (window.attachEvent) window.attachEvent("onload", addQnt);
}
 
// ========== FA Candidate Buttons ==========
 
function doQfa() {
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{featured article candidate}}";
  document.editform.wpSummary.value = "Marked as [[Battlestar Wiki:Featured articles|featured article candidate.]]";
  document.editform.submit();
}
 
function doQfp() {
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{featured picture candidate}}";
  document.editform.wpSummary.value = "Marked 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();
}
 
if (document.title.indexOf("Editing ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addQfa, false);
  else if (window.attachEvent) window.attachEvent("onload", addQfa);
}
}


if (document.title.indexOf("Editing ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addQfp, false);
  else if (window.attachEvent) window.attachEvent("onload", addQfp);
}
// ========== Edit Section 0 ==========
function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth 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&section=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&section=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 + '&section=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 + '&section=0';
    z.appendChild(document.createTextNode('Edit Section 0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
  }
}
if (document.title.indexOf("Editing ") == -1) {
  if (window.addEventListener) window.addEventListener("load", addEditSection0, false);
  else if (window.attachEvent) window.attachEvent("onload", addEditSection0);
}
// ========== 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";
}
if (window.location.href.indexOf("Special") == -1) {
    if (window.addEventListener) window.addEventListener("load", addLastDiff, false);
    else if (window.attachEvent) window.attachEvent("onload", addLastDiff);
}
/* </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> */