User:Woganhemlock/wikia.js

$(function addEditorButtons {if ($('.checkboxes').length) { $('   Random PageRecent Changes  ').insertBefore('.checkboxes'); } }); function urlQuery(quer) { for(i in location.href.split('?')) { for(j in location.href.split('?')[i].split('&')) { if(location.href.split('?')[i].split('&')[j].split('=')[0] == quer) { return location.href.split('?')[i].split('&')[j].split('=')[1]; }		}	}	return ''; } function AddRecentChanges { $('div.buttons').css({'width': '310px'}); $('a[data-id="wikiactivity"]').after('Recent Changes'); } addOnloadHook(AddRecentChanges);

/* add contribs to user menu - 2/1/11 */

function UserContribsMenuItem { $('ul.AccountNavigation li:first-child ul.subnav li:first-child').after('Contributions'); } addOnloadHook(UserContribsMenuItem);

/* kill image popups - 3/30/11 */ function changeimagelinks {

if (window.skin == 'oasis') { var article = $('#WikiaArticle, .LatestPhotosModule, #article-comments'); }   else { var article = $('#bodyContent'); }

article.unbind('click.lightbox');

var a = document.getElementsByTagName("a"); for ( var t = 0; t < a.length; ++t ) { var a2 = a[t]; var img = a2.getElementsByTagName("img"); if ( img[0] != null ) { if ( a2.href.indexOf("images.wikia.com") != -1 ) { var link = wgServer + '/wiki/File:' + a2.href.substring(a2.href.lastIndexOf('/') + 1); a2.setAttribute('href',link); }       }    } }

addOnloadHook(changeimagelinks);

/* add upload photo button to main page - 3/8/11 */ function UploadOnMainPage { $('.mainpage #WikiaPageHeader div:first').append(' Upload Image</a> '); }

addOnloadHook(UploadOnMainPage);

/*i do something - custom rollbacks, to be precise*/

function CustomRollbacks { var Buttons = [{ text: '-spam-', title: 'Revert spam', summary: 'Reverted spam', loadtalk: false }, {               text: '-vandalism-', title: 'Revert vandalism', summary: 'Reverted vandalism', loadtalk: false }, {               text: '-null-', title: 'Revert with no summary, flags as bot edit', summary: ' &bot=1', //This one has no summary, and flags it as a bot edit loadtalk: false }];       var list = document.getElementsByTagName('span'); for(i in list) { if(list[i].className == 'mw-rollback-link') { var link = list[i]; var rollback = link.innerHTML; for(j in Buttons) { var customlink = document.createElement('span'); customlink.innerHTML = rollback; customlink.className = 'customrollback'; //we do this to avoid an infinite loop, because when we insert a into the DOM, the list variable includes it                               customlink.getElementsByTagName('a')[0].title = Buttons[j].title; customlink.getElementsByTagName('a')[0].href += '&summary=' + Buttons[j].summary; customlink.getElementsByTagName('a')[0].innerHTML = Buttons[j].text; if(Buttons[j].loadtalk == true) {customlink.getElementsByTagName('a')[0].className = 'loadtalk';} if(urlQuery('action') == 'history') { link.parentNode.insertBefore(customlink, link.nextSibling); customlink.outerHTML = ' | ' + customlink.outerHTML; }                               else { link.parentNode.appendChild(customlink); customlink.outerHTML = ' ' + customlink.outerHTML; }                       }                }        }        for(i in list) { //why another one of these? we're fixing the class that we set to avoid an infinite loop if(list[i].className == 'customrollback') { list[i].className = 'mw-rollback-link'; }       }        /* Grunny's function for opening up a user's talkpage when rollbacking (http://community.wikia.com/wiki/User:Grunny) */ $( '.mw-rollback-link .loadtalk' ).click( function (e) {               e.preventDefault;                var $rblink = $( this );                $.ajax( { url: $rblink.attr( 'href' ), success: function { var    user = $rblink.attr( 'href' ).replace( /.*[&?]from=([^&]*).*/, '$1' ).replace( /\+/g, '_' ), newurl = wgServer + wgArticlePath.replace( '$1', 'User_talk:' + user + '?action=edit&section=new' ); location.href = newurl; },                       error: function  { $rblink.text( function ( i, val ) {                                       return val + ' [failed]';                                } ); }               } );        } ); } addOnloadHook(CustomRollbacks);

// remove admin link on toolbar $.ready( function { $('li > a[data-tracking="admindashboard/toolbar/admin"]').remove; } ); /*remove popup from images, go direct to page*/

///////////// Override Lightboxes and go directly to the image's page when clicking on an image $(document).ready(function { $('#WikiaArticle').unbind('click.lightbox');  var a = document.getElementsByTagName("a");  for ( var t = 0; t < a.length; ++t ) {    var a2 = a[t];    var img = a2.getElementsByTagName("img");    if ( img[0] != null ) {      if ( a2.href.indexOf("images.wikia.com") != -1 ) {        var link = wgServer + '/wiki/File:' + a2.href.substring(a2.href.lastIndexOf('/') + 1);        a2.setAttribute('href',link);      }    }  } }); ///////////// End of Lightboxes override

/*test function - does stuff*/ $(function { $('fieldset div').addClass('showChangesText').css('right','15px'); }

<form method="get" action="index.php?title=Special:Search" class="WikiaSearch" id="WikiaSearch"><input type="text" accesskey="f" autocomplete="off" placeholder="Search the wiki" name="search"><input type="hidden" value="0" name="fulltext"> <img width="21" height="17" class="sprite search" src="blank.gif">