User:Pirr/global.js

require( ['jquery', 'mw', 'wikia.window'], function( $, mw, window ) {   var config = mw.config.get( [ 'wgTrackID', 'wgUserGroups', 'wgUserLanguage', 'wgUserName', 'wgContentLanguage' ] );   if ( config.wgTrackID !== 33612736 || window.GlobalJSLoaded ) return;    window.GlobalJSLoaded = true;    var global = {};    global.i18n = function( msg, lang ) {        if ( !msg ) return;        var language;        if ( lang === 'content' ) {            language = config.wgContentLanguage;        } else {            language = lang || config.wgUserLanguage;        }        var messages = {            en: {                'err_no-msg': 'No message found!',                'recentchanges': 'Recent changes',                'summary-delete': 'Housekeeping',                'summary-block': 'Vandalism',                'summary-comment': 'Harmful comment',                'summary-file': 'Auto-update of file names'            },            pl: {                'err_no-msg': 'Nie znaleziono komunikatu!',                'recentchanges': 'Ostatnie zmiany', 'summary-delete': 'Porządki', 'summary-block': 'Wandalizm', 'summary-comment': 'Obraźliwy komentarz', 'summary-file': 'Automatyczna aktualizacja nazw plików' }       };        messages = $.extend(            messages.en,            messages[language]        ); if ( Object.keys( messages ).indexOf( msg ) >= 0 ) { return messages[msg]; } else { return messages['err_no-msg']; }   };    global.import = function { window.ajaxSpecialPages = [ 'Recentchanges', 'Images', 'Videos', 'Watchlist', 'Newwikis', 'Log', 'NewPages', 'Wikiactivity' ];       window.announcementsIgnore = { option: 'opt-out-all', exceptWikiIds: [ // wikia.php?controller=WikisApi&method=getDetails&ids= 7931,  // Dev Wiki 177,   // Community Central 1686,  // Centrum Społeczności ]       };        window.ajaxRefresh = 15000; window.MultiUploadoption = { max: 75 }; window.lastEdited = { avatar: false }; window.qtUserPageTemplate = '' : '}}'; window.WHAMDeleteReason = global.i18n( 'summary-delete', 'content' ); window.WHAMBlockReason = global.i18n( 'summary-block', 'content' ); window.AjaxCommentDeleteConfig = global.i18n( 'summary-comment', 'content' ); LIRoptions = { editSummary: global.i18n( 'summary-file', 'content' ) }; var imports = { user: [ 'u:dev:MediaWiki:AjaxUndo/code.js', 'u:dev:MediaWiki:AjaxRC/code.js', 'u:dev:MediaWiki:ConsistentNotifications.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:MultiUpload/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:UnhideUserMasthead/code.js', 'u:dev:MediaWiki:View Source/code.js', 'u:dev:MediaWiki:LastEdited/code.js', 'u:dev:MediaWiki:QuickCreateUserPage/code.js', 'u:dev:MediaWiki:UnsafeScripts/code.js', 'u:dev:MediaWiki:SearchSuggest/code.js', 'u:dev:MediaWiki:FixPolishMonths.js', 'u:dev:MediaWiki:AnnouncementsIgnore.js', 'u:dev:MediaWiki:MobileEditor.js', 'u:dev:MediaWiki:ChromeToolbarColor.js', 'u:dev:MediaWiki:FindAndReplace/code.js', 'u:dev:MediaWiki:UserAndIPTools.js', 'u:dev:MediaWiki:QuickDiff/code.js' ],           sysop: [ 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:AjaxBatchDelete.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:Discussions Delete All/code.js', 'u:dev:MediaWiki:AjaxCommentDelete/code.js', 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:MediaWiki:CategoryRenameAuto-update/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js' ],           merge: function { var array; if ( /sysop|content-moderator|threadmoderator|bureaucrat/.test( config.wgUserGroups.join ) ) { array = imports.user.concat( imports.sysop ); } else { array = imports.user; }               return array; }       };        importArticles( {            type: 'script',            articles: imports.merge        } ); };   global.snippets = mw.loader.using( 'mediawiki.util', function {        $( '.wds-community-header__wiki-buttons a[data-tracking="wiki-activity"]' ).attr( { href: mw.util.getUrl( 'Special:Recentchanges' ), title: global.i18n( 'recentchanges' ) } );       $( 'a.external' ).attr( 'target', '_blank' );        $( '#wpLeaveRedirect' ).attr( 'checked', false );        $( '#mw-delete-table #wpReason' ).val( global.i18n( 'summary-delete', 'content' ) );    } ); global.init = function { $( document ).ready( function {           global.import;            global.snippets;        } ); };   global.init; } );