MediaWiki:CorrectForm-i18n-js.js

/* @ Created By Lil' Miss Rarity, customized by Joeytje50 (i18n compatibility upgrade and dropdown languages) @ further customised by sactage for compatibility with i18n.js @ Some functions added by Jr Mime (pop-up layout, variables) @ Adds a pop up modal form for wlb.wikia.com @ License: CC-BY-NC-SA @ License Jurisdiction: International */

// Variables for later on // Keep these in an object for organization var _cr = { edittoken: mw.user.tokens.values.editToken, namespace: mw.config.get('wgNamespaceNumber'), pagename: mw.config.get('wgPageName'), server: mw.config.get('wgServer'), signature:  + , language: mw.config.get('wgUserLanguage') };

var $ = this.jQuery, mw = this.mediaWiki, i;

i18n.registerMessages('correctform',   ['correctform-button',        'correctform-save-wiki',        'correctform-community-url',        'correctform-form-name',        'correctform-form-header',        'correctform-form-header-placeholder',        'correctform-form-language',        'correctform-form-language-choose',        'correctform-form-url',        'correctform-form-information-header',        'correctform-form-information-request',        'correctform-form-items',        'correctform-form-items-placeholder',        'correctform-form-extrainfo',        'correctform-form-extrainfo-placeholder',        'correctform-form-signature']); i18n.require('correctform');

// Add buttons depending on user language if(_cr.pagename === 'Correct:FakeRequests') { var buttonappend = '' + mw.msg('correctform-button') + ''; document.getElementById("lang-" + _cr.language.toUpperCase).innerHTML = buttonappend;

window.dropdown = ''; dropdown += '' + mw.msg('correctform-form-language-choose') + ' '; for (var i in i18n.languages) { dropdown += ''+i18n.languages[i]+' '; }   dropdown += ' ';

// This opens the form for the users to fill out

function openFormCorrect { $.showCustomModal(mw.msg('correctform-form-name'), ' ' + mw.msg('correctform-form-header') + '   ' + mw.msg('correctform-form-information-header') + ' [?]   ', {            id: "requestWindow",            width: 650,            buttons: [{                id: "cancel",                message: "Cancel",                handler: function  {                    cancelformCorrect;                }            }, {                id: "submit",                defaultButton: true,                message: "Submit",                handler: function  {                    submitformCorrect; }           }]        });    } }

// Closes the form

function cancelformCorrect { $("#requestWindow").closeModal; }

// Submits the form

function submitformCorrect { console.log('Starting to submit...'); var $form = $('#correctionForm'), header = $form.find('#request-header').val, lang = $form.find('#language').val, wikiurl = $form.find('#wiki-url').val, items = $form.find('#items').val, extrainfo = $form.find('#extrainfo').val, signatureplace = $form.find('#signature-place').val, page = '\n\n\n\'\'\'\'\'\': w:c:' + wikiurl + '\n\n\'\'\'\'\'\': ' + items + '\n\n\'\'\'\'\'\': ' + extrainfo + '\n\n\'\'\'\'\'\': ' + signatureplace; // Making sure the header isnt blank, and a language has been filled in   if (!header) { alert("Please title your request!"); return; }   if (!lang) { alert('Please select a language!'); return; }   console.log('Performed checks...');

// Ajax URL var url = _cr.server + '/api.php?action=edit&title=Correct:' + encodeURIComponent(header) + ' (' + encodeURIComponent(lang) + ')&text=' + encodeURIComponent(page) + '&summary=New+correct+request+(' + encodeURIComponent(lang) + ')&token=' + encodeURIComponent(_cr.edittoken); console.log('Got the url: ',url);

$.post(url, function (r) {       console.log('Should be done now:',r);        cancelformCorrect;        window.location.reload;    }); console.log('Sent request...'); }