User:Mathmagician/railgun.js

// Outside variables var railgunDefaultMode = 0; // default mode to enter upon pageload // Inside variables var railgunMode; if (wgNamespaceNumber != undefined) { addOnloadHook(launchRailgun); }

/* function launchRailgun -- */ /* Starts up Railgun upon page load, placed inside addOnloadHook - */ /* - */ function launchRailgun { railgunMode = railgunDefaultMode; //var contentWidth = $('#WikiaMainContent').width; //var catlinksWidth = $('#catlinks').width; var railgunModeButton = "";

if (railgunMode == 0) { railgunModeButton = '+'; $(railgunModeButton).appendTo('.tools');

// Initialization for mode 0 if (!window.hasRailgunModule) { addRailgunModule; }	} else if (railgunMode == 1) { railgunModeButton = '-'; $(railgunModeButton).appendTo('.tools');

// Initialization for mode 1 document.getElementById('WikiaRail').style.display = 'none'; document.getElementById('WikiaMainContent').style.width = '1000px'; document.getElementById('catlinks').style.width = '1000px'; } else { railgunButton = 'W</ul></li>'; $(railgunModeButton).appendTo('.tools');

// Initialization for mode 2 document.getElementById('WikiaRail').style.display = 'block'; document.getElementById('WikiaMainContent').style.width = '680px'; document.getElementById('catlinks').style.width = '638px'; } }

/* function setRailgunMode0 */ /* Expand the WikiaRail to include the Railgun module -- */ /* - */ function setRailgunMode0 { if (wgNamespaceNumber != undefined && !window.hasRailgunModule) { addRailgunModule; }	$('#railgunModeButton a').replaceWith('<a onclick="setRailgunMode1;" style="color:#fff; width: 15px; text-align:center" title="go to -">+</a>'); railgunMode = 0; }

/* function setRailgunMode1 */ /* Completely collapse the WikiaRail --- */ /* - */ function setRailgunMode1 { $('.RailgunModule').replaceWith(''); hasRailgunModule = false; $('#railgunModeButton a').replaceWith('<a onclick="setRailgunMode2;" style="color:#fff; width: 15px; text-align:center" title="go to W">-</a>'); document.getElementById('WikiaRail').style.display = 'none'; document.getElementById('WikiaMainContent').style.width = '1000px'; document.getElementById('catlinks').style.width = '1000px'; railgunMode = 1; }

/* function setRailgunMode2 */ /* Restore the WikiaRail to its default setting */ /* - */ function setRailgunMode2 { $('#railgunModeButton a').replaceWith('<a onclick="setRailgunMode0;" style="color:#fff; width: 15px; text-align:center" title="go to +">W</a>'); document.getElementById('WikiaRail').style.display = 'block'; document.getElementById('WikiaMainContent').style.width = '680px'; document.getElementById('catlinks').style.width = '638px'; railgunMode = 2; }

/* function addRailgunModule --- */ /* Creates the Railgun Module on the WikiaRail - */ /* - */ function addRailgunModule { var header = '<h1 style="margin-bottom: 16px;">Railgun<form onsubmit="railgunSearch; return false;" name="RailgunSearchForm" class="RailgunSearchForm" id="RailgunSearchForm" style="margin-top: 10px;"><input type="text" placeholder="Search wikipedia.org" name="RailgunSearchInput" class="RailgunSearchInput" id="RailgunSearchInput" style="width: 195px; margin-right: 8px;" /><input class="secondary" type="button" onclick="railgunSearch;" value="Search" style="width: 75px;" /> ';

var thisPage = '<p style="margin-top: 0px; margin-bottom: 0.6em; font-size: 1.2em;"><a href="/wiki/' + wgPageName + '">' + wgPageName.replace(/_/g, " ") + '</a> ' + ' ';	var thisWiki = '<p style="margin-top:0.6em; margin-bottom:0.6em; font-size: 1.2em;"><a href="/wiki/">' + wgSiteName + '</a> ' + ' ';

var userImage = '<img src="http://images1.wikia.nocookie.net/mathmagician/images/7/79/Star_30px.png" title="+1 Happiness" style="width: 24px; height: 24px; vertical-align: middle;">';

var userList = '<p style="margin-top:0.6em; margin-bottom:0.6em; font-size: 1.2em;">User List ' + ' ';

var global = '<p style="margin-top:0.6em; margin-bottom:0.6em; font-size: 1.2em;"><a href="http://www.wikia.com/Wikia">Wikia</a> :: <a href="/wiki/Special:Contact">Contact</a> ' + ' ';	var html = '<section class="RailgunModule module">' + header + thisPage + thisWiki + userList + global + ' ';

var WikiaRail = document.getElementById("WikiaRail"); var WikiaSearch = document.getElementById("WikiaSearch"); if (WikiaSearch.parentNode == WikiaRail) { $(html).insertAfter('#WikiaSearch'); } else { $(html).insertAfter(WikiaRail.firstChild); }	hasRailgunModule = true; } /* function railgunSearch */ /* Searches google, bing, wikipedia or youtube for the given text -- */ /* - */ function railgunSearch { var query = document.RailgunSearchForm.RailgunSearchInput.value; if (query == "") { return; } document.RailgunSearchForm.RailgunSearchInput.value = ""; window.open('http://en.wikipedia.org?search=' + query); } /* - */ function stalkSomeone { var username = document.RailgunStalkForm.RailgunStalkInput.value; if (username == "") { return; } document.RailgunStalkForm.RailgunStalkInput.value = "";

var image = '<img onclick="unstalkSomeone(this.parentNode.parentNode);" src="http://images1.wikia.nocookie.net/mathmagician/images/0/00/Bomb_Omb_30px.png" title="Explodify!" style="width: 24px; height: 24px; vertical-align: middle;">';

var html = ' ' + image + ' <a href="/wiki/User:' + username + '">' + username + '</a> [<a href="/wiki/User_talk:' + username + '">talk</a>] [<a href="/wiki/User_blog:' + username + '">blog</a>] [<a href="/wiki/Special:Contributions/' + username + '">contrib</a>] [<a href="/wiki/Special:Editcount/' + username + '">count</a>] [<a href="/wiki/Special:Log/' + username + '">log</a>] [<a href="/wiki/Special:EmailUser/' + username + '">email</a>] ';

$(html).insertBefore('.RailgunStalkFormContainer'); } function unstalkSomeone(userRow) { $(userRow).replaceWith(''); }