MediaWiki:CorrectForm.js

/* @ Created By Princess Platinum @ Some functions added by Jr Mime @ 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,   msg = messages = { get: function(name) { return (messages[_cr.language.toUpperCase]||messages['EN'])[name]; },       languages: { EN: 'English', CA: 'Català', DE: 'Deutsch', ES: 'Español', FR: 'Français', JA: '日本語', NL: 'Nederlands', PL: 'Polski', PT: 'Português' },   };

//English / default messages['EN'] = { button: "Create request", "save-wiki": "Wiki", "form-name": "Request Form", "form-header": "Title of the request:", "form-header-placeholder": "Replace this with the title", "form-language": "Language to correct:", "form-language-choose": "Choose language", "form-url": "URL of the wiki:", "form-information-header": "Information of your request:", "form-information-request": "More information on how to file in your request can be found at the top of the page.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Extra information", "form-extrainfo-placeholder": " — Don't forget to sign your post with " + _cr.signature + "!", }

// Catalan messages['CA'] = { button: "Nova soŀlicitud", "save-wiki": "Wiki", "form-name": "Forma de petició", "form-header": "Títol de la petició:", "form-header-placeholder": "Reemplaça això amb el títol", "form-language": "Idioma per corregir:", "form-language-choose": "Tria idioma", "form-url": "URL del wiki:", "form-information-header": "Informació de la teva petició:", "form-information-request": "Més informació de com fer la teva petició es pot trobar a la part superior de la pàgina.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Informació extra", "form-extrainfo-placeholder": " — No t'oblidis signar el teu post amb " + _cr.signature + "!", }

//German messages['DE'] = { button: "Korrekturanfrage stellen", "save-wiki": "Wiki", "form-name": "Formular", "form-header": "Anfragetitel:", "form-header-placeholder": "Geben Sie hier den Titel an", "form-language": "Language to correct:", "form-language-choose": "Sprache wählen", "form-url": "Wiki-URL hier angeben:", "form-information-header": "Informationen zur Anfrage:", "form-information-request": "Weitere Informationen darüber, wie das Formular auszufüllen ist können auf der Seite \"Correct\" gefunden werden.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Weitere Informationen", "form-extrainfo-placeholder": " — Don't forget to sign your post with " + _cr.signature + "!", // Needs translation }

//Spanish messages['ES'] = { button: "Nueva solicitud", "save-wiki": "Wiki", "form-name": "Formulario de solicitud de", "form-header": "Título de la petición:", "form-header-placeholder": "Sustituye esto con el título", "form-language": "Idioma para corregir:", "form-language-choose": "Elige idioma", "form-url": "Url de la wiki:", "form-information-header": "Información de tu petición:", "form-information-request": "Más información sobre como hacer tu petición se puede encontrar en la parte superior de la página.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Información extra", "form-extrainfo-placeholder": "  — No te olvides de signar tu post con " + _cr.signature + "!", }

//De la Fránçoissélemènte messages['FR'] = { button: "Nouvelle requête", "save-wiki": "Wiki", "form-name": "Formulaire de demande", "form-header": "Titre de votre requête:", "form-header-placeholder": "Remplacez ceci avec votre titre", "form-language": "Langue à corriger:", "form-language-choose": "Choisir une langue", "form-url": "L'URL du wiki:", "form-information-header": "Information de vôtre requête:", "form-information-request": "Plus d'information sur comment remplir votre requête ce retrouve en haut de cette page.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Information d'extra", "form-extrainfo-placeholder": " — N'oubliez pas de signer vôtre message avec " + _cr.signature + "!", }

//Japanese messages['JA'] = { button: "直すリクエストを新規作成", "save-wiki": "Wiki", // Needs translation "form-name": "伺い書", "form-header": "リクエストのタイトル", "form-header-placeholder": "こちらをタイトルに変更しなさい", "form-language": "Language to correct:", "form-language-choose": 'Choose language', //Needs translation "form-url": "項目:", "form-information-header": "リクエストの情報. ", "form-information-request": "リクエストの記入についての他の情報は、ページの上の方に書いています. ", "form-items": "その他の情報", "form-items-placeholder": "＜その他の情報を追加してください（任意）＞", "form-extrainfo": "placeholder", // Wat "form-extrainfo-placeholder": "placeholder", // Is this //  template: '\n\n\'\'\'ウィキ\'\'\'： \n\n\'\'\'項目 \'\'\'： \n\n\'\'\'その他の情報 \'\'\'： ＜その他の情報を追加してください（任意）＞ \n\n' + _cr.signature + '\n', }

//Dutch / Hollandsch messages['NL'] = { button: "Verbetering aanvragen", "save-wiki": "Wiki", "form-name": "Aanvraagformulier", "form-header": "Onderwerp van de aanvraag", "form-header-placeholder": "Vervang dit met het onderwerp", "form-language": "Language to correct:", "form-language-choose": "Kies taal", "form-url": "Plaats hier de url van de wiki:", "form-information-header": "Informatie over de aanvraag:", "form-information-request": "Meer informatie over hoe je de aanvraag kan invullen staat aan de bovenkant van de pagina.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Extra informatie", "form-extrainfo-placeholder": "<andere informatie (optioneel) — Don't forget to sign your post with " + _cr.signature + "!", // Needs translation }

//Polish or something messages['PL'] = { button: "Utwórz wniosek", "save-wiki": "Wiki", "form-name": "Formularz wniosku", "form-header": "Tytuł wniosku:", "form-header-placeholder": "Zastąp ten tytuł", "form-language": "Language to correct:", "form-language-choose": "Choose language", //Needs translation "form-url": "Podaj adres url wiki:", "form-information-header": "Informacje o Twoim wniosku:", "form-information-request": "Więcej informacji na temat plików, można znaleźć na górze strony.", "form-items": "Items", "form-items-placeholder": "", "form-extrainfo": "Dodatkowe informacje", "form-extrainfo-placeholder": " — Don't forget to sign your post with " + _cr.signature + "!", // Needs translation }

//Portuguese messages['PT'] = { button: "Novo pedido", "form-language-choose": 'Choose language', //Needs translation "save-wiki": "Wiki", "form-name": "Formulário de solicitação", "form-header": "Título do pedido:", "form-header-placeholder": "Substitui isto com o título", "form-language": "Language to correct:", "form-url": "Url da wiki:", "form-information-header": "Informação do teu pedido:", "form-information-request": "Mais informações sobre como fazer o teu pedido podem-se encontrar na parte superior da página.", "form-items": "Itens", "form-items-placeholder": "", "form-extrainfo": "Informação extra", "form-extrainfo-placeholder": " — Don't forget to sign your post with " + _cr.signature + "!", // Needs translation }

// Add buttons depending on user language if(_cr.pagename === 'Correct') { var buttonappend = '' + msg.get('button') + '</a>'; document.getElementById("lang-" + _cr.language.toUpperCase).innerHTML = buttonappend;

window.dropdown = '<select name="language" id="language" value="'+mw.config.get('wgUserLanguage').toUpperCase+'">'; dropdown += '<option value="" selected disabled>' + msg.get('form-language-choose') + ' '; for (var i in msg.languages) { dropdown += '<option value="'+i+'">'+msg.languages[i]+' '; }   dropdown += ' ';

// This opens the form for the users to fill out function openFormCorrect { $.showCustomModal(msg.get('form-name'), '<form class="WikiaForm" method="" name="" id="correctionForm"> ' + msg.get('form-header') + ' <input id="request-header" type="text" placeholder="' + msg.get('form-header-placeholder') + '" style="width: 450px"/> ' + msg.get('form-information-header') + ' <span title="' + msg.get('form-information-request') + '" style="cursor:help; float:right; font-size:12pt; border-bottom:1px dotted">[?]   ', {        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 { 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, page = ' \n\n\n\'\'\ + msg.get('save-wiki') + '\'\'\': ' + wikiurl + '\n\n\'\'\ + msg.get('form-items') + '\'\'\': ' + items + '\n\'\'\'' + msg.get('form-extrainfo') + '\'\'\': ' + extrainfo + '\n '; // 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; }   // Ajax URL var url = _cr.server + '/api.php?action=edit&title=' + encodeURIComponent(_cr.pagename) + '&section=new&sectiontitle=' + encodeURIComponent(header) + '&text=' + encodeURIComponent(page) + '&token=' + encodeURIComponent(_cr.edittoken); $.post(url, function {        window.location.reload;    }); setTimeout(cancelformCorrect, 1000); }