User:Alex Gn./global.js

//—————————————————————————————— ! ! ! ———————————————————————————————// /* Import scripts. NOTE: Place scripts configurations above this line */ /* Scripts */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:MediaWiki:AjaxDelete/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:View_Source/code.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:PurgeButton/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:DisplayClock/code.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:ExternalImageLoader/code.js', 'u:dev:MediaWiki:ListFiles/code.js', 'u:dev:MediaWiki:MultipleFileDelete/code.js', 'u:dev:MediaWiki:QuickComments/code.js', 'u:dev:MediaWiki:UnsafeScripts/code.js', 'u:dev:MediaWiki:QuickThreads/code.js', 'u:dev:MediaWiki:AjaxBlock/code.js', 'u:dev:MediaWiki:AjaxBatchUndelete/code.js', 'u:dev:MediaWiki:AjaxBatchDelete/code.js', 'u:dev:MediaWiki:AjaxThreadUnfollow/code.js', 'u:dev:MediaWiki:MassBlock/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:MassUserRights/code.js' ]   }); }); /* Update site staff avatars */ window.avatars = {}; function getURL(user) { $.get("/wiki/Special:Contributions/" + user + "?useskin=oasis", function(data) {       window.avatars[user] = //ig.exec(data)[1] + '';    }); } if ( wgPageName == "Peridot_Wikia:Site_Staff" || wgPageName == "Stevidot_Wikia:Site_Staff" || wgPageName == "Navid_Wikia:Site_Staff" ) { $(window).load(function {       $('.wikinav2 .WikiaPageHeader').css('padding-right', '0');        $('#WikiaPageHeader .comments').after( 'Update avatars ' );       $('#update-avatars').click(function { var usrs = []; var matches; var PC; var pageNewContent; $('.staff-usr-template').each(function {               usrs.push($(this).text.trim);            }); var API = new mw.Api; API.get({               action: 'query',                prop: 'revisions',                rvprop: 'content',                titles: wgPageName            }).done(function(data) {                for (var i in data.query.pages) {                    PC = data.query.pages[i].revisions[0]['*'];                    page = data.query.pages[Object.keys(data.query.pages)[0]];        		}                matches = PC.match(/\|(\s+|)link(\s+|)=(\s+|).+/gi);                pageNewContent = PC;                for (var i in matches) {                    matches[i] = matches[i].split('=')[1].trim;                }                for (var i in usrs) {                    if (usrs[i] !== '') {                        getURL(usrs[i]);                    }                }                setTimeout(function { for (var i in usrs) { if (usrs[i] !== '') { usrs[i] = window.avatars[usrs[i]]; usrs[i] = usrs[i].replace('static', 'images1') + '/scale-to-width-down/' + matches[i].split('/scale-to-width-down/')[1]; }                   }                    for (var i in usrs) { if (usrs[i] !== '') { pageNewContent = pageNewContent.replace(matches[i], usrs[i]); }                   }                    if ( PC != pageNewContent ) { var config = { 'minor': 'yes', 'bot': 'yes', 'summary': 'Updating user avatars. (automatic)', 'action': 'edit', 'title': wgPageName, 'token': mw.user.tokens.get('editToken'), 'text': pageNewContent };                       $.ajax({                            url: mw.util.wikiScript('api'),                            data: config,                            dataType: 'json',                            type: 'POST',                            success: function(d) {                                if (!d.error) {                                    new BannerNotification('Avatars successfully updated!', 'confirm').show;                                } else {                                    new BannerNotification('Failed while updating avatars: ' + d.error.code, 'error').show;                                }                            }                        }); } else { new BannerNotification('No avatars to update.', 'error').show; }               }, 7000);            });        });    }); }