User:Shane/bsgbook.js/default.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
< User:Shane | bsgbook.js
No edit summary |
updated |
||
| (28 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* <pre><nowiki> */ | /* <pre><nowiki> */ | ||
// ========== User Set Options ============ | |||
var admin=admin||'false'; // By Default, a user is not an admin | |||
var trusted=trusted||'false'; // By Default, a user is not in the trusted group | |||
var checkuser=checkuser||'false'; // By Default, a user is not in the checkuser group | |||
var debug=debug||'false'; // By Default, a user is not debuging this script | |||
// ========== XHMTL Functions Needed ========== | // ========== XHMTL Functions Needed ========== | ||
| Line 89: | Line 96: | ||
function isAdmin() { | function isAdmin() { | ||
return admin; | return admin; | ||
} | |||
function isTrusted() { | |||
return trusted; | |||
} | |||
function isCheckUser() { | |||
return checkuser; | |||
} | |||
function isDebug() { | |||
return debug; | |||
} | } | ||
| Line 99: | Line 114: | ||
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].textContent.indexOf("Battlestar Wiki") != -1) { return "Battlestar Wiki"; } | if (z[n].textContent.indexOf("Battlestar Wiki") != -1) { return "Battlestar Wiki"; } | ||
if (z[n].textContent.indexOf("Battlestar Wiki Media") != -1) { return "Battlestar Wiki"; } | |||
if (z[n].textContent.indexOf("Podcast") != -1) { return "Podcast"; } | if (z[n].textContent.indexOf("Podcast") != -1) { return "Podcast"; } | ||
if (z[n].textContent.indexOf("Portal") != -1) { return "Portal"; } | if (z[n].textContent.indexOf("Portal") != -1) { return "Portal"; } | ||
if (z[n].textContent.indexOf("Sources") != -1) { return "Sources"; } | 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(" | if ((shortwikiloc == "en") || (shortwikiloc == "md") || (shortwikiloc == "hb") || (shortwikiloc == "zh")) { | ||
if (shortwikiloc == "md") { | |||
if (z[n].textContent.indexOf("Potw") != -1) { return "Potw"; } | |||
} | |||
if (z[n].textContent.indexOf("Template") != -1) { return "Template"; } | |||
if (z[n].textContent.indexOf("Help") != -1) { return "Help"; } | |||
if (z[n].textContent.indexOf("Image") != -1) { return "Image"; } | |||
if (z[n].textContent.indexOf("Category") != -1) { return "Category"; } | |||
if (z[n].textContent.indexOf("User") != -1) { | |||
if (z[n].textContent.indexOf("talk") != -1) { | |||
return "User talk"; | |||
} else { | |||
return "User"; | |||
} | |||
} | |||
} | |||
return "Article"; | return "Article"; | ||
} | } | ||
}; | } | ||
} | |||
function getUsername() { | |||
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]; | |||
} | |||
if (username.indexOf("/") != -1){ | |||
username = username.split('/')[0]; | |||
} | |||
return username; | |||
} | } | ||
if (window.location.href.indexOf("http://en.") == 0) { | if (window.location.href.indexOf("http://en.") == 0) { | ||
var wikiloc = "http://en.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://en.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "en"; | |||
} else if (window.location.href.indexOf("http://de.") == 0) { | |||
var wikiloc = "http://de.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://de.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "de"; | |||
} else if (window.location.href.indexOf("http://es.") == 0) { | |||
var wikiloc = "http://es.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://es.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "es"; | |||
} else if (window.location.href.indexOf("http://zh.") == 0) { | |||
var wikiloc = "http://zh.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://zh.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "zh"; | |||
} else if (window.location.href.indexOf("http://fr.") == 0) { | |||
var wikiloc = "http://fr.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://fr.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "fr"; | |||
} else if (window.location.href.indexOf("http://tr.") == 0) { | |||
var wikiloc = "http://tr.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://tr.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "tr"; | |||
} else if (window.location.href.indexOf("http://hb.") == 0) { | |||
var wikiloc = "http://hb.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://hb.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "hb"; | |||
} else if (window.location.href.indexOf("http://media.") == 0) { | } else if (window.location.href.indexOf("http://media.") == 0) { | ||
var wikiloc = "http://media.battlestarwiki.org/w/"; | |||
var wikiloc_mod = "http://media.battlestarwiki.org/wiki/"; | |||
var shortwikiloc = "md"; | |||
} | |||
} | |||
function addLoadEvent(func) | function addLoadEvent(func) | ||
Latest revision as of 17:36, 18 February 2007
/* <pre><nowiki> */
// ========== User Set Options ============
var admin=admin||'false'; // By Default, a user is not an admin
var trusted=trusted||'false'; // By Default, a user is not in the trusted group
var checkuser=checkuser||'false'; // By Default, a user is not in the checkuser group
var debug=debug||'false'; // By Default, a user is not debuging this script
// ========== XHMTL Functions Needed ==========
if (document.implementation.createDocument) {
var gml_xmlparser = new DOMParser();
}
function gml_XMLParse(string) {
if (document.implementation.createDocument) {
return gml_xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
gml_xmldoc.async = "false";
ret = gml_xmldoc.loadXML(string);
if (!ret)
return null;
return gml_xmldoc.documentElement;
}
return null;
}
var gml_xmlhttp;
function HTTPClient() {
var gml_http;
if(window.XMLHttpRequest) {
gml_http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
gml_http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
gml_http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
gml_http = false;
}
}
}
return gml_http;
}
// ========== 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 + ']'; }
akeytt();
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 isAdmin() {
return admin;
}
function isTrusted() {
return trusted;
}
function isCheckUser() {
return checkuser;
}
function isDebug() {
return debug;
}
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("Battlestar Wiki") != -1) { return "Battlestar Wiki"; }
if (z[n].textContent.indexOf("Battlestar Wiki Media") != -1) { return "Battlestar Wiki"; }
if (z[n].textContent.indexOf("Podcast") != -1) { return "Podcast"; }
if (z[n].textContent.indexOf("Portal") != -1) { return "Portal"; }
if (z[n].textContent.indexOf("Sources") != -1) { return "Sources"; }
if (z[n].textContent.indexOf("Quotes") != -1) { return "Quotes"; }
if ((shortwikiloc == "en") || (shortwikiloc == "md") || (shortwikiloc == "hb") || (shortwikiloc == "zh")) {
if (shortwikiloc == "md") {
if (z[n].textContent.indexOf("Potw") != -1) { return "Potw"; }
}
if (z[n].textContent.indexOf("Template") != -1) { return "Template"; }
if (z[n].textContent.indexOf("Help") != -1) { return "Help"; }
if (z[n].textContent.indexOf("Image") != -1) { return "Image"; }
if (z[n].textContent.indexOf("Category") != -1) { return "Category"; }
if (z[n].textContent.indexOf("User") != -1) {
if (z[n].textContent.indexOf("talk") != -1) {
return "User talk";
} else {
return "User";
}
}
}
return "Article";
}
}
}
function getUsername() {
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];
}
if (username.indexOf("/") != -1){
username = username.split('/')[0];
}
return username;
}
if (window.location.href.indexOf("http://en.") == 0) {
var wikiloc = "http://en.battlestarwiki.org/w/";
var wikiloc_mod = "http://en.battlestarwiki.org/wiki/";
var shortwikiloc = "en";
} else if (window.location.href.indexOf("http://de.") == 0) {
var wikiloc = "http://de.battlestarwiki.org/w/";
var wikiloc_mod = "http://de.battlestarwiki.org/wiki/";
var shortwikiloc = "de";
} else if (window.location.href.indexOf("http://es.") == 0) {
var wikiloc = "http://es.battlestarwiki.org/w/";
var wikiloc_mod = "http://es.battlestarwiki.org/wiki/";
var shortwikiloc = "es";
} else if (window.location.href.indexOf("http://zh.") == 0) {
var wikiloc = "http://zh.battlestarwiki.org/w/";
var wikiloc_mod = "http://zh.battlestarwiki.org/wiki/";
var shortwikiloc = "zh";
} else if (window.location.href.indexOf("http://fr.") == 0) {
var wikiloc = "http://fr.battlestarwiki.org/w/";
var wikiloc_mod = "http://fr.battlestarwiki.org/wiki/";
var shortwikiloc = "fr";
} else if (window.location.href.indexOf("http://tr.") == 0) {
var wikiloc = "http://tr.battlestarwiki.org/w/";
var wikiloc_mod = "http://tr.battlestarwiki.org/wiki/";
var shortwikiloc = "tr";
} else if (window.location.href.indexOf("http://hb.") == 0) {
var wikiloc = "http://hb.battlestarwiki.org/w/";
var wikiloc_mod = "http://hb.battlestarwiki.org/wiki/";
var shortwikiloc = "hb";
} else if (window.location.href.indexOf("http://media.") == 0) {
var wikiloc = "http://media.battlestarwiki.org/w/";
var wikiloc_mod = "http://media.battlestarwiki.org/wiki/";
var shortwikiloc = "md";
}
function addLoadEvent(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
/* </nowiki></pre> */