var socket = io("https://myaccount.harford.edu:443"); var usernameSearch = function (usernameDiv, typeOf, msgDiv, subTypeOf) { // set up state object let state = new State(); state.event.type = typeOf; state.event.subType = subTypeOf; state.status.current = 'success'; // grab username from username html div, removing any email part added on let username = document.getElementById(usernameDiv).value.split("@")[0]; // ensure username is populated // otherwise RENDER MESSAGE ERROR if (checkIfPopulated(username) === false) { state.status.current = "error"; state.message.system = "user did not enter username"; state.message.endUser = "Please enter username and click submit."; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "textContent"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } // ensure username does not have any spaces. // otherwise RENDER MESSAGE ERROR if (username.includes(" ") === true) { state.status.current = "error"; state.message.system = "username given includes a space"; state.message.endUser = "
Please make sure to enter your username. Usernames will not include a space. If you aren't sure what your username is, please recover it here
Please enter your first name.
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } // ensure last name is populated // otherwise RENDER MESSAGE ERROR if (checkIfPopulated(lastname) === false) { state.status.current = "error"; state.message.system = "user did not enter last name"; state.message.endUser = "Please enter your last name.
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } // ensure birthdate is populated // otherwise RENDER MESSAGE ERROR if (checkIfPopulated(birthdate) === false) { state.status.current = "error"; state.message.system = "user did not enter birthdate"; state.message.endUser = "Please fillout your birthdate information.
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } else { if (birthdate.includes("Month") || birthdate.includes("Day") || birthdate.includes("Year")) { state.status.current = "error"; state.message.system = "user did not enter birthdate"; state.message.endUser = "Please fillout your birthdate information.
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } } // ensure captcha answer is populated // otherwise RENDER MESSAGE ERROR if (checkIfPopulated(captchaInterpretation) === false) { state.status.current = "error"; state.message.system = "user did not answer captcha"; state.message.endUser = "Please fill out captcha response and click submit.
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } // ensure captcha encoded correct answer is populated // otherwise RENDER MESSAGE ERROR if (checkIfPopulated(correctCaptcha) === false) { state.status.current = "error"; state.message.system = "encoded correct captcha from server not available"; state.message.endUser = "
internal server error, please contact ITS at 443-412-2477, option #3
"; state.actions.client.toProcess.push('renderMessage'); state.actions.client.renderMessage.location.div = msgDiv; state.actions.client.renderMessage.message.type = "innerHTML"; state.actions.client.renderMessage.message.data = state.message.endUser; // run renderMessage // alert user they need to type in a username state = processActions(state); return state; } // create apiCall action state.actions.client.toProcess.push('apiCall'); state.actions.client.apiCall.search.type = typeOf; state.actions.client.apiCall.search.endpoint = 'api/v1/actions/generate-user-record'; state.actions.client.apiCall.search.attributes = { firstname: firstname, lastname: lastname, birthdate: birthdate, version: "v1", endpoints: "ActiveDirectory,Identity" }; state.actions.client.apiCall.captcha.required = true; state.actions.client.apiCall.captcha.userInterpretation = captchaInterpretation; state.actions.client.apiCall.captcha.correctEncoded = correctCaptcha; // run apiCall // emit socket apiCall to search for user info state = processActions(state); return state; } var updateMonthDropDown = function (num) { item = document.getElementById('monthDropDown').innerText = num } var updateDayDropDown = function (num) { item = document.getElementById('dayDropDown').innerText = num } var updateYearDropDown = function (num) { item = document.getElementById('yearDropDown').innerText = num }