MediaWiki:Wikia.js

/* @ By Princess Platinum @ Adds a pop up modal form for wlb.wikia.com @ License: CC-BY-NC-SA @ License Jurisdiction: International

//First we will declare the variables used throughout the script //Lets define jQuery and mediaWiki var $ = this.jQuery, mw = this.mediaWiki;

//To avoid frustration var template; var lang; var button;

//Now for the others, we'll keep them in an object for organization var wlb = { edittoken: mw.user.tokens.values.editToken, namespace: mw.config.get('wgNamespaceNumber'), pagename: mw.config.get('wgPageName'), server: mw.config.get('wgServer'), signature:  +  };

//The translation button text var buttontext = ["Create New Request", "Učinite zahtjev", "Crear una nova sol · licitud", "Neue Anfrage Stellen", "Crear una nueva solicitud", "Créer une nouvelle requête", "Créer nouvelle demande", "No Button Translation", "Buat Permintaan New", "Maken Nieuw Aanvraag", "Utwórz nowe"];

//This function makes sure the script doesn't check for the tag before it is loaded $('.tabs').click(function {   lang = $('div.selected').find('.wlb-langcode').html;    setTimeout(makeButton, 1500); });

function makeButton { //We will get the different values from here switch (window.lang) { case "EN": button = buttontext[0]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Items\'\'\': \n\n\'\'\'Extra information\'\'\': \n\n' + wlb.signature + '\n'; break; case "BS": return; break; case "CA": button = buttontext[2]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Items\'\'\': \n\n\'\'\'Informació extra\'\'\': \n\n' + wlb.signature + '\n'; break; case "DE": button = buttontext[3]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Elemente\'\'\': \n\n\'\'\'Extrainformationen\'\'\': \n\n' + wlb.signature + '\n'; break; case "ES": button = buttontext[4]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Items\'\'\': \n\n\'\'\'Extra information\'\'\': \n\n' + wlb.signature + '\n'; break; case "FR": button = buttontext[5]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Items\'\'\': \n\n\'\'\'Information d\'extra\'\'\': ' + wlb.signature + '\n'; break; case "IT": return; break; case "JA": button = buttontext[7]; template = '\n\n\'\'\'ウィキ\'\'\'： <ウィキのURLを入力してください>\n\n\'\'\'項目 \'\'\'： <翻訳をお願いしたい項目 (3つまで)>\n\n\'\'\'その他の情報 \'\'\'： ＜その他の情報を追加してください（任意）＞ \n\n' + wlb.signature + '\n'; break; case "MS": button = buttontext[8]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Sumber\'\'\': \n\n\'\'\'Maklumat tambahan\'\'\': <masukkan maklumat tambahan sini (tidak wajib diisi~)>\n\n' + wlb.signature + '\n'; break; case "NL": button = buttontext[9]; template = '\n\n\'\'\'Wiki\'\'\': <plaats hier de url van de wiki>\n\n\'\'\'Items\'\'\': <te vertalen pagina\'s (tot 3)>\n\n\'\'\'Extra informatie\'\'\': <andere informatie (optioneel)>\n\n' + wlb.signature + '\n'; break; case "PL": button = buttontext[10]; template = '\n\n\'\'\'Wiki\'\'\': \n\n\'\'\'Elementy\'\'\': <elementy do przetłumaczenia (do 3)>\n\n\'\'\'Dodatkowe informacje\'\'\': <wpisz dodatkowe informacje (opcjonalnie)>\n\n' + wlb.signature + '\n'; break; default: return; break; }	//Creates the button with the specified text $('.wlb-button').html('<a class="wikia-button" id="wlb-submit" onclick="openForm">' + button + '</a>'); }

//This opens the form for the users to fill out function openForm { $.showCustomModal("Request Form", '<form class="WikiaForm" method="" name=""> Title of the request: <input id="request-header" type="text" placeholder="Replace this with the title" style="width: 500px"/>  Information of your request. More information on how to file in your request can be found on top of the page. <textarea id="request-body" cols="80" rows="10">' + window.template + '   ', { id: "requestWindow", width: 650, buttons: [ { id: "cancel", message: "Cancel", handler: function { cancelform; } }, { id: "submit", defaultButton: true, message: "Submit", handler: function { submitform; setTimeout(cancelform, 1000); } } ] }); }

//Closes the form function cancelform { $("#requestWindow").closeModal; }

//Submits the form function submitform { var header = document.getElementById( "request-header" ).value || 'null', body = document.getElementById( "request-body" ).value, page = ' ' + body + ' ';

//Making sure the header isn't blank if (header === 'null') { alert("Please title your request!"); return; }

//Ajax URL var url = wlb.server + '/api.php?action=edit&title=' + encodeURIComponent(wlb.pagename) + '/' + encodeURIComponent(window.lang) + '&section=new&sectiontitle=' + encodeURIComponent(header) + '&text=' + encodeURIComponent(page) + '&token=' + encodeURIComponent(wlb.edittoken);

$.post(url, function {	window.location.reload;   }); }

$(function { setTimeout(makeButton, 3000); } );