MediaWiki:PageMakerPro/code.js

/************************************/ /* PageMakerPro. */ /* Written by: Prince(ss) Platinum. */ /* License: GPL v2. */ /************************************/ (function ($, mw, window) {   /***************************************************/    /* i18n: Please contribute translations here only! */    /***************************************************/    var i18n = {        "en": {            formTitle: "Create a New Page",            formStart: "Create",            formCancel: "Close",            formPage: "Special:New_Page",            formMain: "Main",            formBlog: "Blog",            formCat: "Category",            formMW: "MediaWiki",            formTemp: "Template",            formCont: "Page Content",            formBlank: "Blank",            formPop: "Populated",            urlBlog: "User-blog"        }    };    /****************************************************/    /* End of i18n. Please don't change anything below. */    /****************************************************/ /* Variables for use in the script */ var server = mw.config.get("wgServer"); var skin = mw.config.get("skin"); var lang = mw.config.get("wgUserLanguage"); var page = mw.config.get("wgPageName"); var formHTML = '  ' + i18n[lang].formMain + ' ' + i18n[lang].formBlog + ' ' + i18n[lang].formCat + ' ' + i18n[lang].formMW + ' ' + i18n[lang].formTemp + '    ' + i18n[lang].formCont + ': ' + i18n[lang].formBlank + ' ' + i18n[lang].formPop + '

';   if (skin == "oasis" || skin == "wikia") { $("nav.contribute").find("ul").append('Create Page(beta)').click(function (e) {           makeForm;        }); } else { if (page != i18n[lang].formPage) { $(".p-body").find("ul").append('' + i18n[lang].formTitle + '</li>'); } else { makePage; }   }    function makeForm { $.showCustomModal(i18n[lang].formTitle, formHTML, {           id: "page-create",            width: 650,            buttons: [{                id: "page-create-close",                message: i18n[lang].formCancel,                handler: function  {                    $("#page-create").closeModal;                }            }, {                id: "page-create-go",                defaultButton: true,                message: i18n[lang].formStart,                handler: function  {                    redirectWindow;                }            }]        }); }   function makePage { $("title").text("Page Create"); $("#bodyContent").html(formHTML); var node = document.createElement("button"); node.id = "page-create-monobook"; node.textContent = i18n[lang].formStart; node.addEventHandler("click", function {            redirectWindow;        }); $("#page-create-fieldset").append($(node)); $("#page-create-monobook").css("float", "right"); }   function redirectWindow { var namespace = $("input[name=namespace]:checked").val; var target = $("#NewPageTitle").val; var populated = $("input[name=pagecontent]:checked").val; var link; switch (namespace) { case "main": if (populated == "populated") { link = server + '/wiki/' + target + '?action=edit&useFormat=1'; } else { link = server + '/wiki/' + target + '?action=edit'; }           break; case "blog": link = server + '/wiki/' + i18n[lang].urlBlog + '' + target + '?action=edit'; break; case "category": link = server + '/wiki/' + i18n[lang].formCat + '' + target + '?action=edit'; break; case "mediawiki": link = server + '/wiki/' + i18n[lang].formMW + '' + target + '?action=edit'; break; case "template": link = server + '/wiki/' + i18n[lang].formTemp + '' + target + '?action=edit'; break; default: break; }       window.location = link; } }(this.jQuery, this.mediaWiki, this));