User:S33L/scripts/easycreate.js

/**********************/ /* PageMakerPro. */ /* Written by: S33L. */ /* License: GPL v2. */ /**********************/ (function ($, mw, window) {

var messages = { formTitle: "Create a New Page", formStart: "Create", formPage: "Special:New_Page", formMain: "Main", formCat: "Category", formMW: "MediaWiki", formTemp: "Template", formCont: "Page Content", formBlank: "Blank", };

/* Variables for use in the script */ var page = mw.config.get("wgPageName"); var fHTML = '' + ' ' + messages.formTitle + ' ' + '' + messages.formMain + ' ' + '' + messages.formCat + ' ' + '' + messages.formMW + ' ' + '' + messages.formTemp + ' ' + ' ' + '

' + messages.formStart + ' ';

if (page != messages.formPage) { $("#p-tb-list").append('' + i18n[lang].formTitle + ''); } else { makePage; }

function makePage { $("title").text("Page Create"); $("#bodyContent").html(fHTML); $("#create-button").click(function {            redirectWindow;        }); }

function redirectWindow { var namespace = $("input[name=namespace]:checked").val; var target = $("#NewPageTitle").val; var link;

switch (namespace) { case "main": link = 'http://en.wikisource.org/w/' + target + '?action=edit'; break; case "category": link = 'http://en.wikisource.org/w/Category:' + target + '?action=edit'; break; case "mediawiki": link = 'http://en.wikisource.org/w/MediaWiki:' + target + '?action=edit'; break; case "template": link = 'http://en.wikisource.org/w/Template:' + target + '?action=edit'; break; default: break; }

window.location = link; } }(this.jQuery, this.mediaWiki, this));