User:Starfleet Academy/global.js

// // STARFLEET ACADEMY'S GLOBAL JAVASCRIPT FILE: Use at own risk. Bugs should be noted, however.

//IMPORTS //Importing 'Wikimarks' gadget by Pecoes importScriptPage('Wikimarks/code.js', 'dev'); //END importing gadget //Importing my own gadget. It's not quite ready for beta yet. importScriptPage('MediaWiki:RC.js', 'sixteen-aft'); //END importing gadget //END Imports

//(window.mw = window.mw || {}).config = window.mw.config || { get: function(p) { return window[p]; } };

//This class makes a URL friendly version of passed wgVariables -- by Starfleet Academy var FixWgVariable = function(wgVariable) { var variable = wgVariable; this.getVar = function { return variable; }   this.encodeURL = function { var variable = this.getVar; var findDQuotes = new RegExp('"');       var findAmps = new RegExp('&');            variable = variable.replace(/!/g, '%21');            variable = variable.replace(/"/g, '%22'); variable = variable.replace(/#/g, '%23'); variable = variable.replace(/\u0024/g, '%24'); varaible = variable.replace(/%/g, '%25'); variable = variable.replace(/&/g, '%26'); variable = variable.replace(/\u003F/g, '%3F'); return variable; }; }; //END fixing URLs

/*//Adds recent changes button to Main header -- by Starfleet Academy $(function navRC { var blankimgurl=mw.config.get('wgBlankImgUrl');   if (mw.config.get('wgAction') == "edit" || mw.config.get('wgPageName') == "User:Starfleet_Academy/Wikimarks") {        $('.WikiaHeader .GlobalNavigation').append('RC  ');    } else {        $('.WikiaHeader .GlobalNavigation').append('RC  ');    } }); //END adding recent changes button*/

//Adds links to my blog, contribs & watchlist //under talkpage link in account nav (drop-down) -- by Starfleet Academy $(function accnavLinks { var server = mw.config.get('wgServer'),   pagename = mw.config.get('wgPageName'),    DBname = mw.config.get('wgDBname'),    CCwiki = "http://community.wikia.com";    if ( DBname != "admintools" ) {        if ( pagename == "Wikia" ) {            $('.WikiaHeader .AccountNavigation .subnav > li:first-child').after('My blog<a data-id="mycontribs" href="' + CCwiki + '/wiki/Special:Contributions/Starfleet_Academy">Contributions</a></li><a data-id="mywatchlist" href="' + CCwiki + '/wiki/Special:Following">Followed pages</a></li>');        } else {            $('.WikiaHeader .AccountNavigation .subnav > li:first-child').after('<a data-id="myblog" href="/wiki/User_blog:Starfleet_Academy">My blog</a></li><a data-id="mycontribs" href="/wiki/Special:Contributions/Starfleet_Academy">Contributions</a></li><a data-id="mywatchlist" href="/wiki/Special:Following">Followed pages</a></li>'); }   } }); //END adding links to Account nav

//Adds purge link to edit menu -- by Starfleet Academy $(function purgeLink { var fixPageName = new FixWgVariable(mw.config.get("wgPageName")),   pageName = fixPageName.encodeURL;    if (mw.config.get('wgPageName') != "User:Starfleet_Academy/Wikimarks") {        $('.WikiaPageHeader .wikia-menu-button .WikiaMenuElement > li:first-child').before('<a href="/index.php?title='+ pageName +'&action=purge" data-id="purge">Purge</a></li>');    };    if (mw.config.get('wgCanonicalNamespace') == "User", "User_talk") {        $('.UserProfileActionButton .wikia-menu-button .WikiaMenuElement > li:first-child').before('<a href="/index.php?title='+ pageName +'&action=purge" data-id="purge">Purge</a></li>');    } }); //END adding purge button

//Adds a "return to page top" link on the toolbar -- by Starfleet Academy $(function beamMeUp { var server=mw.config.get('wgServer'),   fixPageName = new FixWgVariable(mw.config.get("wgPageName")),    pageName= fixPageName.encodeURL;    switch (mw.config.get("wgAction")) {        case "protect":        pageName += "?action=protect";        break;        case "delete":        pageName += "?action=delete";        break;    }    if (mw.config.get("wgAction") != "history" || mw.config.get('wgCanonicalNamespace') == "Message_Wall" || mw.config.get('wgCanonicalNamespace') == "Thread") {        $('.skin-oasis .WikiaBarWrapper .toolbar .tools').append('<a href="'+ server +'/wiki/'+ pageName +'#WikiaHeader" class="to-top-link" title="Return to page home">Top</a></li>');    } }); //END top-returning link

//Changes the contribute button to a random page button //And adds a random in cat button on category pages -- by Starfleet Academy $(function { var server=mw.config.get('wgServer'),   fixTitle = new FixWgVariable(mw.config.get("wgTitle")),    title= fixTitle.encodeURL;    $('.WikiHeader .buttons .contribute').replaceWith('<a href="'+ server +'/wiki/Special:Random" title="Random Page" class="wikia-button secondary" data-id="randompage"><img src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" height="0" width="0" class="sprite random" /> Random Page</a>');    if (mw.config.get('wgCanonicalNamespace') == "Category") {        $('.WikiHeader .buttons').append('<a href="'+ server +'/wiki/Special:RandomInCategory/'+ title +'" target="_blank" title="Random Page" class="wikia-button secondary" data-id="randompage"><img src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" height="0" width="0" class="sprite random" /> RIC</a>');    } }); //END random page button.

//Edit button customz if ( mwCustomEditButtons ) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/central/images/1/11/Button_category.png", "speedTip": "Category", "tagOpen": "[[Category:",		"sampleText": "Insert cat"       }; }; //END edit button customz // EOF //