MediaWiki:ChatDeveloperTools.js

/* ChatDeveloperTools.js is a script made for active Wikia editors and coders. * It's planned to have all necessary and handy tools in one modal window. * Author: Lady Furude * * If you've got a suggestion or found a bug, contact Lady Furude! */

$(function {   "use strict";    var ChatDeveloperTools = {        createLink: function(link, title) {            return $("", { href: (function {                   if (link.indexOf("global") !== -1) {                        return "https://community.wikia.com/wiki/Special:MyPage/" + link;                    } else if (link.indexOf("MediaWiki") !== -1) {                        return mw.util.getUrl(link);                    } else {                        switch(link) {                            case "User": return mw.util.getUrl("Special:MyPage");                            case "Talk": return mw.util.getUrl("Special:MyTalk");                            case "Contribs": return mw.util.getUrl("Special:Contributions");                            case "UserActivity": return "https://community.wikia.com/wiki/Special:UserActivity";                            case "SpecialPages": return mw.util.getUrl("Special:SpecialPages");                            case "WikiActivity": return mw.util.getUrl("Special:WikiActivity"); case "RecentChanges": return mw.util.getUrl("Special:RecentChanges"); default: return mw.util.getUrl("Special:MyPage/") + link; }                   }                }),                target: "_blank",                text: title            }); },       createSection: function(obj) { var collection = [], counter = 0; for (var key in obj) { collection.push(this.createLink(key, obj[key])); counter++; if (counter !== Object.keys(obj).length) { collection.push(", "); }           }            return collection; },       createSectionsObject: function { return { "User Files": { User: "My Profile", Sandbox: "My Sandbox", Talk: "My Talk Page", Contribs: "My Contributions", UserActivity: "My Activity" },               "Special Pages": { SpecialPages: "All Special Pages", WikiActivity: "Recent Wiki Activity", RecentChanges: "Recent Changes" },               "MediaWiki Common Files": { "MediaWiki:Common.js": "MW:Common JS", "MediaWiki:Common.css": "MW:Common.CSS" },               "MediaWiki Oasis Skin Files": { "MediaWiki:Wikia.js": "MW:Wikia JS", "MediaWiki:Wikia.css": "MW:Wikia.CSS" },               "MediaWiki Chat Files": { "MediaWiki:Chat.js": "MW:Chat JS", "MediaWiki:Chat.css": "MW:Chat.CSS" },               "User Common Files": { "common.js": "Common JS", "common.css": "Common CSS" },               "User Global Files": { "global.js": "Global JS", "global.css": "Global CSS" },               "User Oasis Skin Files": { "Wikia.js": "Wikia JS", "Wikia.css": "Wikis CSS" },               "User Chat Files": { "chat.js": "Chat JS", "chat.css": "Chat CSS" }           };        },        createContent: function { var sections = [], sectionsObj = this.createSectionsObject; for (var key in sectionsObj) { sections.push(this.createSection(sectionsObj[key])); }           return sections; },       fillUpContent: function(element) { var sections = this.createContent, sectionsObj = this.createSectionsObject, counter = 0; var $div; for (var key in sectionsObj) { $div = element.append(                   $(" ").append( $("", {text: key}), ": ", sections[counter] )               );                counter++; if (counter !== Object.keys(sectionsObj).length) { $div.append($(" ")); }           }            return $div; },       showModal: function { $.showCustomModal(               "Chat Developer Tools",                this.fillUpContent($(" ")),                {                    id: "WikiaDeveloperTools"                }            ).css({                width: "550px",                overflow: "auto",                height: "285px",                "margin-left": "-283px"            }); }   };    mw.hook("dev.chat").add(function(chat) {        new chat.Button({ name: "DevTools", attr: { text: "Tools", click: function { ChatDeveloperTools.showModal; }           }        });    });    importArticle({        type: "script",        article: "u:dev:Chat-js.js"    }); });