I've been rewriting various bits of code I've 'inherited' and come across something I don't understand. Both jslint and jshint think the below function is a constructor, and I have no idea why.
function GEReqsDone(failed) {
if (!failed) {
alert('Thank you for your submission! The page will now be reloaded.');
document.location.replace(mwConfig.wgScript + '?title=' + encodeURIComponent(mwConfig.wgPageName) + '&action=purge');
} else {
alert('An error occurred while submitting the edit.');
button.disabled = false;
button.innerHTML = 'Update price';
}
}
This is a callback from query using $.ajax() that queries the mediawiki API to automatically edit to update a price on a page. If the edit succeeds failed
is not defined and the page reloads. If it fails, failed
is set to true and it resets the button used to trigger the update.
button
is simply a button element, the wg* variables are part of the mediaWiki object here used to access the pagename and url prefix (usually /index.php
).
Does anyone know why jshint and jslint seem to think this function should be new GEReqsDone()
rather than GEReqsDone()
?