* Stores captcha callbacks used for captchas in AJAX contexts.
*/
WCF.System.Captcha = {
+ /**
+ * ids of registered captchas
+ * @var {string[]}
+ */
+ _registeredCaptchas: [],
+
/**
* Adds a callback for a certain captcha.
*
require(['WoltLabSuite/Core/Controller/Captcha'], function(ControllerCaptcha) {
try {
ControllerCaptcha.add(captchaID, callback);
+
+ this._registeredCaptchas.push(captchaID);
}
catch (e) {
if (e instanceof TypeError) {
// ignore other errors
}
- });
+ }.bind(this));
},
/**
getData: function(captchaID) {
var returnValue;
+ if (this._registeredCaptchas.indexOf(captchaID) === -1) {
+ return returnValue;
+ }
+
var ControllerCaptcha = require('WoltLabSuite/Core/Controller/Captcha');
try {
returnValue = ControllerCaptcha.getData(captchaID);
require(['WoltLabSuite/Core/Controller/Captcha'], function(ControllerCaptcha) {
try {
ControllerCaptcha.delete(captchaID);
+
+ this._registeredCaptchas.splice(this._registeredCaptchas.indexOf(item), 1);
}
catch (e) {
// ignore errors for unknown captchas
}
- });
+ }.bind(this));
}
};