1var promocode = (function() { 2 3 var init = function () { 4 let promoButton = document.getElementById('promosend'); 5 if(!promoButton) { 6 return false; 7 } 8 9 document.getElementById('promosend').addEventListener('click', function() { 10 var promocode = document.getElementById('promocode').value; 11 var url = document.getElementById('promocode').getAttribute('data-url'); 12 var error = document.getElementById('promo_error'); 13 var success = document.getElementById('promo_success'); 14 var hiddenField = document.getElementById('promo_id'); 15 16 success.innerHTML = error.innerHTML = ''; 17 success.style.display = error.style.display = 'none'; 18 var xhr = new XMLHttpRequest(); 19 xhr.open('POST', url); 20 21 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 22 xhr.setRequestHeader('X-CSRF-Token', yii.getCsrfToken()); 23 24 xhr.onload = function() { 25 var response = JSON.parse(xhr.responseText); 26 if (xhr.status === 200) { 27 window.dispatchEvent(new CustomEvent('indirim_yaz',{detail:{percent : parseInt(response.percent)}})); 28 document.getElementById('promocode').value = ''; 29 30 success.innerHTML = response.message; 31 success.style.display = 'block' 32 33 hiddenField.value = response.id_promo; 34 } 35 if (xhr.status === 418) { 36 error.innerHTML = response.error; 37 error.style.display = 'block'; 38 } 39 }; 40 xhr.send('promocode=' + encodeURIComponent(promocode)); // Send the request with the promocode input value as the request body 41 }); 42 43 return true 44 }; 45 46 return { 47 init: init 48 } 49}());
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.