User:KockaAdmiralac/global.js

window.topLevelCat = 'Browse'; ajaxPages = ["Special:RecentChanges","Special:WikiActivity", "Special:Log", "Special:Log/upload", "Special:Contributions", "Special:NewWikis", "Special:AbuseLog"]; batchDeleteDelay = massCategorizationDelay = massProtectDelay = 10; window.AjaxCommentDeleteConfig = { fastDelete: "Deleting comment" };

var regularList = [ 'u:dev:MediaWiki:AjaxRC/code.js', 'u:dev:MediaWiki:CacheCheck/code.js', 'u:dev:MediaWiki:AjaxUndo/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:WallGreetingButton/code.js', 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:kocka:MediaWiki:VSTFReport/code.js' ], adminList = [ 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:MassCategorization/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:AjaxBatchDelete/code.2.js', 'u:kocka:MediaWiki:AjaxCommentDelete/code.js', 'u:kocka:MediaWiki:AjaxThreadDelete/code.js' ]; $(function {   /**     * Adding stuff to global navbar.     */    var username = mw.config.get('wgUserName'),    page = mw.config.get("wgPageName"),    globalLinks = {        "User": "User:" + username,        "Talk": "User_talk:" + username,        "Settings": "Special:Preferences",        "RC": "Special:RecentChanges",        "Admins": "Special:ListAdmins",        "Log off": "Special:UserLogout?returnto=" + page,        "Contribs": "Special:Contributions/" + username,        "Purge": page + "?action=purge",        "QQX": page + "?uselang=qqx"    }, linksContent = "";    for(var prop in globalLinks) linksContent += "" + prop + "";    $(".global-navigation-container").append(linksContent);    // Empty delete reason    if(mw.config.get('wgAction') && mw.config.get('wgAction') === 'delete') $("#wpReason").val(""); });

importArticles({ type: 'script', articles: (regularList.concat((wgUserGroups.includes("sysop") ? adminList : []))) });

/** * Name:       ListUntranslated * Version:    v1.0 * Author(s):  KockaAdmiralac <1405223@gmail.com> * Description: Lists untranslated articles */ $(function {	var ListUntranslated = {		allpages: [],		api: new mw.Api,		config: (window.ListUntranslatedConfig || {}),		translated: {},       languages: {},        languageModalContent: "",		init: function		{            mw.util.addCSS("#ListUntranslatedResults{height:400px;overflow-y:auto}");			this.i18n = this.config.vocab || {};			this.getNextPage;            this.getLanguages;            this.insertUI;		},		getNextPage: function(next)		{			this.api.get({ action: "query", list: "allpages", apnamespace: 0, aplimit: 5000, apfrom: next, apfilterredir: 'nonredirects' }).done(function(d) {				ListUntranslated.allpages = ListUntranslated.allpages.concat(d.query.allpages.map(function(el){ return el.title; })); if(d["query-continue"]) ListUntranslated.getNextPage(d["query-continue"].allpages.apfrom); else ListUntranslated.packPages; }).fail(function{ ListUntranslated.getNextPage(next); });		},       packPages: function        {            var packed = [], temp = [];            this.allpages.forEach(function(el) {               temp.push(el); if(temp.length === 50) {                   packed.push(temp.join("|")); temp = []; }           });            packed.push(temp.join("|"));            packed.forEach(function(el) { this.findTranslated(el); }, this);        },		findTranslated: function(pack, next)		{			this.api.get({ action: "query", prop: "langlinks", titles: pack, lllimit: 500, llcontinue: next }).done(function(d) {				for(var prop in d.query.pages) {					var page = d.query.pages[prop]; if(page.langlinks) ListUntranslated.translated[page.title] = page.langlinks.map(function(el){ return el.lang; }); }               // TO DO: Dunno what now }).fail(function{ ListUntranslated.findTranslated(pack, next); });		},       getLanguages: function        {            this.api.get({ action: "query", meta: "siteinfo", siprop: "languages" }).done(function(d) {               d.query.languages.forEach(function(el)                {                    if(!ListUntranslated.languages[el['*']] && el.code !== mw.config.get('wgContentLanguage'))                    {                        ListUntranslated.languages[el['*']] = el.code;                        ListUntranslated.languageModalContent += " " + el['*'] + " ";                    }                }); }).fail(function{ ListUntranslated.getLanguages; });       },		insertUI: function		{            // TO DO: Do the same thing for Monobook            if(typeof skin !== 'undefined' && skin === "oasis") $("#my-tools-menu").append("" + (this.i18n.untranslated || "Non-translated pages") + "");            $("#ListUntranslatedButton").click(this.showModal);		},		showModal: function		{			$.showCustomModal(ListUntranslated.i18n.untranslated || "Non-translated pages", " " + (ListUntranslated.i18n.language || "Language") + "" + ListUntranslated.languageModalContent + "  ", {               id: "ListUntranslatedModal", width: ListUntranslated.config.modalWidth || 500, buttons: [{ id: "ListUntranslatedExecuteButton", defaultButton: true, message: ListUntranslated.i18n.execute || "Execute", handler: function {                       var content = "", lang = ListUntranslated.languages[$("#ListUntranslatedLanguage").val]; for(var prop in ListUntranslated.translated) if(!ListUntranslated.translated[prop].includes(lang)) content += "" + prop + ""; $("#ListUntranslatedResults").html(content); }               },                {                    id: "ListUntranslatedCloseButton", defaultButton: true, message: ListUntranslated.i18n.close || "Close", handler: function { $("#ListUntranslatedModal").closeModal; } }]           });		}	};    $(ListUntranslated.init); });