FANDOM


//
/**
 * This file was minified with the YUI Compressor
 * to see the full version go to [[RailgunClient.js]]
 * to see the documentation go to [[Docs/Files]]
 */
 
Railgun={isDebug:false,version:"2.1.0"};Railgun.Storage={domain:"http://railgunscript.wikia.com",iframe:null,serverState:null,storageState:null,sendRequest:function(a){if(Railgun.isDebug){console.log("Client issuing "+a.instruction+" request to the server:");console.log(a)}this.iframe.contentWindow.postMessage(JSON.stringify(a),this.domain)},init:function(){var a='<iframe id="railgun-server"style="display: none; position: absolute; left: -1px; width: 1px;"src="'+this.domain;if(Railgun.isDebug){a+='/wiki/RailgunServerDebug?action=render"></iframe>'}else{a+='/wiki/RailgunServer?action=render"></iframe>'}$(document.body).append(a);this.iframe=document.getElementById("railgun-server")}};Railgun.ShowHideSiderail={siderailHidden:false,leftArrow:'<img class="railgun-siderail-left-arrow" src="http://images3.wikia.nocookie.net/mathmagician/images/a/ab/ArrowLeft.png" onclick="Railgun.ShowHideSiderail.showSiderail();">',rightArrow:'<img class="railgun-siderail-right-arrow" src="http://images4.wikia.nocookie.net/mathmagician/images/9/93/ArrowRight.png" onclick="Railgun.ShowHideSiderail.hideSiderail();">',showSiderail:function(){Railgun.Storage.sendRequest({id:"showSiderail()",instruction:"setItem",key:"siderailHidden",value:false});$(".WikiaRail, .WikiaMainContent, .catlinks").removeClass("railgun-no-siderail");$(".railgun-siderail-left-arrow").css("display","none");$(".railgun-siderail-right-arrow").css("display","block")},hideSiderail:function(){Railgun.Storage.sendRequest({id:"hideSiderail()",instruction:"setItem",key:"siderailHidden",value:true});$(".WikiaRail, .WikiaMainContent, .catlinks").addClass("railgun-no-siderail");$(".railgun-siderail-left-arrow").css("display","block");$(".railgun-siderail-right-arrow").css("display","none")},init:function(){this.siderailHidden=Railgun.Storage.storageState.siderailHidden?true:false;$(".WikiaFooter .toolbar").prepend(this.leftArrow+this.rightArrow);if(true===this.siderailHidden){$(".WikiaRail, .WikiaMainContent, .catlinks").addClass("railgun-no-siderail");$(".railgun-siderail-left-arrow").css("display","block");$(".railgun-siderail-right-arrow").css("display","none")}else{$(".railgun-siderail-left-arrow").css("display","none");$(".railgun-siderail-right-arrow").css("display","block")}}};Railgun.FriendsList={friends:null,noFriendsMessage:'<p class="railgun-no-friends-message">It looks like you haven\'t made any friends yet. To add someone to your friend\'s list, simply click the icon on their profile masthead. There\'s no hurry, Fluttershy will keep you company in the meantime.<img src="http://images3.wikia.nocookie.net/mathmagician/images/5/5a/Fus_Ro_Yay%21.gif"></p>',addFriendProfileImage:'<img src="http://images1.wikia.nocookie.net/__cb20120418234625/mathmagician/images/0/00/Bomb_Omb_30px.png" onclick="Railgun.FriendsList.addFriend();" class="railgun-add-friend-image" title="This user is not your friend. Click to explodify!">',removeFriendProfileImage:'<img src="http://images1.wikia.nocookie.net/__cb20120418234525/mathmagician/images/7/79/Star_30px.png" onclick="Railgun.FriendsList.removeFriend();" class="railgun-remove-friend-image" title="Friendship is witchcraft. Click to steal your friend\'s star!">',toggleLinks:function(b,a){$(b).find(".railgun-friend-td2-span2").css("visibility",a?"visible":"hidden")},createFriendHTML:function(j){var f=encodeURIComponent(j.replace(/ /,"_"));var q='<a href="/wiki/User:'+f+'">';var g='<img src="'+$(".masthead-avatar .avatar").attr("src")+'" class="railgun-friend-avatar">';var n='<tr class="railgun-friend-tr" data-user="'+j+'" onmouseover="Railgun.FriendsList.toggleLinks(this, true);" onmouseout="Railgun.FriendsList.toggleLinks(this, false);">';var h='<td class="railgun-friend-td1">';var e='<td class="railgun-friend-td2">';var d='<span class="railgun-friend-td2-span1">';var c='<a href="/wiki/User:'+f+'">'+j+"</a>";var b='<span class="railgun-friend-td2-span2">';var m='[<a href="/wiki/User_talk:'+f+'">talk</a>]';var o=' [<a href="/wiki/User_blog:'+f+'">blog</a>]';var p=' [<a href="/wiki/Special:Contributions/'+f+'">contrib</a>]';var l=' [<a href="/wiki/Special:Editcount/'+f+'">count</a>]';var i=' [<a href="/wiki/Special:Log/'+f+'">log</a>]';var a=' [<a href="/wiki/Special:PrefixIndex/User:'+f+'">subpages</a>]';var k=n+h+q+g+"</a></td>"+e+d+c+"</span><br />"+b+m+o+p+l+i+a+"</span></td></tr>";return k},addFriend:function(){var e=$(".masthead-info h1").text();var c=this.createFriendHTML(e);var a=-1;for(var b=0;b<this.friends.length;b++){if(this.friends[b].username===e){a=b;break}}if(-1!==a){this.friends.splice(a,1)}this.friends.push({username:e,html:c,homewiki:wgServer});this.friends.sort(function(g,f){if(g.username<f.username){return -1}else{if(g.username==f.username){return 0}else{return 1}}});Railgun.Storage.sendRequest({id:"addFriend()",instruction:"setItem",key:"friends",value:this.friends});$(".railgun-no-friends-message").remove();var d=$(".railgun-friend-tr");if(0===d.length){$(".railgun-friend-table").append(c)}else{if(e<d.first().attr("data-user")){$(".railgun-friend-table").prepend(c)}else{if(e>d.last().attr("data-user")){$(".railgun-friend-table").append(c)}else{for(var b=0;b<d.length;b++){if(e<$(d[b]).attr("data-user")){$(d[b]).before(c);break}}}}}$(".railgun-add-friend-image").replaceWith(this.removeFriendProfileImage)},removeFriend:function(){var d=$(".masthead-info h1").text();var c=$(".railgun-friend-tr");var a=-1;for(var b=0;b<this.friends.length;b++){if(this.friends[b].username===d){a=b;break}}if(-1!==a){this.friends.splice(a,1)}Railgun.Storage.sendRequest({id:"removeFriend()",instruction:"setItem",key:"friends",value:this.friends});switch(c.length){case 0:break;case 1:c.replaceWith(this.noFriendsMessage);break;default:for(var b=0;b<c.length;b++){if(d===$(c[b]).attr("data-user")){$(c[b]).remove();break}}}$(".railgun-remove-friend-image").replaceWith(this.addFriendProfileImage)},init:function(){var g='<section class="railgun-friend-module module">';var h="<h1>Friend's List</h1>";var f='<table class="railgun-friend-table" cellspacing="3">';this.friends=Railgun.Storage.storageState.friends||[];var e=[];var b="";if(0===this.friends.length){b=this.noFriendsMessage}else{for(var d=0;d<this.friends.length;d++){e[d]=this.friends[d].username;b+=this.friends[d].html}}var c=g+h+f+b+"</table></section>";if($("#WikiaSearch").parent().attr("id")==="WikiaRail"){$("#WikiaSearch").after(c)}else{$("#WikiaRail").prepend(c)}var a=$(".masthead-info h1");if(0!==a.length){if(-1===e.indexOf(a.text())){$(".masthead-info hgroup").append(Railgun.FriendsList.addFriendProfileImage)}else{$(".masthead-info hgroup").append(Railgun.FriendsList.removeFriendProfileImage)}}}};Railgun.initLoadModules=function(){if(window.removeEventListener){window.removeEventListener("message",Railgun.initProcessServerResponse,false)}else{if(window.detachEvent){window.detachEvent("message",Railgun.initProcessServerResponse)}}Railgun.ShowHideSiderail.init();Railgun.FriendsList.init()};Railgun.initProcessServerResponse=function(a){if(a.origin!==Railgun.Storage.domain){return}var b=JSON.parse(a.data);Railgun.Storage.serverState=b.serverState;Railgun.Storage.storageState=b.storageState;Railgun.initLoadModules()};Railgun.initRequestServer=function(){if(window.addEventListener){window.addEventListener("message",Railgun.initProcessServerResponse,false)}else{if(window.attachEvent){window.attachEvent("message",Railgun.initProcessServerResponse)}}Railgun.Storage.sendRequest({instruction:"retrieve",isDebug:Railgun.isDebug})};Railgun.init=function(){if(null===wgUserName){if(Railgun.isDebug){console.log("Railgun didn't initialize because: not logged in")}return}else{if("oasis"!==skin){if(Railgun.isDebug){console.log("Railgun didn't initialize because: not using Oasis")}return}else{if(0===$(".WikiaRail").length){if(Railgun.isDebug){console.log("Railgun didn't initialize because: siderail absent")}return}else{if("http://wikimarks.wikia.com"===wgServer){if(Railgun.isDebug){console.log("Railgun didn't initialize because: domain is wikimarks")}return}}}}$("#railgun-stylesheet").remove();var a=Railgun.Storage.domain;if(Railgun.isDebug){a+="/wiki/MediaWiki:RailgunStylesheetDebug.css?action=raw&ctype=text/css&maxage=0&smaxage=0"}else{a+="/wiki/MediaWiki:RailgunStylesheet.css?action=raw&ctype=text/css"}$(document.head).append('<link id="railgun-stylesheet" rel="stylesheet" type="text/css" href="'+a+'">');Railgun.Storage.init();if(Railgun.Storage.iframe.addEventListener){Railgun.Storage.iframe.addEventListener("load",Railgun.initRequestServer,false)}else{if(Railgun.Storage.iframe.attachEvent){Railgun.Storage.iframe.attachEvent("onload",Railgun.initRequestServer)}}};$(function(){Railgun.init()});
//