/** * Copyright Asay Media Network, Joplin, Missouri, USA. * * @author Kevin Kinsey (kkinsey@asaypub.com) * @package * @version * * AMN_Code_Maturity_Level: development * Date: 8-25-2017 * * History: * * Comments: part of #519, supporting initiative at #340. * * checkUsername, comparePassphrases, findLabel, hideTOS, * reveal, password_chars, showTOS, submitRegistration, * switchTo, testRegistration, toggle, zipAutoFill */ if (typeof (SITEreg) == 'undefined') { SITEreg = {}; } /** * Check that we've not already processed an account for a given email address. */ SITEreg.checkEmail = function () { var email, url, data; email = document.getElementById('company_email'); url = "register_server.php"; data = { "action": "already_registered", "email": email.value }; warning = function (text, status, xhr) { if (text.responseText.length > 1) { sweetAlert(text.responseText); } if (text.responseText.indexOf("Confirmation has be") > -1) { setTimeout((function () { window.location.href = '/welcome'; })(), 2400); } if (text.responseText.indexOf("forgot_passw") > -1) { setTimeout((function () { window.location.href = '/forgot_password'; })(), 2400); } } settings = { "method": "POST", "data": data, "complete": warning }; jax = $jqs.ajax(url, settings); }; /** * Desired username must meet site policies. */ SITEreg.checkUsername = function () { var name, url, data, warning, settings, jax; name = document.getElementById('username'); if (name.value.length < 1) return false; url = "register_server.php"; data = { "action": "uname_check", "username": name.value }; warning = function (text, status, xhr) { if (text != "Y") { sweetAlert("Username is taken, or violates policy. Please select another username."); // \n How about : "+text name.value = ''; name.className += " error"; name.focus(); } if (text == "Y") { if (name.className.indexOf("error") > -1) { var str = name.className.replace(" error", ""); name.className = str; } return true; } } settings = { "method": "POST", "data": data, "success": warning }; jax = $jqs.ajax(url, settings); }; /** * Ensure that the 'new' password & the re-typed password match. * Do some work in the UI if they don't. */ SITEreg.comparePassphrases = function () { //form calls this var one, two; one = document.getElementById('password_new'); two = document.getElementById('password_confirm'); if (one.value !== two.value) { sweetAlert("Confirmation password does not match."); //one.value = ''; two.value = ''; two.className += " error"; //setTimeout(function () { document.getElementById('password_confirm').focus(); }, 500); return false; } else { // is this working?? if (two.className.indexOf("error") > -1) { var str = two.className.replace(" error", ''); two.className = str; } return true; } }; /** * Find the "