PageSourceSearch

https://hazwoper-osha.com/var/cache/file.4369363d70309cb092e5ef0185e5e4b66d0a3665.js

js hazwoper-osha.com collected 2026-10-02 17:53:57 UTC 9,275 bytes, 21 lines download raw bytes

1/* login_register.js */
2function loadScript(src){return new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=src;script.onload=()=>resolve();script.onerror=()=>reject(new Error(`Failed to load script ${src}`));document.head.appendChild(script);});}
3async function initializeScripts(){await loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js');await loadScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/additional-methods.min.js');document.dispatchEvent(new Event('scriptsLoadedInternal'));}
4document.addEventListener('DOMContentLoaded',initializeScripts);function recaptchaCallback(e){console.log("reCAPTCHA verification successful!"),$(".register-error-message").empty(),$("#register-fail-text").addClass("hidden");}
5const input=document.querySelector("#billing_phone");if(input!=undefined){var iti=window.intlTelInput(input,{initialCountry:"us",separateDialCode:true,utilsScript:"https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js",autoFormat:true,formatOnDisplay:false,nationalMode:false,customPlaceholder:function(){return"";}});}
6$(document).ready(function(){function str2ab(str){const encoder=new TextEncoder();return encoder.encode(str).buffer;}
7$('.toggle-password').on('click',function(){const targetSelector=$(this).data('target');const input=$(targetSelector);const isPassword=input.attr('type')==='password';input.attr('type',isPassword?'text':'password');input.css('-webkit-text-security',isPassword?'none':'disc');$(this).toggleClass('fa-eye fa-eye-slash');});function encryption(obj){const jsonString=JSON.stringify(obj);const binaryData=str2ab(jsonString);const base64String=btoa(String.fromCharCode.apply(null,new Uint8Array(binaryData)));console.log("work ecr")
8return base64String;}
9async function loginApi(data){console.log(data,"datadata")
10try{const response=await fetch(apiUrl,{method:'POST',headers:{},body:JSON.stringify(data),});console.log({response})
11console.log(BASE_URL,"BASE_URL")
12const responseData=await response.json();return responseData;}catch(error){console.error('Error:',error.message);return error.message;}}
13function setCookie(name,value,days){var expires='';if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires='; expires='+date.toUTCString();}
14document.cookie=name+'='+value+expires+'; path=/';}
15document.addEventListener('scriptsLoadedInternal',function(){const commonPattern=/^[a-zA-Z0-9\s\-.,&]+$/;$("#loginForm").validate(),$("#RegisterForm").validate({ignore:":hidden:not(#billing_state, #billing_country)",rules:{password:{required:!0,minlength:8,strongPassword:true,},confirmpassword:{required:!0,equalTo:"#RegisterForm #password",minlength:8,strongPassword:true},billing_phone:{required:true,billingPhone:true,maxlength:25},email:{validate_email:!0},username:{noSpace:!0},billing_first_name:{required:true,pattern:commonPattern},billing_last_name:{required:true,pattern:commonPattern},billing_city:{required:true,pattern:commonPattern},billing_company:{required:false,pattern:commonPattern},billing_address_1:{required:true,pattern:commonPattern},billing_address_2:{required:false,pattern:commonPattern},billing_postcode:{required:true,pattern:commonPattern},billing_state:{required:true},billing_country:{required:true},billing_first_name:{required:true,pattern:commonPattern},billing_last_name:{required:true,pattern:commonPattern}},messages:{password:{strongPassword:"Password must contain at least 1 lowercase, 1 uppercase, 1 number, and 1 special character."},confirmpassword:{strongPassword:"Confirm Password must meet strength requirements.",equalTo:"The passwords do not match."},billing_phone:{required:"Phone is a required field."},billing_first_name:{pattern:"Invalid characters detected. Please enter a valid First Name."},billing_last_name:{pattern:"Invalid characters detected. Please enter a valid Last Name."},billing_city:{pattern:"Invalid characters detected. Please enter a valid City."},billing_company:{pattern:"Invalid characters detected. Please enter a valid company name."},billing_address_1:{pattern:"Invalid characters detected. Please enter a valid Street Address."},billing_address_2:{pattern:"Invalid characters detected. Please enter a valid Suite, Apt, Building."},billing_postcode:{pattern:"Invalid characters detected. Please enter a valid Zip / Postal Code."},billing_state:{required:"State is a required field."},billing_country:{required:"Country is a required field."},},errorPlacement:function(error,element){if(element.attr("name")==="billing_phone"){error.appendTo("#phone-error");}else if(element.attr("name")==="billing_state"){error.appendTo("#billing_state_error");}else if(element.attr("name")==="billing_country"){error.appendTo("#billing_country_error");}else{error.insertAfter(element);}},}),jQuery.validator.addMethod("validate_email",function(e,a){return!!/^[a-zA-Z0-9](?!.*[.]{2})[a-zA-Z0-9._%+-]*[a-zA-Z0-9]@[a-zA-Z0-9](?!.*[.]{2})[a-zA-Z0-9.-]*[a-zA-Z0-9]\.[a-zA-Z]{2,}$/.test(e);},"Please enter a valid email address."),jQuery.validator.addMethod("noSpace",function(e,a){return this.optional(a)||/^[a-zA-Z0-9]+$/.test(e);},"Spaces and special characters are not allowed."),$.validator.addMethod("billingPhone",function(value,element){if(!value)return false;return/^[0-9\s()+\-]+$/.test(value);},"Please enter a valid phone number");jQuery.validator.addMethod("strongPassword",function(value,element){return this.optional(element)||/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{6,}$/.test(value);},"Password must contain at least 1 lowercase, 1 uppercase, 1 number, and 1 special character.");});var isCheckoutSource=new URLSearchParams(window.location.search).get('source')==='checkout_page';$("#loginForm").submit(async function(e){e.preventDefault();var captcha_data=grecaptcha.getResponse();if($("#loginForm").valid()){const postData={user_name:$("#loginForm #Login_username").val(),password:$("#loginForm #login_password").val(),g_recaptcha_response:captcha_data,client:"web",env:_ENV};try{const result=await apiCall('login','post',postData);if(result.user_details&&result.success){const loginData=set_user_data(result);const jwtToken=result.jwtoken;window.localStorage.setItem('lms_login',encryption(loginData));setCookie('jwt',jwtToken,7);if(result.ehs_permission!==undefined&&result.ehs_permission===true&&!isCheckoutSource){window.location.href=`${result.ehs_url}/${jwtToken}/${loginData.session_id}`;}else if(isCheckoutSource){window.location.replace('checkout');}else{window.location.replace('my-account');}}else{if(result.error&&result.error.indexOf('To prevent automated access')!==-1){$("#g-recaptcha-error").text(result.error);}
16grecaptcha.reset();const errorMessage=result&&result.error?result.error:"An unknown error occurred";console.log(errorMessage,"errorMessage")
17showToast("error",errorMessage);}}catch(error){grecaptcha.reset();console.error(error);const errorMessage=error.response&&error.response.data&&error.response.data.message?error.response.data.message:error.message||"An error occurred";showToast("error",errorMessage);}}});$("#RegisterForm").submit(async function(e){if((e.preventDefault(),$("#register-fail-text").addClass("hidden"),$("#RegisterForm").valid())){if(document.getElementById('loginForm')){if(!grecaptcha.getResponse()){var captchaData=grecaptcha.getResponse(1);}else{var captchaData=grecaptcha.getResponse();}}
17else{var captchaData=grecaptcha.getResponse();}
18for(var a in((captcha_data=grecaptcha.getResponse()),(RegisterData={first_name:$("#RegisterForm #firstName").val(),last_name:$("#RegisterForm #lastname").val(),billing_company:$("#RegisterForm #company").val(),billing_address_1:$("#RegisterForm #billing_address_1").val(),billing_address_2:$("#RegisterForm #billing_address_2").val(),billing_postcode:$("#RegisterForm #billing_postcode").val(),billing_city:$("#RegisterForm #billing_city").val(),billing_state:$("#RegisterForm #billing_state").val(),billing_country:$("#RegisterForm #billing_country").val(),user_name:$("#RegisterForm #username").val().replaceAll(" ",""),password:$("#RegisterForm #password").val().replaceAll(" ",""),email:$("#RegisterForm #email").val(),phone:$("#RegisterForm #billing_phone").val(),user_role_id:"2",g_recaptcha_response:captchaData,verify_field:$("#RegisterForm #verify_field").val(),}),RegisterData))
19RegisterData[a].trim&&(RegisterData[a]=RegisterData[a].trim());if(((result=await apiCall("register_new_user","post",RegisterData)),result.success)){const e=set_user_data(result);const jwtToken=result.jwtoken;
19window.localStorage.setItem("lms_login",encryption(e)),setCookie('jwt',jwtToken,7);if(result.ehs_permission!==undefined&&result.ehs_permission===true){window.location.href=`${result.ehs_url}/${jwtToken}/${e.session_id}`;}else{window.location.replace(BASE_URL+"my-account");}}
20else
21$(".register-error-message").empty(),$(".register-error-message").text(result.error),$("#register-fail-text").removeClass("hidden");}});document.getElementById('billing_country').addEventListener('change',function(){const stateSelect=document.getElementById('billing_state');const selectedOption=this.options[this.selectedIndex];const countryId=selectedOption.getAttribute('data-id');handleCountryChange(countryId,stateSelect);});});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.