1(() => { 2 "use strict"; 3 4//console.log("PR.JS TOP executed, readyState=", document.readyState); 5 6 7 // -------------------------- 8 // Constants / Enums 9 // -------------------------- 10 const UK = 0; 11 const USA = 1; 12 const Canada = 2; 13 const Australia = 3; 14 const SaudiArabia = 4; 15 const Europe_notUK = 5; 16 const SouthAfrica = 6; 17 18 const country = ["UK", "USA", "Canada", "Australia", "Saudi Arabia", "Europe (not UK)", "South Africa"]; 19 const country_tag = ["UK", "USA", "CANADA", "AUSTRALIA", "ARABIA", "EUROPE", "AFRICA"]; 20 const currency = ["GBP", "USD", "CAD", "AUD", "SAR", "EUR", "ZAR"]; 21 const currency_code = ["GBP", "USD", "CAD", "AUD", "USD", "EUR", "USD"]; 22 23 const PAYPAL = 0; 24 const DISPLAY = 1; 25 26 // Expose these if other scripts rely on them 27 // (Old code treated them like globals.) 28 window.UK = UK; 29 window.USA = USA; 30 window.Canada = Canada; 31 window.Australia = Australia; 32 window.SaudiArabia = SaudiArabia; 33 window.Europe_notUK = Europe_notUK; 34 window.SouthAfrica = SouthAfrica; 35 36 37 // -------------------------- 38 // Helpers 39 // -------------------------- 40 function explicit(amount) { 41 const fact = 5; 42 return Math.ceil(Math.round(amount) / fact) * fact; 43 } 44 45 function isInteger(n) { 46 return n - Math.floor(n) === 0; 47 } 48 49 50 51 function safeCurrencyConvert(amount, from, to) { 52 // CoinMill provides currency_convert(). Under CSP/lockdown/adblock it may be missing. 53 if (typeof window.currency_convert !== "function") return null; 54 try { 55 return window.currency_convert(amount, from, to) * 1; 56 } catch { 57 return null; 58 } 59 } 60 61 62 function convert(unitPriceGBP, currCurrencyIndex) { 63 // Returns [PAYPAL_amount, DISPLAY_amount] in target currency 64 // If conversion unavailable, fall back to "GBP only" by returning GBP values. 65 const convertedDisplay = safeCurrencyConvert(unitPriceGBP, currency[UK], currency[currCurrencyIndex]); 66 if (convertedDisplay == null) return [unitPriceGBP, unitPriceGBP]; 67 68 const display = explicit(convertedDisplay); 69 const convertedPaypal = safeCurrencyConvert(display, currency[currCurrencyIndex], currency_code[currCurrencyIndex]); 70 const paypal = explicit(convertedPaypal == null ? display : convertedPaypal); 71 72 return [paypal, display]; 73 } 74 75 76 // -------------------------- 77 // Product IDs (kept stable) 78 // -------------------------- 79 const dummy = 0; 80 81 const DM_1 = 1; /*Affe mit Schädel Powderhall*/ 82 const DM_2 = 2; /*Bronze Darwin Bust*/ 83 const DM_3 = 3; /*Jesmonite Darwin Bust*/ 84 const DM_4 = 11; /*Darwin Monkey Thomas*/ 85 const DM_5 = 12; /*unique Darwin Monkey Thomas*/ 86 const JP_1 = 4; /*Darwin Head*/ 87 const JP_2 = 5; /*Marine Iguanas*/ 88 const JP_3 = 6; /*Blue Footed Boobies*/ 89 const JP_4 = 7; /*Galápagos Tortoise*/ 90 const JP_5 = 8; /*Galápagos Sea Lions*/ 91 const JP_6 = 9; /*Galápagos Penguins*/ 92 const JP_7 = 10; /*Darwin Maquette*/ 93 94 // Expose these because your HTML and other scripts may refer to them. 95 window.DM_1 = DM_1; 96 window.DM_2 = DM_2; 97 window.DM_3 = DM_3; 98 window.DM_4 = DM_4; 99 window.DM_5 = DM_5; 100 window.JP_1 = JP_1; 101 window.JP_2 = JP_2; 102 window.JP_3 = JP_3; 103 window.JP_4 = JP_4; 104 window.JP_5 = JP_5; 105 window.JP_6 = JP_6; 106 window.JP_7 = JP_7; 107 108 const ID = [ 109 "dummy", 110 "DM_1", 111 "DM_2", 112 "DM_3", 113 "JP_1", 114 "JP_2", 115 "JP_3", 116 "JP_4", 117 "JP_5", 118 "JP_6", 119 "JP_7", 120 "DM_4", 121 "DM_5", 122 ]; 123 124 const unit = [ 125 "zero-based offset", 126 "Affe mit Schädel", 127 "Bronze Darwin Bust", 128 "Jesmonite Darwin Bust", 129 "Darwin Head", 130 "Marine Iguanas", 131 "Blue Footed Boobies", 132 "Galápagos Tortoise", 133 "Galápagos Sea Lions", 134 "Galápagos Penguins", 135 "Darwin Maquette", 136 "Affe mit Schädel", 137 "unique Darwin Monkey", 138 ]; 139 140 const originalprice = [ 141 dummy, 142 3500, /* DM_1 */ 143 385, /* DM_2 */ 144 150, /* DM_3 */ 145 695, /* JP_1 */ 146 645, /* JP_2 */ 147 795, /* JP_3 */ 148 745, /* JP_4 */ 149 765, /* JP_5 */ 150 795, /* JP_6 */ 151 2595, /* JP_7 */ 152 850, /* DM_4 */ 153 1200, /* DM_5 */ 154 ]; 155 156 const unitprice = [ 157 dummy, 158 2999, /* DM_1 */ 159 350, /* DM_2 */ 160 105, /* DM_3 */ 161 434, /* JP_1 */ 162 404, /* JP_2 */ 163 497, /* JP_3 */ 164 466, /* JP_4 */ 165 479, /* JP_5 */ 166 497, /* JP_6 */ 167 1622, /* JP_7 */ 168 725, /* DM_4 */ 169 1200, /* DM_5 */ 170 ]; 171 172 // -------------------------- 173 // VAT / Shipping 174 // -------------------------- 175 const VATrate = 20; 176 const noVAT = false;
177 178 const VAT = [ 179 0, 180 noVAT, noVAT, noVAT, 181 noVAT, noVAT, noVAT, noVAT, noVAT, noVAT, noVAT, 182 noVAT, noVAT, 183 ]; 184 185 const MAIL_ETC_packaging = 15; 186 const FREE_packaging = 0; 187 const FREE_shipping = 0; 188 const UK_shipping = 20; 189 190 const shipping_to_pay = [ 191 dummy, 192 FREE_shipping + FREE_packaging, 193 FREE_shipping + FREE_packaging, 194 FREE_shipping + FREE_packaging, 195 UK_shipping, 196 UK_shipping, 197 UK_shipping, 198 UK_shipping, 199 UK_shipping, 200 UK_shipping, 201 UK_shipping, 202 FREE_shipping + FREE_packaging, 203 FREE_shipping + FREE_packaging, 204 ]; 205 206 // -------------------------- 207 // Pricing rendering 208 // -------------------------- 209 const PRODUCTPAGE = true; 210 const INDEXPAGE = false; 211 212 213 function ConvertPrice(id, unit_price_gbp) { 214 let decpl = isInteger(unit_price_gbp) ? 0 : 2; 215 216 // Always show GBP 217 let str = "£" + unit_price_gbp.toFixed(decpl); 218 219 // If conversion is available, append USD/EUR. If not, stay GBP-only. 220 const usd = convert(unit_price_gbp, USA); 221 const eur = convert(unit_price_gbp, Europe_notUK); 222 223 if (usd[DISPLAY] !== unit_price_gbp) { 224 decpl = isInteger(usd[DISPLAY]) ? 0 : 2; 225 str += " / $" + usd[DISPLAY].toFixed(decpl); 226 } 227 228 if (eur[DISPLAY] !== unit_price_gbp) { 229 decpl = isInteger(eur[DISPLAY]) ? 0 : 2; 230 str += " / €" + eur[DISPLAY].toFixed(decpl); 231 } 232 233 return str; 234 } 235 236 237 function getDiscount(id, original_price, unit_price, product_page) { 238 let decpl = 2; 239 if (isInteger(unit_price) && isInteger(original_price)) decpl = 0; 240 let percentsaving = 1 - (unit_price.toFixed(decpl) / original_price.toFixed(decpl)); 241 percentsaving = Math.ceil(percentsaving * 100); 242 while (Math.ceil(percentsaving) % 5) percentsaving++; 243 return percentsaving + "%"; 244 } 245 246 function applyVatAndShipping(unitID, rawUnitPrice, rawOriginalPrice) { 247 let unit_price = rawUnitPrice; 248 let original_price = rawOriginalPrice; 249 250 if (VAT[unitID]) { 251 unit_price = unit_price * (1 + (VATrate / 100)); 252 original_price = original_price * (1 + (VATrate / 100)); 253 } 254 255 unit_price = unit_price + shipping_to_pay[unitID]; 256 original_price = original_price + shipping_to_pay[unitID]; 257 258 return { unit_price, original_price }; 259 } 260 261 262 function PriceOrDiscount(id, unitID) { 263 const { unit_price, original_price } = applyVatAndShipping(unitID, unitprice[unitID], originalprice[unitID]); 264 265 const dom = document.getElementById("discount_" + id); 266 if (!dom) return; 267 268 if (unit_price >= original_price) { 269 dom.innerHTML = ConvertPrice(id, unit_price); 270 dom.style.width = "99%"; 271 dom.style.textAlign = "center"; 272 dom.style.paddingLeft = "0px"; 273 dom.style.fontSize = "16px"; 274 dom.style.color = "#14790C"; 275 } else { 276 dom.style.backgroundImage = "url('images/discount.png')"; 277 dom.style.backgroundSize = "110px 30px"; 278 dom.style.backgroundRepeat = "no-repeat"; 279 dom.innerHTML = getDiscount(id, original_price, unit_price, INDEXPAGE); 280 } 281 } 282 283 function PricesOrDiscounts() { 284 PriceOrDiscount("DM_1", DM_1); 285 PriceOrDiscount("DM_2", DM_2); 286 PriceOrDiscount("DM_3", DM_3); 287 PriceOrDiscount("DM_4", DM_4); 288 PriceOrDiscount("DM_5", DM_5); 289 PriceOrDiscount("JP_1", JP_1); 290 PriceOrDiscount("JP_2", JP_2); 291 PriceOrDiscount("JP_3", JP_3); 292 PriceOrDiscount("JP_4", JP_4); 293 PriceOrDiscount("JP_5", JP_5); 294 PriceOrDiscount("JP_6", JP_6); 295 PriceOrDiscount("JP_7", JP_7); 296 } 297 298 299 300 function price(id, unitID) { 301 302 //console.log("********** PR.JS price LOADED"); 303 304 const { unit_price, original_price } = applyVatAndShipping(unitID, unitprice[unitID], originalprice[unitID]); 305 306 //console.log("********** SECTION 1.1 COMPLETE"); 307 308 const buybox = document.getElementById("buybox"); 309 if (buybox) buybox.style.background = "none"; 310 311 //console.log("********** SECTION 1.2 COMPLETE"); 312 313 const priceDom = document.getElementById("price"); 314 if (!priceDom) return; 315 316 //console.log("********** SECTION 1.3 COMPLETE"); 317 318 priceDom.style.textAlign = "left"; 319 priceDom.style.padding = "10px"; 320 321 //console.log("********** SECTION 1.4 COMPLETE"); 322 323 324 let spacer = 0; 325 let str = 326 '<div style="text-align:center;"><span style="color:#b12704;font-size:14px;">' + 327 ConvertPrice(id, unit_price) + 328 "</span></div>"; 329 330 if (unit_price < original_price) { 331 str += 332 '<div style="z-index:0;color:#888;">RRP: <span style="text-decoration: line-through;font-size:12px;">' + 333 ConvertPrice(id, original_price) + 334 "</span></div>"; 335 str += 336 '<div style="z-index:1;">You Save: <span style="color:black;font-size:14px;">' + 337 getDiscount(id, original_price, unit_price, PRODUCTPAGE) + 338 "</span></div>"; 339 } else { 340 str += '<div style="margin:8px 0 7px 0;"><img src="images/curlicue.jpg" style="width:150px;"></div>'; 341 } 342 343 str += '<div style="margin-top:' + spacer + 'px;text-align: center;"><span style="color:#0066c0;font-size:12px;">FREE Delivery'; 344 345 if (shipping_to_pay[unitID] === UK_shipping) { 346 str += ' in the UK<div class="mailtolink">Please <a href="mailto:[email protected]?subject=Darwin Monkey International Shipping Enquiry">enquire</a> about your location</div>'; 347 } else { 348 str += " Worldwide"; 349 } 350 str += "</span></div>"; 351 352 str += '<div id="Avail" style="color:#090;font-size:13px;text-align: center;">
352Available <span id="availability">for commission</span>.</div>'; 353 str += '<div id="delivery_time" style="color:black;font-size:8px;text-align: center;">Estimating dispatch within <span>15 weeks</span>.</div>'; 354 str += '<div id="contact_invite" style="text-align:center;margin-top:10px;color:#0066c0;font-size:11px;">Please contact us for more details and to place your order<div style="font-size:10px;"><a style="margin-left:0px;font-weight:bold;" href="mailto:[email protected]?subject=Darwin Monkey Enquiry">[email protected]</a></div>.</div>'; 355 356 priceDom.innerHTML = str; 357 358 const button = document.getElementById("button"); 359 if (button) { 360 button.style.visibility = "visible"; 361 if (typeof window.mobile === "function" && window.mobile()) { 362 button.style.position = "relative"; 363 button.style.top = "90px"; 364 } 365 const isSafari = navigator.userAgent.includes("Safari") && !navigator.userAgent.includes("Chrome"); 366 if (isSafari) { 367 button.style.position = "relative"; 368 button.style.left = "5px"; 369 button.style.top = "10px"; 370 } 371 } 372 373 } 374 375 376 377 // -------------------------- 378 // Image/zoom helpers (kept compatible) 379 // -------------------------- 380 function setImg(item, img) { 381 locImg(item, img, 0, 0); 382 if (window.jQuery) window.jQuery(".zoomContainer").width("275px"); 383 } 384 385 function locImg(item, img, x, y) { 386 if (!window.jQuery) return; 387 window.jQuery("#mainviewport").html( 388 '<a class="group1 cboxElement" href="images/DM_' + item + '/medium/' + img + '.jpg">' + 389 '<img src="images/DM_' + item + '/small/' + img + '.jpg" id="mainimgX" class="mainimg" data-zoom-image="images/DM_' + item + '/' + img + '.jpg"/>' + 390 '<img id="magnif" class="magn" src="images/zoom.png"></a>' + 391 '<img id="magnifier" class="magn" src="images/magnif.png">' 392 ); 393 394 const $img = window.jQuery("#mainimgX"); 395 if (typeof $img.elevateZoom === "function") { 396 $img.elevateZoom({ zoomWindowPosition: "specs", zoomWindowHeight: 531, zoomWindowWidth: 495, borderSize: 1, easing: true }); 397 } 398 } 399 400 window.setImg = setImg; 401 window.locImg = locImg; 402 403 404function initPricing() { 405 //console.log("PR.JS initPricing fired; readyState=", document.readyState); 406 407 try { 408 if (document.getElementById("buybox") && document.getElementById("price")) { 409 price("DM_1", DM_1); 410 } 411 412 PricesOrDiscounts(); 413 } catch (e) { 414 //console.error("Pricing init crashed:", e); 415 } 416} 417 418if (document.readyState === "loading") { 419 document.addEventListener("DOMContentLoaded", initPricing); 420} else { 421 initPricing(); 422} 423 424window.addEventListener("DOMContentLoaded", () => { 425 if (typeof window.setImg === "function") window.setImg(1, 7); 426}); 427 428 // -------------------------- 429 // Export only what legacy HTML expects 430 // -------------------------- 431 window.price = price; 432 window.PricesOrDiscounts = PricesOrDiscounts; 433 window.PriceOrDiscount = PriceOrDiscount; 434 window.ConvertPrice = ConvertPrice; 435 // window.setImg = setImg; 436 // window.locImg = locImg; 437 438 // If you still need these arrays globally: 439 window.country = country; 440 window.country_tag = country_tag; 441 window.currency = currency; 442 window.currency_code = currency_code; 443 window.ID = ID; 444 window.unit = unit; 445})();
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.