User:Jr Mime/Request button.js

$('header.WikiaPageHeader').append(" Message");

//Variables var $ = this.jQuery, mw = this.mediaWiki, wgPageName = mw.config.get('wgPageName'), wgServer = mw.config.get('wgServer'), wgScriptPath = mw.config.get('wgScriptPath'), EditToken = mw.user.tokens.values.editToken, PageID = mw.config.get('wgArticleId'), Namespace = mw.config.get('wgNamespaceNumber'), Signature =  + ;

// Message function openWindow { if (Namespace === 0) { var windowHTML = $.showCustomModal("Request Form", ' Request title:   Information \nItems: \nExtra information: \n~  ~">   ', {            id: "requestWindow",            width: 600,            buttons: [                {                id: "cancel",                message: "Cancel",                handler: function {                    cancelChanges;                }            },                {                id: "submit",                defaultButton: true,                message: "Submit",                handler: function {                    submitForm; }           }            ]        });    } else {        alert("This function is for use on mainspace only!");    } } function cancelChanges {    $('#requestWindow').closeModal; } function submitForm {    var header = document.getElementById("request-header").value || 'null',        body = document.getElementById("request-body").value || 'null';    if (header === 'null' || body === 'null') {        alert("Please fully fill out this request!");        return;    } else {        var editToken = mw.user.tokens.values.editToken;        var url = wgServer + '/api.php?action=edit&title=' + encodeURIComponent(wgPageName) + '&section=new&sectiontitle=' + encodeURIComponent(header) + '&text=' + encodeURIComponent(body) + '&token=' + encodeURIComponent(editToken);        $.post(url, function { $('#requestWindow').closeModal; window.location.reload; });   } }