/* * verification.js * Copyright (C) 2008 * Author: Alexey Potapenko * Created: 2008-10-30 */ var Verification = { verify: function(sendButton, code){ var xhr = new XHR(); xhr.onSuccess = function(self) { if (sendButton != null) { sendButton.className = "SubmitButton"; sendButton.disabled = false; } var result = Json.evaluate(this.transport.responseText); if (result == null || result["status"] == "success") { window.location = "video"; return; } var errors = result["errors"]; var fields = ["IM3_Ver_Code", "IM3_Ver_Overall"]; for (var i = 0; i < fields.length; i++) { var field = fields[i]; if (!$defined($(field + "_Error"))) continue; $(field + "_Error").className = "FormErrorHidden"; if (errors[field] != null) { $(field + "_Error").innerHTML = errors[field]; $(field + "_Error").className = "FormErrorVisible"; } } } if (!$defined(code) || code.length == 0) code = $("IM3_Ver_Code").value; if (sendButton != null) { sendButton.className = "SubmitButtonDisabled"; sendButton.disabled = true; } xhr.send(IM3_Config.jsonServerURL + "/IM3Service.verify/" + IM3_Config.webcastID + "/" + code); } } var behaviourRules = { '#VerificateButton' : function(el){ el.onclick = function(el){ Verification.verify($('VerificateButton')); return false; } } } Behaviour.register (behaviourRules);