User:Americhino/global.js

if (mw.config.get('wgCityId') === '177' || mw.config.get('wgCityId') === '7931') { importArticles({       type: 'script',        articles: [            'u:dev:MediaWiki:FANSUN.js',        ],        type: 'style',        articles: [            'u:dev:MediaWiki:FANSUN.css',        ]    }); } // Adding favorite wikis to menu dropdown; forking code by Fandyllic var adminWikis = { calvinandhobbes: 'Calvin and Hobbes Wiki', paladins: 'Paladins Wiki', americhino: 'Americhino Wiki', dev: 'FANDOM Open Source Library', }; $(function {	'use strict';    $('.wds-global-navigation__link-group .wds-dropdown__content').addClass('wds-is-not-scrollable');    /* Don't try to add Admin Wikis menu, if it appears to already exist */	if (!window.adminWikis || $('#AdminWikis').length) {		return;	}    /* Start building My Favorite Wikis menu */	var $adminWikisList = $('').addClass('wds-list wds-is-linked');	var $adminWikis = $('')		.attr('id', 'AdminWikis')		.addClass('wds-dropdown-level-2')		.append( $('') .attr('href', '#') .addClass('wds-dropdown-level-2__toggle') .attr('data-tracking', 'custom-level-2') .append(					$(' ').text('Admin'),					$(' ')				), $(' ')				.addClass('wds-is-not-scrollable wds-dropdown-level-2__content') .append($adminWikisList) );   // Add links from admin wikis list	Object.keys(window.adminWikis).forEach(function (key) { $adminWikisList.append(			$('').append( $('') .attr('href', '//' + key + '.wikia.com/') .attr('target', '_blank') .text(window.adminWikis[key]) )		)	});	// Add "Block" button to admin wikis list   if (wgCityId === 680, 1304663, 1452453) {        $adminWikisList.append( $('').append(   			$('')    				.attr('href', '/wiki/Special:Block/')    				.attr('target', '_blank')    				.attr('id', 'AdminBlockButton')    				.addClass('wds-button wds-is-secondary wds-global-navigation__link-button')    				.text('Block')    		) );   	$('#NotAdminBlockButton').remove;    } else {    	$adminWikisList.append( $('').append(   			$('')    				.attr('target', '_blank')    				.attr('id', 'NotAdminBlockButton')    				.addClass('wds-button wds-is-secondary wds-global-navigation__link-button wds-is-disabled')    				.text('Block')    		) );   	$('#AdminBlockButton').remove;    }    /* Add completed fav wikis (favWikis) HTML blob to profile menu */	$('div.wds-global-navigation__link-group > div.wds-dropdown__content > ul.wds-list > li:first-child')		.before($adminWikis); }); /* Start a Wiki Icon; thank you Speedit */ mw.hook('dev.wds').add(function(wds) {   $('.wds-global-navigation__link-button[data-tracking-label="start-a-wiki"]').html((function(i) {        i.setAttribute('fill', '#ccc !important');        return i;    }(wds.icon('add-small')))); }); /* Share icon */ /* $('#ShareEntryPoint').empty; mw.hook('dev.wds').add(function(wds) {   $('#ShareEntryPoint').html((function(i) {        return i;    }(wds.icon('share-small')))); }); */ /* @submodule              UserStatus/dropdown * @description            Dropdown menu to quickly change one's status. * @author                 Americhino * @version                1.0.1 * @license                CC-BY-SA 3.0 */ var $user = mw.config.get('wgTitle').split('/'); // if (($user[1] ? $user[1] : $user[0]) === mw.config.get('wgUserName')) { mw.hook('dev.i18n').add(function (i18n) {       i18n.loadMessages('UserStatus').done(function (i18n) { $.ajax({               method: 'GET',                dataType: 'text',                url: mw.util.wikiScript('index'),                data: {                    title: wgFormattedNamespaces[2] + ':' + mw.config.get('wgUserName') + '/status',                    action: 'raw'                },                complete: function (data) {                    // Variables                    var config = window.UserStatusSettings || {};                    // Limit responses to valid statuses                    var status = ['online', 'away', 'dnd', 'offline'].indexOf(data.responseText) === -1                        ? i18n.msg('unknown').plain                        : data.responseText;                    var status_color = {                        'online': config.online || '#43b581',                        'away': config.away || '#faa61a',                        'dnd': config.dnd || '#f04747', 'offline': config.offline || '#747f8d', 'unknown': config.offline || '#747f8d', };                   var $statusLink = $(' ') .addClass('wds-global-navigation__link-group wds-dropdown') .attr('id', 'StatusChangeGlobal').append(                               $(' ')                                    .attr('id', 'StatusToggleGlobal')                                    //.css('align-items', 'center')                                    //.css('display', 'flex')                                    //.css('flex', '1 1 auto')                                    //.css('height', '100%')                                    .addClass('wds-global-navigation__link-group wds-dropdown__toggle')                                    .append( $(' ')                                           .css('background', status_color[status]) .css('border-radius', '50%') .css('height', '20px') .css('width', '20px') .attr('id', 'StatusIndicatorGlobal') )                                   .append( $(' ') .addClass('wds-dropdown__toggle-chevron') )                       );                    var $statusDropdown = $(' ').addClass('wds-is-not-scrollable wds-dropdown__content').append(                                        $(' ')                                            .addClass('wds-list wds-is-linked')                                            .attr('id', 'StatusMenuGlobal')                                             .append( $(' ').append(                                                   $('')                                                    .attr('target', '_blank')                                                    .attr('style', 'cursor: pointer;')                                                    .attr('id', 'StatusMenuGlobal-online')                                                    .text(i18n.msg('online').plain)                                                ))                                            .append( $(' ').append(                                                   $('')                                                    .attr('target', '_blank')                                                    .attr('style', 'cursor: pointer;')                                                    .attr('id', 'StatusMenuGlobal-away')                                                    .text(i18n.msg('away').plain)                                                ))                                            .append( $(' ').append(                                                   $('')                                                    .attr('target', '_blank')                                                    .attr('style', 'cursor: pointer;')                                                    .attr('id', 'StatusMenuGlobal-dnd')                                                    .text(i18n.msg('dnd').plain)                                                ))                                            .append( $(' ').append(                                                   $('<a />')                                                    .attr('target', '_blank')                                                    .attr('style', 'cursor: pointer;')                                                    .attr('id', 'StatusMenuGlobal-unknown')                                                    .text(i18n.msg('offline').plain)                                            ) )                                );                     if (mw.config.get('wgVersion') !== '1.19.24') { $('.wds-global-navigation__notifications-dropdown').after($statusLink); } else { $('#notificationsEntryPoint').after($statusLink); }                   $('#StatusToggleGlobal').after($statusDropdown); $('body').on('click', 'a[id^="StatusMenuGlobal-"]', function(e) {                       e.preventDefault;                        var content;                        switch ($(e.target).attr('id')) {                            case 'StatusMenuGlobal-online':                                content = 'online';                                break;                            case 'StatusMenuGlobal-away':                                content = 'away';                                break;                            case 'StatusMenuGlobal-dnd':                                content = 'dnd';                                break;                            case 'StatusMenuGlobal-unknown':                                content = 'offline';                                break;                        }                    $.ajax({ type: 'POST', url: mw.util.wikiScript('api'), dataType: 'json', data: { action: 'edit', title: wgFormattedNamespaces[2] + ':' + wgUserName + '/status', summary: '[UserStatus] ' + i18n.msg('edit-status').plain, text: content, format: 'json', token: mw.user.tokens.get('editToken') }                   }).done(function (data) { if (data.edit.result === 'Success') { if (mw.config.get('wgVersion') !== '1.19.24') { mw.loader.using('mediawiki.notify').then(function {                                    mw.notify(i18n.msg('success').plain);                                    console.log('[UserStatus]' + i18n.msg('success').plain);                                }); } else { new BannerNotification (i18n.msg('success').plain, 'confirm').show; }                       } else { if (mw.config.get('wgVersion') !== '1.19.24') { mw.loader.using('mediawiki.notify').then(function {                                    mw.notify(i18n.msg('error').plain);                                    console.log('[UserStatus]' + i18n.msg('error').plain);                                }); } else { new BannerNotification (i18n.msg('error').plain, 'error').show; }                       }                    }).fail(function (data) { if (mw.config.get('wgVersion') !== '1.19.24') { mw.loader.using('mediawiki.notify').then(function {                                    mw.notify(i18n.msg('error').plain);                                    console.log('[UserStatus]' + i18n.msg('error').plain);                                }); } else { new BannerNotification (i18n.msg('error').plain, 'error').show; }                   });                });                }            });        });    });    mw.util.addCSS('#StatusChangeGlobal{margin-left:12px}#StatusChangeGlobal .wds-dropdown__content{min-width:140px !important}');    window.importArticles({ type: 'script', articles: ['u:dev:MediaWiki:I18n-js/code.js'] }); // } /* Imports */ importArticles({ type: 'script', articles: [ 'u:dev:MediaWiki:UserAccountAge/code.js', 'u:dev:MediaWiki:MastheadGender/code.js', 'u:dev:MediaWiki:LastEdited/code.js', 'u:dev:MediaWiki:ContribsLink/code.js', 'u:dev:MediaWiki:VSTFReport.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:QuickDiff/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:MassEdit/code.js', 'u:dev:MediaWiki:PreferenceLinks.js', // end of ucp and legacy working 'u:community:User:Americhino/AdminTools.javascript', // works on legacy 'u:community:User:Americhino/DevTools.javascript', // works on legacy 'u:dev:MediaWiki:MastheadRightsBadge.js', 'u:dev:MediaWiki:WDSIcons/code.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:PortableListUsers.js', 'u:dev:MediaWiki:ContribsButtons.js', 'u:dev:MediaWiki:MinimalTestModeAlert.js', // Unknown compatibility from this point on       'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:WorkingMoreUsersCount.js', 'u:dev:MediaWiki:FandomizedWikiFeatures/adaptable.js', 'u:dev:MediaWiki:QuickLogs/code.js', 'u:dev:MediaWiki:EditConflictAlert/code.js', 'u:dev:MediaWiki:CodeLinksDropdown.js', // MY SCRIPT FIX IT        'u:dev:MediaWiki:SeeMoreActivityButton/code.js', 'u:dev:MediaWiki:FindAndReplace/code.js', 'u:dev:MediaWiki:SandboxLink/code.js', 'u:dev:MediaWiki:AjaxBlock/code.js', 'u:dev:MediaWiki:MassRename/code.js', 'u:dev:MediaWiki:MassRenameRevert/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:ViewDeleted/code.js', 'u:dev:MediaWiki:MassRedirect/code.1.js', 'u:dev:MediaWiki:CleanWantedFiles/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:AjaxBatchUndelete.js', 'u:dev:MediaWiki:NotesModule/code.js', ] });