1var registration = (function(root, $){ 2 "use strict"; 3 4 $(document).ready(function(){ 5 6 const emailForm = document.getElementById("email-subscribe"); 7 const unSubEmail = document.getElementById("email-unsubscribe"); 8 const formRegister = document.getElementById("site-register"); 9 const formCheck = document.getElementById("registration-check"); 10 11 const urlHost = location.protocol + "//" + window.location.host; 12 let grabSubdomain = urlHost.split('.')[0].split('//')[1]; 13 let subdomain = ''; 14 if(grabSubdomain != "www"){ 15 subdomain = true; 16 } else { 17 subdomain = false; 18 } 19 20 //check for registered user 21 if (formCheck) { 22 const el = document.getElementById("registration-check-submit"); 23 el.addEventListener("click", function(e) { 24 const host = location.protocol + "//" + window.location.host; 25 const emailval = sandiaEmailCheck( formCheck[0].value ); 26 const subdomainSite = window.location.host.split('.')[1] ? window.location.host.split('.')[0] : false; 27 28 //redirect if site is xyce and user is sandia.gov email 29 const xyceCheck = subdomainSite.substring(0 , 4); 30 if ( xyceCheck == "xyce" && emailval == "sandia.gov" ) { 31 if ( subdomain ) { 32 window.location.href = host + "/sandia-download/"; 33 return; 34 } else { 35 let siteName = window.location.pathname.split('/')[1]; 36 window.location.href = host + "/" + siteName + "/sandia-download/"; 37 return; 38 } 39 } 40 41 const checkboxCheck = document.getElementById("contact-me").checked; 42 if (!checkboxCheck) { 43 e.preventDefault(); 44 fetch(subscribe.path + 'emp-api/download-reg-check', { 45 method: 'POST', 46 headers: { 47 'Content-Type': 'application/x-www-form-urlencoded' 48 }, 49 body: new URLSearchParams(new FormData(formCheck)), 50 beforeSend: function (xhr) { 51 xhr.setRequestHeader('X-WP-NONCE', subscribe.sub_nonce); 52 } 53 }).then(response => { 54 return response.json(); 55 }).then(jsonResponse => { 56 if(jsonResponse.success){ 57 $('#registration-resend').removeClass('d-none') 58 } else { 59 const emailValue = jsonResponse.data.message; 60 formRegister[2].value = emailValue; 61 62 // $('#registration-check').addClass('d-none') 63 $('#site-register').removeClass('d-none') 64 $('#new-user').addClass('d-none'); 65 } 66 }); 67 } 68 69 }); 70 } 71 72 //show full registration form if new visitor 73 if ( formCheck ) { 74 const el = document.getElementById("new-user"); 75 el.addEventListener("click", function(e) { 76 e.preventDefault(); 77 // $('#registration-check').addClass('d-none') 78 $('#site-register').removeClass('d-none'); 79 $('#new-user').addClass('d-none'); 80 81 }); 82 } 83 84 //handle registration form 85 if ( formRegister ) { 86 const reg = document.getElementById("registration-info-submit"); 87 reg.addEventListener('click', function(e) { 88 const host = location.protocol + "//" + window.location.host; 89 const fieldCheck = document.getElementById("user-email").value; 90 const emailval = sandiaEmailCheck( formRegister[2].value ); 91 const subdomainSite = window.location.host.split('.')[1] ? window.location.host.split('.')[0] : false; 92 93 //redirect if site is xyce and user is sandia.gov email 94 const xyceCheck = subdomainSite.substring(0 , 4); 95 if ( xyceCheck == "xyce" && emailval == "sandia.gov" ) { 96 sandiaRedirect(host); 97 } else { 98 //continue if not xyce sandia.gov user 99 if (!fieldCheck) { 100 e.preventDefault(); 101 fetch(subscribe.path + 'emp-api/download-reg-form', { 102 method: 'POST', 103 headers: { 104 'Content-Type': 'application/x-www-form-urlencoded' 105 }, 106 body: new URLSearchParams(new FormData(formRegister)), 107 beforeSend: function (xhr) { 108 xhr.setRequestHeader('X-WP-NONCE', subscribe.sub_nonce); 109 } 110 }).then(response => { 111 return response.json(); 112 }).then(jsonResponse => { 113 if ( !subdomain ) { 114 window.location.href = host + "/thank-you/"; 115 } else { 116 let siteName = window.location.pathname.split('/')[1]; 117 window.location.href = host + "/" + siteName + "/thank-you/"; 118 } 119 }); 120 } 121 } 122 123 }); 124 } 125 126 //labnews subscribe 127 if (emailForm) { 128 emailForm.addEventListener('submit', function(e) { 129 const fieldCheck = document.getElementById("user-email").value; 130 131 if (!fieldCheck) { 132 e.preventDefault(); 133 fetch( subscribe.path + 'emp-api/labnews-reg', { 134 method: 'POST', 135 headers: { 136 'Content-Type': 'application/x-www-form-urlencoded' 137 }, 138 body: new URLSearchParams(new FormData(emailForm)), 139 beforeSend: function (xhr) { 140 xhr.setRequestHeader('X-WP-NONCE', subscribe.sub_nonce); 141 } 142 }).then(response => { 143 return response.json(); 144 145 }).then(jsonResponse => { 146 $('#email-subscribe').hide(); 147 $('#notification').show(); 148 // jsonResponse; 149 // console.log({jsonResponse}); 150 }); 151 } 152 153 }); 154 } 155 156 //labnews unsubscribe 157 if (unSubEmail) { 158 unSubEmail.addEventListener('submit', function(e) { 159 const fieldCheck = document.getElementById("user-email").value; 160 161 if (!fieldCheck) { 162 e.preventDefault(); 163 fetch(subscribe.path + 'emp-api/labnews_unsub', { 164 method: 'POST', 165 headers: { 166 'Content-Type': 'application/x-www-form-urlencoded' 167 }, 168 body: new URLSearchParams(new FormData(unSubEmail)), 169 beforeSend: function (xhr) { 170 xhr.setRequestHeader('X-WP-NONCE', subscribe.sub_nonce); 171 } 172 }).then(response => { 173 174 return response.json(); 175 176 }).then(jsonResponse => { 177 $('#email-unsubscribe').hide(); 178 $('#unsub-notification').show(); 179 // jsonResponse; 180 // console.log({jsonResponse}); 181 }); 182 } 183 184 }); 185 } 186 187 function sandiaEmailCheck( value ) { 188 var myRegexp = /@(.*)/; 189 var match = myRegexp.exec(value); 190 var res = match[1].toLowerCase(); 191 return res; 192 }; 193 194 function sandiaRedirect(host){ 195 if ( subdomain ) { 196 window.location.href = host + "/sandia-download/"; 197 return; 198 } else { 199 let siteName = window.location.pathname.split('/')[1]; 200 window.location.href = host + "/" + siteName + "/sandia-download/"; 201 return; 202 } 203 return; 204 } 205 206 }); 207 208 }(this, jQuery));
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.