mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
55c17aa367
* Removed unused globals and local variables. * Use Message class. * Remove PHP4-ism from recaptchalib.php. * Remove superfluous newlines. * Add missing semi-colon in ext.confirmedit.asirra.js. * Fix up some documentation. Change-Id: I8916003d083a8c00aeabc9e485cc9a50030f0982
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
/*======================================================================*\
|
|
|| #################################################################### ||
|
|
|| # Asirra module for ConfirmEdit by Bachsau # ||
|
|
|| # ---------------------------------------------------------------- # ||
|
|
|| # This code is released into public domain, in the hope that it # ||
|
|
|| # will be useful, but without any warranty. # ||
|
|
|| # ------------ YOU CAN DO WITH IT WHATEVER YOU LIKE! ------------- # ||
|
|
|| #################################################################### ||
|
|
\*======================================================================*/
|
|
|
|
jQuery( function( $ ) {
|
|
var asirraform = $( "form#userlogin2" );
|
|
var submitButtonClicked = document.createElement("input");
|
|
var passThroughFormSubmit = false;
|
|
|
|
function PrepareSubmit() {
|
|
console.log( 'daa' );
|
|
submitButtonClicked.type = "hidden";
|
|
var inputFields = asirraform.find( "input" );
|
|
for (var i=0; i<inputFields.length; i++) {
|
|
if (inputFields[i].type === "submit") {
|
|
inputFields[i].onclick = function(event) {
|
|
console.log( this );
|
|
submitButtonClicked.name = this.name;
|
|
submitButtonClicked.value = this.value;
|
|
}
|
|
}
|
|
}
|
|
|
|
asirraform.submit( function() {
|
|
return MySubmitForm();
|
|
} );
|
|
}
|
|
|
|
function MySubmitForm() {
|
|
if (passThroughFormSubmit) {
|
|
return true;
|
|
}
|
|
Asirra_CheckIfHuman(HumanCheckComplete);
|
|
return false;
|
|
}
|
|
|
|
function HumanCheckComplete(isHuman) {
|
|
if (!isHuman) {
|
|
alert( mw.msg( 'asirra-failed' ) );
|
|
} else {
|
|
asirraform.append(submitButtonClicked);
|
|
passThroughFormSubmit = true;
|
|
asirraform.submit();
|
|
}
|
|
}
|
|
|
|
PrepareSubmit();
|
|
|
|
} );
|