1var forms = { 2 enable: function ($form) { 3 var _enable = function ($items) { 4 $items.prop('disabled', false); 5 }; 6 this._perform($form, _enable); 7 }, 8 9 _perform: function ($form, func) { 10 func($form.find('input')); 11 func($form.find('textarea')); 12 func($form.find('button')); 13 }, 14 15 disable: function ($form) { 16 var _disable = function ($items) { 17 $items.prop('disabled', true); 18 }; 19 this._perform($form, _disable); 20 }, 21 22 processing: function ($form, isProcessing) { 23 if (isProcessing) { 24 $form.find('button').addClass('btn--processing'); 25 return; 26 } 27 $form.find('button').removeClass('btn--processing'); 28 }, 29 30 reset: function ($form, buttonText) { 31 $form.find('button') 32 .html('<div class="submission-status"></div> ' + buttonText) 33 .removeClass('btn--success'); 34 forms.processing($form, false); 35 }, 36 37 success: function ($form, buttonText) { 38 forms.processing($form, false); 39 $form.find('button') 40 .removeClass('btn--processing') 41 .addClass('btn--success') 42 .html('<div class="submission-status"></div> ' + buttonText); 43 }, 44 45 captchaBeforeSubmit: function (arr, $form, options) { 46 forms.disable($form); 47 forms.processing($form, true); 48 49 var robots = null; 50 for (var i = 0; i < arr.length; i++) { 51 var a = arr[i]; 52 if (a.name === 'g-recaptcha-response' && a.value) { 53 robots = a.value; 54 } 55 } 56 57 if (!robots) { 58 alert('Are you a robot?'); 59 forms.enable($form); 60 forms.processing($form, false); 61 return false; 62 } 63 arr.push({ name: 'Robots', value: robots }); 64 return true; 65 }, 66 67 subscribeFormConfig: function ($form) { 68 return { 69 beforeSubmit: function (arr, $form, options) { 70 return forms.captchaBeforeSubmit(arr, $form, options); 71 }, 72 success: function (responseText, statusText, xhr, $form) { 73 forms.success($form, 'Subscribed'); 74 }, 75 error: function () { 76 forms.enable($form); 77 forms.processing($form, false); 78 alert('There was an error with your request. Please validate your input and try again!'); 79 } 80 }; 81 } 82}; 83 84var cart = { 85 _keys: { 86 items: 'artcld_shopping_cart_items', 87 itemsV2: 'artcld_shopping_cart_items_v2', 88 promoCode: 'artcld_shopping_cart_promo_code' 89 }, 90 init: function (sub) { 91 cart.update(cart.getItemsFromStorage(), sub); 92 }, 93 formatUrl: function (editions, sub) { 94 var _sub; 95 if (sub && sub.length > 0) { 96 _sub = 'sub=' + sub; 97 } 98 var url = '/buy/'; 99 if (editions && editions.length > 0) { 100 const editionIds = []; 101 const framed = []; 102 editions.forEach(d => { 103 editionIds.push(d.EditionId); 104 framed.push(d.IsFramed || false); 105 }); 106 url += ('?editionId=' + editionIds.join('&editionId=') + '&framed=' + framed.join('&framed=') + (_sub ? '&' + _sub : '')); 107 } else if (_sub) { 108 url += ('?' + _sub); 109 } 110 return url; 111 }, 112 getItemsFromStorage: function () { 113 return JSON.parse(localStorage.getItem(cart._keys.itemsV2)) || []; 114 }, 115 getPromoCodeFromStorage: function () { 116 return localStorage.getItem(cart._keys.promoCode); 117 }, 118 setItems: function (editions, sub) { 119 localStorage.setItem(cart._keys.itemsV2, JSON.stringify(editions)); 120 cart.update(editions, sub); 121 }, 122 setPromoCode: function (promoCodeId) { 123 localStorage.setItem(cart._keys.promoCode, promoCodeId); 124 }, 125 update: function (editions, sub) { 126 var editionsCount = editions.length; 127 $('.cart__btn').attr('href', cart.formatUrl(editions, sub)); 128 if (editionsCount > 0) { 129 $('.cart__counter').text(editionsCount).show(); 130 } 131 else { 132 $('.cart__counter').hide(); 133 } 134 } 135}; 136 137var cookie = { 138 _cookiePolicy: 'artcld_cookie_policy', 139 _referrer: 'artcld_referrer', 140 _subscribe: 'artcld_subscribe_cookie', 141 _utm: 'artcld_utm', 142
143 setCookie: function (cname, cvalue, exdays) { 144 var d = new Date(); 145 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 146 var expires = "expires=" + d.toUTCString(); 147 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 148 }, 149 getCookie: function (cname) { 150 var name = cname + "="; 151 var ca = document.cookie.split(';'); 152 for (var i = 0; i < ca.length; i++) { 153 var c = ca[i]; 154 while (c.charAt(0) === ' ') { 155 c = c.substring(1); 156 } 157 if (c.indexOf(name) === 0) { 158 return c.substring(name.length, c.length); 159 } 160 } 161 return ""; 162 } 163}; 164 165// Polyfills 166 167if (!String.prototype.replaceAll) { 168 String.prototype.replaceAll = function (str, newStr) { 169 if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') { 170 return this.replace(str, newStr); 171 } 172 return this.replace(new RegExp(str, 'g'), newStr); 173 }; 174}
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.