User:Fandyllic/global.js

/* ***** */

//A script that adds a "Go to bottom" button in the footer of the Oasis theme. //Based on BackToTop by Noemon from Dead Space Wiki (function(window, $, mw) {   'use strict';    var translations = {    //    ar:         'انتقل إلى أسفل',    //    af:         'Gaan na onder',    //    be:         'перайсці ўніз',    //    bg:         'Отидете надолу',    //    bs:         'Idite dole',    //    ca:         'Vés a baix',    //    cs:         'Jděte dolů',    //    da:         'Gå til bunden',    //    de:         'Gehe nach unten',    //    el:         'Πηγαίνετε κάτω',        en:         'Go to bottom'//,    //    eo:         'Iru al fundo',    //    es:         'Ir al fondo',    //    eu:         'Joan beherantz',    //    fa:         'به پایین بروید',    //    fr:         'Aller au fond',    //    ga:         'Téigh go dtí bun',    //    gl:         'Ir a fondo',    //    hi:         'नीचे जाएं',    //    hr:         'Idi na dno',    //    id:         'Ke bawah',    //    it:         'Vai in basso',    //    ja:         '下に行く', //   ko:         '하단으로 이동', //   la:         'Ad deorsum', //   mk:         'Оди до дното', //   ms:         'Pergi ke bawah', //   nl:         'Ga naar beneden', //   no:         'Gå til bunnen',' //   pl:         'Przejdź na dół', //   pt:         'Ir para o fundo', //   'pt-br':    'Ir para o fundo', //   ro:         'Du-te jos', //   ru:         'Вниз', //   sco:        'Rach gu bonn', //   sl:         'Pojdi do dna', //   sr:         'Иди до дна', //   sv:         'Gå till botten', //   tl:         'Pumunta sa ibaba', //   uk:         'Іди донизу', //   vi:         'Đi xuống dưới cùng', //   zh:         '转到底部', //   'zh-hans':  '转到底部', //   'zh-hant':  '轉到底部' },   buttonStart = typeof window.JumpToBottomStart === 'number' ? window.JumpToBottomStart : 0,   scrollSpeed = typeof window.JumpToBottomSpeed === 'number' ? window.JumpToBottomSpeed : 600,   fadeSwitch = typeof window.JumpToBottomFade === 'number' ? window.JumpToBottomFade : 600,   theText = (typeof window.JumpToBottomText === 'string' && window.JumpToBottomText) || translations['en'] || translations.en; if (window.JumpToBottomLoaded) { return } window.JumpToBottomLoaded = true; $(addJumpToBottom); function hideFade { $("#jumptobottom").hide; $(window).scroll(function {           if ($(this).scrollTop > buttonStart) {                switch (fadeSwitch) {                    case 0:                        $('#jumptobottom').show;                        break;                    default:                        $('#jumptobottom').fadeIn;                        break;                }            } else if ($(this).scrollTop > ($('#mw-content-text').height - $('.wds-global-footer').height)) {                switch (fadeSwitch) {                    case 0:                        $('#jumptobottom').hide;                        break;                    default:                        $('#jumptobottom').fadeOut;                        break;                }            } else {                switch (fadeSwitch) {                    case 0:                        $('#jumptobottom').hide;                        break; default: $('#jumptobottom').fadeOut; break; }           }        });    }    $('body').on('click', '#jumptobottom', function { $('body,html').animate({           scrollTop: $('#mw-content-text').height - $('.wds-global-footer').height + 220            }, scrollSpeed); return false; });   function addJumpToBottom {        if (skin == 'oasis') {            $(' ', { id: 'jumptobottom', style: 'float: right; margin-top: -1px; border-right: none' })           .append( $(' ', {                   type: 'button',                    style: 'height: 20px;',                    text: theText                }) )           .appendTo('#WikiaBarWrapper .toolbar > .tools');            hideFade;        }    } }(this, jQuery, mediaWiki));

/* Purge button to left of page header contrib buttons on modernized UI v2*/ $(function {	var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('div.page-header__contribution-buttons > div.wds-button-group > a:first-child').not('#custom-purge').before(' Purge '); });

/* History button for diffs */ /* (doesn't work on some namespaces like User: and User talk: */ /*   because w:Special:MyPage/global.js and Special:MyPage/wikia.js */ /*   never get loaded) */ $(function {	$("h1:contains('Changes:')").after('History'); })

/* Back to top button on Wikia bottom tool bar */ importScriptPage('MediaWiki:BackToTopButton/code.js', 'dev');

/* Edit button (classic editor) to right of page name header */ /* DISABLE, since you can now default to source editor, but still access new VE (but not old VE) $(function {    var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('#WikiaPageHeader > h1').after(' Edit '); });

/* Purge link to right of page name header */ /* NOTE: Stopped working mid-2017 $(function {	var currServer = mw.config.get('wgServer');	var newPageName = wgPageName.replace(/\?/,"\%3F");	var newTitle = wgTitle;	if (wgCanonicalNamespace) newTitle = wgCanonicalNamespace + ":" + wgTitle;	$('.tally > em').before('  '); */	/* PAGE TITLE LINK $('#WikiaPageHeader > h1').after('  ' + newTitle + ' '); */ /* });

/** * To use this script, install it and view:  Special:InterLangList?filtertype=interlanguage */ if (mediaWiki.config.get('wgCanonicalSpecialPageName') === 'Blankpage' && $.getUrlVar('filtertype') === 'interlanguage') { (function ($, mw) {		var url = mw.config.get('wgServer') + '/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json';		// get local interwiki map		$.getJSON(url, function (data) { var interlanguageWikis = [], map = data.query.interwikimap; for (var i = 0, len = map.length; i < len; i++) { if (map[i].language) { interlanguageWikis[interlanguageWikis.length] = map[i]; }			}			// display results in an HTML table $(function {				// generate html				var wiki, link, html, message;				message = ' The ' + mw.config.get('wgSiteName') + ' appears to be available in ' + interlanguageWikis.length + ' language(s).  Do you know of a version of this wiki in a language not listed here? You can make a request here for it to be interlanguage linked. ';				html = ' ' + message + ' ';				// insert html				document.title = 'Interlanguage wikis';				$('#firstHeading, #WikiaArticle h1').first.text('Interlanguage wikis');				$('#mw-content-text').html(html);			}); });	}(jQuery, mediaWiki)); }

/* Add Contributions to user drop down */ /* NOTE: Broken. $(function {   $('ul.AccountNavigation li:first-child ul.subnav li:first-child').after('<li>Contributions</a></li>'); });

/* Convert "Anonymous" in Comments to IP address from User:Monchoman45                        */ $(function {   var list = document.getElementsByTagName('a');    for(var i in list) {        if(list[i].href && list[i].href.indexOf('Special:Contributions/') && list[i].innerHTML == 'A Wikia contributor') {            list[i].innerHTML = list[i].href.substring(list[i].href.lastIndexOf('/') + 1, list[i].href.length);        }    } }); /* END Convert "Anonymous" in Comments to IP address */

/* Adds a 'Back to page' link under the preview header when previewing an edit. */ $(function {   if (wgAction == "submit") {        $('#WikiaEditBoxHeader p').clone.appendTo('#WikiaPageHeader:first-child');    } });

/* Experimental auto signer http://dev.wikia.com/wiki/Sine */ /* Disable for now importScriptPage('Sine/code.js', 'dev');

/* See User:Fandyllic/langwikicheckerJS for a copy of JS at Thread:484838   */