User:Stranger195/PurgeButton.js

/*jshint browser:true, jquery:true*/ /*global mediaWiki*/

( function ( $, mw ) {   'use strict';    var nsNr = mw.config.get( 'wgNamespaceNumber' ),        translations = {            bg: 'Обновяване',            en: 'Refresh',            es: 'Actualizar',            de: 'Neu laden',            fr: 'Actualiser',            hu: 'Frissítés',            it: 'Aggiorna',            ko: '새로고침',            nl: 'Herladen',            pl: 'Odśwież',            pt: 'Actualizar',            'pt-br': 'Atualizar',            ru: 'Обновить',            tl: 'I-sariwa',            uk: 'Оновити',            vi: 'Làm tươi trang',            waf: 'Waffles',            'zh-Hans': '刷新',            'zh-Hant': '重新整理'        },        theText = (typeof window.PurgeButtonText === 'string' && window.PurgeButtonText) ||            translations[mw.config.get('wgContentLanguage')] || translations.en;    if ( nsNr < 0 || window.PurgeButtonsLoaded || document.getElementById( 'control_purge' ) ) { return; }   window.PurgeButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code) $( addPurgeButton ); function purgePage { var page = encodeURIComponent( mw.config.get( 'wgPageName' ) ); $.get( '/index.php?title=' + page + '&action=purge', function {            location.reload( true );        } ); $('html,body').css( {           display: 'block',            overflow: 'hidden'        } ); $( ' ' ).appendTo( document.body ) .css( 'height', $( window ).height ); }   function addOasisPurgeButton  { var selector; switch (nsNr) { case 500: case 502: selector = $( '#WikiaUserPagesHeader' ); break; case 2: case 3: selector = $( '.UserProfileActionButton' ); if ( selector.length ) break; default: selector = $( '#WikiaPageHeader' ); }       selector.find('.wikia-menu-button').first.find('ul') .append(''); }   function addPurgeButton  { switch( mw.config.get( 'skin' ) ) { case 'vector': case 'monobook': $('#p-cactions > .pBody > ul').append(''); break; case 'oasis': case 'wikia': addOasisPurgeButton; break; }       $( '.custom-purge-button' ).text( theText ).click( purgePage ); }   } ( jQuery, mediaWiki ) );