Gaming
 
[Fisker]

Fisker 1,094 edits since December 10, 2006

1,094

User:Fisker/wowwiki.js

From WoWWiki

Image:Icon-warning-22x22.png Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac)
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Konqueror: simply click the Reload button, or press F5
  • Opera users may need to completely clear the cache in Tools→Preferences.
/*
<pre>
*/

var wgBreakFrames = true;
var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/;
var mwEditButtons = [];

/* detects which key is down */
document.onkeydown = KeyDownHandler;
document.onkeyup = KeyUpHandler;
var CTRL = false;       
var SHIFT = false;     
var ALT = false;
var SPACE = false;

function KeyDownHandler(e) {
var x = '';
if (document.all) {
var evnt = window.event;
x = evnt.keyCode;
} else {
x = e.keyCode;
}
DetectKeys(x, true);
}

function KeyUpHandler(e) {
var x = '';
if (document.all) {
var evnt = window.event;
x = evnt.keyCode;
} else {
x = e.keyCode;
}
DetectKeys(x, false);
}

function DetectKeys(KeyCode, IsKeyDown) {           
if (KeyCode == '16') {
SHIFT = IsKeyDown;
} else if (KeyCode == '17') {
CTRL = IsKeyDown;
} else if (KeyCode == '18') {
ALT = IsKeyDown;
} else if (KeyCode == '32') {
SPACE = IsKeyDown;
}
}

/* changes the Google search box to MediaWiki search box */
function changeSearch() {
document.getElementById('p-search').innerHTML = "<h5><label for='searchInput'>Search</label></h5><div id='searchBody' class='pBody'><form action='/index.php?title=Special:Search' id='searchform'><div><input id='searchInput' name='search' title='Search WoWWiki [alt-shift-f]' accesskey='f' value='' type='text'><input name='go' class='searchButton' id='searchGoButton' value='Go' type='submit'>&nbsp;<input name='fulltext' class='searchButton' id='mw-searchButton' value='Search' type='submit'></div></form></div>";
}

/* goes to user talk page, used in next function */
function goTalk() {
window.location = "http://www.wowwiki.com/User_talk:Fisker?diff=cur";
}

/* changes the personal links (at the top) to include direct links to the customized CSS and JS pages, hides the regular "You have new messages" frame and places the quest icon by the talk link when there are new messages
 */
function changePersonal() {
var divs = document.getElementsByTagName('div');
var tmlt = "";
for (i=0; i<divs.length; i++) {
if (divs[i].className == 'usermessage') {
divs[i].innerHTML = "";
divs[i].style.display = "none";
tmlt = "<li id='pt-mytalkicon' onClick='goTalk();'>&nbsp; &nbsp; </li>";
}
}
document.getElementById('p-personal').innerHTML = "<h5>Personal tools</h5><div class='pBody'><ul><li id='pt-userpage'><a href='/User:Fisker'>Fisker</a></li>" + tmlt + "<li id='pt-mytalk'><a href='/User_talk:Fisker'>talk</a></li><li id='pt-mycss'><a href='/User:Fisker/wowwiki.css'>css</a></li><li id='pt-myjs'><a href='/User:Fisker/wowwiki.js'>js</a></li><li id='pt-preferences'><a href='/Special:Preferences'>preferences</a></li><li id='pt-logout'><a href='/Special:Userlogout'>Log out</a></li></ul></div>";
}

/* changes "navigation" links */
function changeNavigation() {
document.getElementById('p-navigation').innerHTML = "<h5>navigation</h5><div class='pBody'><ul><li id='n-mainpage'><a href='/Main_Page'>Main Page</a></li><li id='n-recentchanges'><a href='/index.php?title=Special:Recentchanges&limit=100'>Recent changes</a></li><li id='n-randompage'><a href='/Special:Random'>Random page</a></li><li id='n-Search-WoWWiki'><a href='/Special:Wantedpages'>Wanted pages</a></li></ul></div>";
}

/* changes "popular" links to more convenient personal favorites */
function changePopular() {
document.getElementById('p-popular').innerHTML = "<h5>personal favorites</h5><div class='pBody'><ul><li id='n-User-Styles'><a href='/WW:GOUS'>User styles</a></li><li id='n-Karazhan'><a href='/Karazhan'>Karazhan</a></li><li id='n-Known-Vandals'><a href='/WW:KV'>Known vandals</a></li><li id='n-Maelstrom'><a href='/Server:Maelstrom_US'>Maelstrom</a></li><li id='n-Coming-Soon'><a href='/Coming_Soon'>Coming Soon</a></li></ul></div>";
}

/* goes to the edit page, used in next function */
function goToEditPage() {
if (CTRL) {
pageName = document.getElementsByTagName('h1')[0].firstChild.nodeValue.replace(" ", "_");
window.location = "http://www.wowwiki.com/index.php?title=" + pageName + "&action=edit";
}
}

/* fixes the problem with the preference "double click to edit" when you can't edit a given page */
function fixViewSource() {
if (document.getElementById('ca-viewsource')) {
if (document.getElementById('ca-viewsource').className != 'selected') {
document.body.onclick = goToEditPage;
}
}
}

/* previews submission, used in next function */
function goToPreview() {
document.editform.wpPreview.click();
}

/* bypasses Preview access key glitch */
function fixPreview() {
if (document.getElementById('ca-edit')) { 	 
if (document.getElementById('ca-edit').className == 'selected') {
document.body.ondblclick = goToPreview;
}
}
}

/* refreshes the page */
function refreshPage() {
window.location.reload();
}

/* refreshes non-editable pages on double-click */
function refreshRC() {
if (!(document.getElementById('ca-edit') || (document.getElementById('ca-viewsource')))) {
document.body.ondblclick = refreshPage;
}
}

/* used in next function */
function editPageFromWhatLinksHere() {
pageName = document.getElementsByTagName('h1')[0].firstChild.nodeValue.replace(" ", "_");
if (!(CTRL)) {
window.location = "http://www.wowwiki.com/index.php?title=" + pageName + "&action=edit";
}
}

/* edits page on single click of a "what links here" page, useful in marking something for speedy deletion when nothing links to it */
function whatLinksHereEdit() {
if (document.URL.indexOf('Special:Whatlinkshere') != -1) {
document.body.onclick = editPageFromWhatLinksHere;
}
}

/* adds text to top of edit box */
function addEditTextToTop(addtext, summary) {
document.editform.wpTextbox1.value = addtext + "\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = summary;
document.editform.wpSave.click();
}

/* adds text to bottom of edit box */
function addEditTextToBottom(addtext, summary) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n\n" + addtext;
document.editform.wpSummary.value = summary;
document.editform.wpSave.click();
}

/* replaces text */
function replaceText(replacetxt, summary) {
document.editform.wpTextbox1.value = replacetxt;
document.editform.wpSummary.value = summary;
document.editform.wpSave.click();
}
/* add welcome tab on User talk pages */
function welcomeUser() {
if ((window.location.href.indexOf('User_talk') != -1) && (window.location.href.indexOf('action=edit') != -1)) {
if (document.editform.wpTextbox1.value == "") {
addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' + 'sub' + 'st::User:Fisker/w' + '}' + '}", "Welcome!");', 'welcome', 'ca-welcome', 'Welcome User', '');
}
}
}

/* add laurlybot tab */
function laurlybot() {
if (document.getElementById('ca-edit')) {
if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('action=edit') != -1)) {
if (window.location.href.indexOf('Quest') == -1) {
addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' + '' + ':User:Laurlybot/Donpc' + '}' + '}", "Tagging for LaurlyBot");', 'laurlybot', 'ca-lbot', 'Tag page for LaurlyBot', '');
} else {
addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' + '' + ':User:Laurlybot/Doquests' + '}' + '}", "Tagging for LaurlyBot");', 'laurlybot', 'ca-lbot', 'Tag page for LaurlyBot', '');
}
}
}
}

/* add foxbot tab */
function foxbot() {
if (document.getElementById('ca-edit')) {
if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('Quest') == -1) && (window.location.href.indexOf('action=edit') != -1)) {
addPortletLink('p-cactions', 'javascript:addEditTextToTop("{' + '{' + '' + ':User:Fisker/f' + '}' + '}", "Tagging for Foxbot");', 'foxbot', 'ca-fbot', 'Tag page for Foxbot', '');
}
}
}

/* handles SD request */
function doSD() {
reason = prompt("Reason for sd", "")
if (reason) {
addEditTextToTop("{{sd|" + reason + "}}", "Speedydelete - " + reason);
}
}

/* add speedydelete tab */
function speedydelete() {
if (document.getElementById('ca-edit')) {
if ((window.location.href.indexOf('User') == -1) && (window.location.href.indexOf('User_talk') == -1) && (window.location.href.indexOf('Talk') == -1) && (window.location.href.indexOf('action=edit') != -1)) {
addPortletLink('p-cactions', 'javascript:doSD();', 'sd', 'ca-sd', 'Mark for speedy deletion', '');
}
}
}

/* does everything */
function doStuff() {
changePersonal();
changeNavigation();
changePopular();
changeSearch();
fixViewSource();
fixPreview();
refreshRC();
whatLinksHereEdit();
welcomeUser();
laurlybot();
foxbot();
speedydelete();
}

/* makes the page wait until it's loaded before it does everything, otherwise it won't be able to access the parts of the page which haven't loaded yet */
addOnloadHook(doStuff);

/* including other pages */
document.write('<script type="text/javascript" src=" \
http://www.wowwiki.com/index.php?title=User:Pcj/autoedit.js \
&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* pcj tooltip stuff */
document.write('<script type="text/javascript" src=" \
http://www.wowwiki.com/index.php?title=User:Pcj/itemtooltip.js \
&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/*
</pre>
[[Category:User JS|Fisker]]
*/