MediaWiki:WOTW nomination.js

/* work in progress */ /* 	@ Created By Lil' Miss Rarity, customized by Joeytje50 (i18n compatibility upgrade and dropdown languages) @ Some functions added by Jr Mime (pop-up layout, variables) @ Adds a pop up modal form for spotlights @ License: CC-BY-NC-SA @ License Jurisdiction: International */	// Variables for later on	// Keep these in an object for organization var $ = this.jQuery, mw = this.mediaWiki, i, msg = messages = { get: function(name) { return (messages[_kt.language.toUpperCase]||messages['EN'])[name]; },			languages: { AR: 'ar - العربية', CS: 'cs - Česky', DA: 'da - Dansk', FA: 'fa - فارسی', HU: 'hu - Magyar', ID: 'id - Bahasa Indonesia', MS: 'ms - Malay', NN: 'nn - ‪Norsk (nynorsk)‬', NO: 'no - Norsk (bokmål)‬', SV: 'sv - Svenska', TR: 'tr - Türkçe', XX: 'Other' },		};

// imports _api.* importScriptPage("MediaWiki:ApiKey.js", "wlb"); // English / default messages['EN'] = { "button-open": "Click here to add a new request", "button-close": "Click here to close the request", "form-language-choose": "Choose language", }	function hideForm { $('#request-form').fadeOut; setTimeout(function {				$('#request-form').remove;				console.log("Form removed successfully");			}, 1000); }	// This opens the form for the users to fill out function openFormWOTW { $("#wotw-nominate").after(' Nominate Word of the Week '		+ 'Word in your language: '		+ ' '		+ 'Your language: '		+ ' '		+ 'Translation (English): '		+ ' Nominate! Cancel '); $('#spotlight-submit').text(msg.get('button-close')); $('#spotlight-submit').removeAttr("onclick").attr("onclick", "hideForm"); }

function submitformWOTW { console.log('Starting to submit...'); var $form = $('#request-form'), wotw_word_local = $form.find('#wotw-word').val, wotw_word_translated = $form.find('#wotw-word-translated').val, lang = $form.find('#language').val, /* reuse dropdown */ page = "* \'\'\'" + wotw_word_local + "\'\'\' (" + lang + " for \'\'" + wotw_word_translated + "\'\'";		// If language or header is blank, return alerts		if (!lang) {			alert('Please select a language!');		}	console.log('Performed checks...');		// Ajax URL		var url = _api.server + '/api.php?action=edit&title=Language_Brigade_Wiki:Word_of_the_Week/Nominations&appendtext=' + encodeURIComponent(page) + '&summary=New+nomination+added';	console.log('Got the url: ',url);		$.post(url, function { console.log('Should be done now:'); window.location = _kt.server + '/wiki/' + 'Spotlight:' + encodeURIComponent(lang) + '/' + encodeURIComponent(wikiname); });	console.log('Sent request...');	}

// Add buttons depending on user language if(_api.pagename === 'Language_Brigade_Wiki:Word_of_the_Week') { $(document).ready(function {

openFormWOTW;

});

}