/*!login_submit * Internet Captcha * version: 2 (20 Mqy 2013) * Examples at http://www.icaptcha.com * License: CREATIVE COMMONS Attribution-NonCommercial 3.0 Unported * Copyright 2013 David Arroni Castellanos */ function login_submit() { var validate = checking_icaptcha(); console.log(validate); if(validate=='ok=True'){ $('#submit_login').submit(); }else{ alert("Secure Code Invalid"); return; } } function forger_pw(){ $('#fgtpwdotp').attr('disabled', true); var country = $('#forgot_country_code').val(); var tel = $('#forgot_tel').val(); var request = "forget password" if (country=="60") { var tel2 = tel; if (tel2.substring(0,1)=="0") { tel2 = tel2.substr(1); tel = tel2; } }else { var tel2 = tel; } tel = country + tel; var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { /// Typical action to be performed when the document is ready: $('#fgtpwdotp').attr('disabled', false); var str=xhr.responseText; console.log(str); if(str.trim()=='OK'){ /// string return $('#success_text').html('OTP Sent Successful'); translator.lang(localStorage.getItem("lang")); $('#SuccessNotice').offcanvas('show'); $('#fgtpwdotp').attr('disabled', true); cdtime(); }else { $('#info_text').html('Error. Please try again later'); translator.lang(localStorage.getItem("lang")); $('#InfoNotice').offcanvas('show'); } } if (xhr.readyState == 4 && xhr.status >= 300) { //// server or connection error } }; xhr.open("POST", "/forgetpwd_sms/", true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send('hpno='+tel+'&request='+request); } function checking_icaptcha() { if (window.XMLHttpRequest) { icaptchaXML = new XMLHttpRequest } else { icaptchaXML = new ActiveXObject("Microsoft.XMLHTTP") } icaptchaXML.open("POST", "/validate/"); icaptchaXML.onreadystatechange = icaptcha_validate; icaptchaXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); icaptchaXML.send("code=" + document.getElementById("code").value); str=icaptchaXML.responseText; return str; } function icaptcha_validate() { if (icaptchaXML.readyState == 4) { var e = icaptchaXML.responseText; if (e == "ok=True") { forger_pw() } else { alert(icaptchat); loadicaptcha(); document.getElementById("code").value = ""; } } } function loadicaptcha() { if (window.XMLHttpRequest) { icaptchaXML = new XMLHttpRequest } else { icaptchaXML = new ActiveXObject("Microsoft.XMLHTTP") } icaptchaXML.open("POST", "/icaptcha/"); icaptchaXML.onreadystatechange = readicaptcha; icaptchaXML.send() } function readicaptcha() { if (icaptchaXML.readyState == 4) { var e; var t; var n = new Array(5); var r = document.getElementById("icaptcha"); var i = document.getElementById("icaptchaId"); var s = r.offsetWidth; var o = r.offsetHeight; i.height = o; i.width = s; icaptchactx.clearRect(0, 0, s, o); var u = icaptchaXML.responseText; var a = u.length / 12; for (e = 0; e < a; e++) { icaptchactx.beginPath(); icaptchactx.lineWidth = icaptchas; icaptchactx.strokeStyle = icaptchac; var f = icaptchag - 5; var l = icaptchag - 35; var c = s / (240 + 2 * icaptchag); var h = o / (60 + 2 * icaptchag); for (t = 0; t < 6; t++) { n[t] = parseInt(u.substr(e * 12 + t * 2, 2), 16) } icaptchactx.moveTo((n[0] + f) * c, (n[1] + l) * h); icaptchactx.quadraticCurveTo((n[4] + f) * c, (n[5] + l) * h, (n[2] + f) * c, (n[3] + l) * h); icaptchactx.stroke() } } } function icaptcha(e, t, n, r, i) { icaptchas = e; icaptchac = t; icaptchat = n; icaptchag = r; icaptchae = i; var i = document.getElementById("icaptcha"); var n = document.createElement("canvas"); n.id = "icaptchaId"; i.appendChild(n); if (typeof G_vmlCanvasManager != "undefined") { G_vmlCanvasManager.initElement(n) } icaptchactx = n.getContext("2d"); loadicaptcha() }