{"version":3,"names":[],"mappings":"","sources":["communication-preferences.js"],"sourcesContent":["\r\nwindow.onload = function () {\r\n //window.disableSubmitButton = disableSubmitButton;\r\n var todaysDate = new Date();\r\n var newDateOptions = {\r\n year: \"numeric\",\r\n month: \"2-digit\",\r\n day: \"2-digit\"\r\n }\r\n todaysDate = todaysDate.toLocaleString('en-US',newDateOptions)\r\n\r\n const displayVisitDateTime = document.getElementById(\"visitDate\")\r\n displayVisitDateTime.innerText = todaysDate\r\n //alert(\"Starting onload\" );\r\n// let userOriginData;\r\n function getUserOriginData() {\r\n let VisitorAPI = function (t, e, a) {\r\n var s = new XMLHttpRequest;\r\n s.onreadystatechange = function () {\r\n var t;\r\n s.readyState === XMLHttpRequest.DONE && (200 === (t = JSON.parse(s.responseText)).status ? e(t.data) : a(t.status, t.result))\r\n }, s.open(\"GET\", \"https://api.visitorapi.com/api/?pid=\" + t), s.send(null)\r\n };\r\n\r\n VisitorAPI(\r\n \"trppJDiR1VD9epeGa43i\",\r\n function (data) {\r\n sessionStorage.setItem('userOriginData', JSON.stringify(data, null, 2));\r\n },\r\n function (errorCode, errorMessage) {\r\n console.log(errorCode, errorMessage)\r\n }\r\n );\r\n return\r\n }\r\n\r\n getUserOriginData();\r\n // new VisitorAPI(\"trppJDiR1VD9epeGa43i\", function(data){console.log(data)}, function(errorCode, errorMessage){console.log(errorCode, errorMessage)});\r\n\r\n let html = ''\r\n\r\n function setHtmlValue() {\r\n html = '\\n' +\r\n '\\n' +\r\n '\\n' +\r\n ' \\n' +\r\n ' Communication Preferences | EmployeeWorkplace\\n' +\r\n ' \\n' +\r\n ' \\n' +\r\n ' \\n' +\r\n '' +\r\n ' \\n' +\r\n ' \\n' +\r\n '' +\r\n '' +\r\n '' +\r\n '\\n' +\r\n '
\\n' +\r\n '\\n' +\r\n '
' +\r\n '
' +\r\n '\"\"\\n' +\r\n '
' +\r\n '
\\n' +\r\n '

\\n' +\r\n ' Communication Preferences Form\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '

\\n' +\r\n ' I would like the following change(s) to be made to my communication preferences:\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n '

Email:

\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n '' +\r\n '
' +\r\n '
\\n' +\r\n '
\\n' +\r\n '

Phone:

\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n '\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n '

Date:

' +\r\n '
\\n' +\r\n '
\\n'\r\n + todaysDate +\r\n '
\\n' +\r\n '
\\n'\r\n\r\n html += '
\\n' +\r\n '
\\n' +\r\n ' First Name:\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n $('#firstName').val() +\r\n '
\\n' +\r\n '
\\n'\r\n\r\n html += '
\\n' +\r\n '
\\n' +\r\n ' Last Name:\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n $('#lastName').val() +\r\n '
\\n' +\r\n '
\\n'\r\n\r\n html += '
\\n' +\r\n '
\\n' +\r\n ' Email Address:\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n $('#emailAddress').val() +\r\n '
\\n' +\r\n '
\\n'\r\n\r\n html += '
\\n' +\r\n '
\\n' +\r\n ' Phone Number:\\n' +\r\n '
\\n' +\r\n '
\\n' +\r\n $('#phoneNumber').val() +\r\n '
\\n' +\r\n '
\\n';\r\n\r\n // if ($('#phoneNumber').val() !== '') {\r\n // html += ' value=\"' + $('#phoneNumber').val() + '\" ' +\r\n // ' type=\"text\">\\n' +\r\n // ' \\n' +\r\n // '
\\n' +\r\n // '
\\n';\r\n // } else {\r\n // html += ' type=\"text\">\\n' +\r\n // ' \\n' +\r\n // '
\\n' +\r\n // ' \\n'\r\n // }\r\n\r\n html += '\\n' +\r\n '
' +\r\n '

\\n' +\r\n ' Opt-Out (Do Not Contact Me)\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '

\\n' +\r\n ' When choosing “Opt-Out” for phone and/or email above, I understand Advantage Resourcing, Advantage xPO, digitalpeople, Hunter Hamilton, Pro Staff, and Staffmark will not attempt to contact me at the email address and/or phone number provided, including about possible jobs.\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '

\\n' +\r\n ' Opt-In (Contact Me)\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '

\\n' +\r\n ' When choosing “Opt-In” for phone and/or email above, I want to be considered for future opportunities that may match my skills, experience, and/or preferences and I consent to receive, and hereby authorize, Advantage Resourcing, Advantage xPO, digitalpeople, Hunter Hamilton, Pro Staff, and Staffmark (collectively, the “Company”), and third parties acting for the Company, to communicate with me via phone or email above. Communications, may include automated, prerecorded and/or artificial voice telephone calls, text messages, and emails regarding my application and interest to work, and, if hired, communications about my employment status, availability and offers of temporary work assignments, job-related information and updates, check-ins, and payroll notifications, at all telephone number(s) and/or email address(es) listed on this application. Message and data rates may apply.\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '

\\n' +\r\n ' By opting-in, I authorize the Company to collect, use, store, and destroy the personal information that I have provided for the purposes of employment with the Company, and/or recruitment for and submission to job positions directly with a Company client, as subject to the terms and conditions of the Company\\'s Privacy Policy listed on its website https://www.staffmarkgroup.com/privacy and allowed by applicable law.\\n' +\r\n '

\\n' +\r\n '\\n' +\r\n '
\\n' +\r\n '\\n'\r\n }\r\n\r\n $('#emailAddress').change(function () {\r\n const re = /\\S+@\\S+\\.\\S+/\r\n let match = false\r\n match = re.test($('#emailAddress').val())\r\n if (!match) {\r\n $('#emailAddress').css('background-color', 'pink')\r\n } else {\r\n $('#emailAddress').css('background-color', 'white')\r\n }\r\n })\r\n\r\n $('#submitButton').click(function (event) {\r\n 'use strict'\r\n\r\n const spinner = document.getElementById(\"spinner\");\r\n const submitText = document.getElementById(\"submitText\");\r\n\r\n spinner.classList.remove('d-none');\r\n // $('#submitText').toggle(\"d-none\");\r\n\r\n let submitForm = false;\r\n // Fetch all the forms we want to apply custom Bootstrap validation styles to\r\n let forms = document.querySelectorAll('.needs-validation')\r\n\r\n // Loop over them and prevent submission\r\n Array.prototype.slice.call(forms)\r\n .forEach(function (form) {\r\n\r\n if (!form.checkValidity()) {\r\n event.preventDefault()\r\n event.stopPropagation()\r\n let errorRadios = document.querySelectorAll(\"input.form-check-input:invalid\");\r\n // alert(\"errorRadios size = \" + errorRadios.length);\r\n let errorOthers = document.querySelectorAll(\"input.form-control:invalid\");\r\n // alert(\"errorOthers size = \" + errorOthers.length);\r\n let firstInvalidRadio = $(\"#commForm\").find(\".form-check-input:invalid\").first();\r\n // alert(\"firstInvalidRadio = \" + firstInvalidRadio);\r\n let firstInvalidOther = $(\"#commForm\").find(\".form-control:invalid\").first()\r\n let target, targetRadio, targetOther, firstInvalid;\r\n\r\n if (errorRadios.length > 0) {\r\n firstInvalid = firstInvalidRadio;\r\n }else\r\n if (errorOthers.length > 0) {\r\n\r\n firstInvalid = firstInvalidOther;\r\n }\r\n const confirmationModal = document.getElementById('exampleModal');\r\n var modal = bootstrap.Modal.getInstance(confirmationModal);\r\n modal.hide();\r\n\r\n setTimeout(function () {\r\n document.getElementById(\"modalBtn\").blur()\r\n window.scrollTo({ top: 0, behavior: 'smooth' });\r\n spinner.classList.add('d-none');\r\n\r\n }, 500);\r\n\r\n } else {\r\n submitForm = true;\r\n }\r\n form.classList.add('was-validated')\r\n })\r\n // return false;\r\n\r\n if (submitForm) {\r\n event.preventDefault()\r\n $('#submitButton').prop('disabled', true)\r\n setHtmlValue()\r\n const s = sessionStorage.getItem(\"userOriginData\")\r\n // alert(\"userOriginData = \" + s)\r\n const communicationPreferences = {\r\n content: html,\r\n data: {\r\n emailOptout: $('#email-Opt-Out')[0].checked,\r\n phoneOptout: $('#phone-opt-Out')[0].checked,\r\n firstName: $('#firstName').val(),\r\n lastName: $('#lastName').val(),\r\n emailAddress: $('#emailAddress').val(),\r\n phoneNumber: $('#phoneNumber').val(),\r\n },\r\n type: \"CommunicationPreference\",\r\n userOriginData: sessionStorage.getItem(\"userOriginData\"),\r\n }\r\n\r\n var apiUrl = ''\r\n if (window.location.hostname === \"localhost\" || window.location.hostname.includes(\"dev2\")) {\r\n apiUrl = 'https://dev2.api.employeeworkplace.com/web-forms/'\r\n } else if (window.location.hostname.includes(\"uat2\")) {\r\n apiUrl = 'https://uat2.api.employeeworkplace.com/web-forms/'\r\n } else {\r\n apiUrl = 'https://api.employeeworkplace.com/web-forms/'\r\n }\r\n\r\n $.ajax({\r\n type: 'post',\r\n url: apiUrl + 'webForm',\r\n contentType: 'application/json',\r\n dataType: 'json',\r\n data: JSON.stringify(communicationPreferences),\r\n success: function (data) {\r\n if (data.message === 'Web form has been processed.') {\r\n $('#email-Opt-Out')[0].checked = false\r\n $('#phone-opt-Out')[0].checked = false\r\n $('#firstName')[0].value = ''\r\n $('#lastName')[0].value = ''\r\n $('#emailAddress')[0].value = ''\r\n $('#phoneNumber')[0].value = ''\r\n\r\n if (!window.location.origin.includes('localhost')) {\r\n window.location.href = window.location.origin + '/web-forms/thank-you.html';\r\n } else {\r\n window.location.href = window.location.origin + '/thank-you.html';\r\n }\r\n\r\n } else {\r\n const modal = document.getElementById('confirmation');\r\n modal.innerHTML = '
' +\r\n '
' +\r\n '
' +\r\n '' +\r\n '
' +\r\n '
' +\r\n '
\\n' +\r\n '

An error has occurred. Please try again later.

\\n' +\r\n '
\\n' +\r\n '
' +\r\n '
';\r\n\r\n this.consumerRequestForm.reset();\r\n // setTimeout( () => {\r\n // this.prompted = !this.prompted;\r\n // location.reload();\r\n // }, 5000);\r\n console.error(error);\r\n }\r\n }\r\n })\r\n }\r\n })\r\n\r\n $('#phoneNumber').keyup(function (event) {\r\n formatPhone(event.currentTarget.value)\r\n });\r\n\r\n function formatPhone(phone) {\r\n if (event.keyCode !== 8) {\r\n var curchr = phone.length;\r\n var curval = phone;\r\n if (curchr == 3) {\r\n $('#phoneNumber').val(\"(\" + curval + \")\" + \" \");\r\n } else if (curchr == 9) {\r\n $('#phoneNumber').val(curval + \"-\");\r\n } else if (curchr === 10 && !curval.includes('(')) {\r\n const areaCode = curval.substring(0, 3)\r\n const phonePart1 = curval.substring(3, 6)\r\n const phonePart2 = curval.substring(6, 10)\r\n $('#phoneNumber').val(\"(\" + areaCode + \")\" + \" \" + phonePart1 + '-' + phonePart2)\r\n } else if (curchr >= 14 && !curval.includes('(')) {\r\n const areaCode = curval.substring(0, 3)\r\n const phonePart1 = curval.substring(4, 7)\r\n const phonePart2 = curval.substring(8, 12)\r\n $('#phoneNumber').val(\"(\" + areaCode + \")\" + \" \" + phonePart1 + '-' + phonePart2)\r\n }\r\n }\r\n }\r\n\r\n // function disableSubmitButton() {\r\n // if ($(\"input[name='emailPreference-radio-group']:checked\").val() !== undefined &&\r\n // $(\"input[name='phonePreference-radio-group']:checked\").val() !== undefined &&\r\n // $('#fullName').val() !== '' && $('#emailAddress').val() !== '' && $('#phoneNumber').val() !== '') {\r\n // $('#submitButton').prop('disabled', false)\r\n // }\r\n // }\r\n}\r\n\r\n"],"file":"communication-preferences.js"}