1 2if (window.addEventListener) { 3 window.addEventListener("load", ft_init, false); 4 window.addEventListener("resize", ft_resize, false); 5} else if (window.attachEvent) { 6 window.attachEvent("onload", ft_init); 7 window.attachEvent("onresize", ft_resize); 8} 9if (document.readyState === "complete") setTimeout(function () { ft_init(); }, 100); 10 11 12function logFerve(s) { 13 ferve.log(s, "border-left:2px solid blue;padding-left: 4px;"); 14} 15 16var darkIntroImage = false; 17 18 19// #mark ------ Initialisation ------ 20 21function ft_init(e) { 22 //if (!ferve) ferve = new Ferve(); 23 logFerve("ft_init()", "info"); 24 25 if (e && !e.isTrusted) { 26 logFerve("exiting !e.isTrusted", "info"); 27 return; 28 } 29 30 var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; 31 var x = document.getElementById("ft_intro"); 32 if (x) x.style.height = (h - 150) + "px"; 33 34 var bodyID = document.body.id; 35 36 x = document.getElementById("ft_background"); 37 if (!x) { 38 x = document.getElementById("ft_mouse"); 39 if (x) x.style.display = "none"; 40 } else { 41 if (bodyID == "ft_home") { 42 if (window.addEventListener) { 43 window.addEventListener("scroll", ft_scroll, false); 44 } else if (window.attachEvent) { 45 window.attachEvent("onscroll", ft_scroll); 46 } 47 } else { 48 x = document.getElementById("ft_headerBG"); 49 if (x) x.className = "ft_scrolled"; 50 x = document.getElementById("ft_header"); 51 if (x) x.className = "ft_scrolled"; 52 } 53 54 var rgb; 55 var navIcons = document.querySelectorAll("div[data-name]"); 56 var rect = (navIcons.length > 0 ? navIcons[0].getBoundingClientRect() : null); 57 58 if (rect) { 59 if (bodyID == "ft_home") { 60 rgb = ft_getAverageRGB("ft_background", rect.left, rect.top, 100, 20); 61 } else if (x) { 62 rgb = ft_getAverageRGB("ft_eventImage", rect.left, rect.top, 100, 20); 63 } 64 } 65 if (rgb) { 66 var brightness = ((rgb.r * 299) + (rgb.g * 587) + (rgb.b * 114)) / 1000; 67 if (brightness < 190) darkIntroImage = true; 68 logFerve("image brightness: " + brightness + " (darkIntroImage: " + darkIntroImage + ")"); 69 } 70 ft_updateFerveNavigation(); 71 } 72 73 var maps = document.querySelectorAll("div[data-map]"); 74 if (maps.length > 0) { 75 var loadMaps = false; 76 var divids = "", key = ""; 77 for (var i = 0; i < maps.length; i++) { 78 if (!key && maps[i].getAttribute("data-key") != null) key = maps[i].getAttribute("data-key"); 79 if (maps[i].getAttribute("data-latitude").length > 0 && maps[i].getAttribute("data-longitude").length > 0) { 80 if (maps[i].id == "venueMap") { 81 var latitude = maps[i].getAttribute("data-latitude"); 82 var longitude = maps[i].getAttribute("data-longitude"); 83 if (latitude.length == 0 || longitude.length == 0) continue; 84 var zoom = parseInt(maps[i].getAttribute("data-zoom")); 85 if (isNaN(zoom)) zoom = 14; 86 var title = maps[i].getAttribute("data-title"); 87 if (title == "null") { 88 var x = document.getElementsByTagName("h1"); 89 if (x) { 90 title = x[x.length - 1].innerText; 91 } 92 } 93 var query = maps[i].getAttribute("data-query"); 94 if (!ferve.isNullOrEmpty(query)) { 95 if (query.indexOf("place_id") == -1) { 96 var h2 = document.createElement("h2"); 97 h2.innerText = title; 98 maps[i].appendChild(h2); 99 } 100 } else { 101 query = title; 102 } 103 query = encodeURIComponent(query).split("%20").join("+") 104 105 var iframe = document.createElement("iframe"); 106 iframe.setAttribute("src", "https://www.google.com/maps/embed/v1/place?key=" + key + "&q=" + query + "¢er=" + latitude + "," + longitude + "&zoom=" + zoom); 107 iframe.setAttribute("allowFullScreen", ""); 108 iframe.style.width = "100%"; 109 iframe.style.height = "100%"; 110 iframe.style.border = "none"; 111 maps[i].appendChild(iframe); 112 113 continue; 114 } 115 116 var bodyids = maps[i].getAttribute("data-bodyids"); 117 if (bodyID.length == 0) { 118 if (bodyids.length == 0) { 119 loadMaps = true; 120 } else { 121 divids += maps[i].getAttribute("id") + ","; 122 } 123 } else { 124 if (!bodyids || bodyids.length == 0) { 125 loadMaps = true; 126 } else { 127 bodyids = bodyids.split(","); 128 for (var j = 0; j < bodyids.length; j++) { 129 if (bodyID == bodyids[j]) { 130 loadMaps = true; 131 } else { 132 divids += maps[i].getAttribute("id") + ","; 133 } 134 } 135 } 136 } 137 } else { 138 divids += maps[i].getAttribute("id") + ","; 139 } 140 } 141 if (divids.length > 0) { 142 divids = divids.split(","); 143 for (var i = 0; i < divids.length; i++) { 144 if (divids[i].length == 0) continue;
145 var x = document.getElementById(divids[i]); 146 if (x) x.style.display = "none"; 147 } 148 } 149 150 if (loadMaps) { 151 var script = document.createElement("script"); 152 script.src = document.location.protocol + "//maps.googleapis.com/maps/api/js?callback=ft_initMaps&key=" + key; 153 document.body.appendChild(script); 154 } 155 } 156 157 if (bodyID == "ft_event") { 158 var gBoxes = ["ft_eventVenueInformation", "ft_eventVenueTransport", "ft_eventVenueAccessibility"]; 159 for (var i = 0; i < gBoxes.length; i++) { 160 ft_createEllipsisElement(gBoxes[i]); 161 } 162 var selected = false; 163 for (var i = 0; i < gBoxes.length; i++) { 164 var x = document.getElementById(gBoxes[i]); 165 if (x) { 166 if (!selected && x.innerHTML.length > 0) { 167 x.style.display = ""; 168 x.style.opacity = 1; 169 x = document.getElementById("gb" + i); 170 x.className = "ft_greyBoxTab ft_greyBoxTabSelected"; 171 selected = true; 172 } else { 173 x.style.display = "none"; 174 x.style.opacity = 1; 175 x = document.getElementById("gb" + i); 176 x.className = "ft_greyBoxTab"; 177 } 178 } 179 } 180 var x = document.getElementById("ft_eventVenuePlaceHolder"); 181 if (x) x.style.display = "none"; 182 ft_toggleGreyBoxTab(-1); 183 } 184 185 186 var forms = document.getElementsByTagName("form"); 187 for (var i = 0; i < forms.length; i++) { 188 forms[i].addEventListener("submit", function (e) { 189 ferve.toggleWaiting(true); 190 }, false); 191 } 192 193 194 var icons = document.getElementsByClassName("ft_footerSocial"); 195 if (icons && icons.length > 0) { 196 icons = icons[0].getElementsByTagName("a"); 197 for (var i = 0; i < icons.length; i++) { 198 var url = document.URL; 199 if (icons[i].href == url) icons[i].style.display = "none"; 200 } 201 } 202 203 204 var pops = document.querySelectorAll(".ft_pops"); 205 if (pops.length > 0) { 206 var div = document.getElementById("ft_pops-image"); 207 if (!div) { 208 div = document.createElement("div"); 209 div.id = "ft_pops-image"; 210 div.addEventListener("click", function (e) { 211 ferve.toggleOverlay(0); 212 }); 213 var image = document.createElement("img"); 214 div.appendChild(image); 215 document.body.appendChild(div); 216 } 217 for (var i = 0; i < pops.length; i++) { 218 pops[i].style.cursor = "nesw-resize"; 219 pops[i].addEventListener("click", function (e) { 220 // Show the image 221 var popsSource = e.target; 222 var popsImage = document.getElementById("ft_pops-image"); 223 var image = popsImage.getElementsByTagName("img")[0]; 224 image.src = popsSource.src; 225 popsImage.style.display = "inline-block"; 226 setTimeout(function () { 227 popsImage.classList.add("ft_pops-visible"); 228 }, 100); 229 ferve.toggleOverlay(1, false, function () { 230 // hide the image 231 popsImage.classList.remove("ft_pops-visible"); 232 setTimeout(function () { 233 popsImage.style.display = "none"; 234 }, 500); 235 }); 236 }, false); 237 } 238 } 239} 240 241 242function ferveInitComplete() { 243 /* // TODO remove var customers = document.querySelectorAll("[data-customer]"); 244 if (customers.length > 0) { 245 for (var i = 0; i < customers.length; i++) { 246 var s = customers[i].getAttribute("data-customer"); 247 if (s == "1") s = ""; 248 customers[i].innerHTML = (ferve.visitor.firstName.length > 0 ? ferve.visitor.firstName : s); 249 } 250 }*/ 251} 252 253function ft_fta() { 254 // Dark intro image 255 return ferve.utility.queryStringValue("fta", document.getElementById("ft_JS").getAttribute("src")) == "1"; 256} 257 258 259// #mark ------ Event listeners ------ 260 261function ft_scroll(event) { 262 var x = document.getElementById("ft_headerBG"); 263 var y = document.getElementById("ft_header"); 264 if (!x || !y) return; 265 var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop; 266 if (top < 100) { 267 x.className = ""; 268 y.className = ""; 269 } else { 270 x.className = "ft_scrolled"; 271 y.className = "ft_scrolled"; 272 } 273 var o = 200 - top; 274 if (o < 0) o = 0; 275 o = o / 100; 276 x = document.getElementById("ft_ferveLogo"); 277 if (x) x.style.opacity = o; 278 ft_updateFerveNavigation(); 279 280 if (menuActive) ft_toggleNavMenu(); 281 282 x = document.getElementById("ft_mouse"); 283 if (x) { 284 o = 80 - top; 285 if (o < 0) o = 0; 286 o = o / 100; 287 x.style.opacity = o; 288 } 289} 290 291//MP : Handling 404 images 292function ft_image404(image) { 293 image.currentSrc = " "; 294 if (image.id != "") document.getElementById(image.id.toString()).style.display = "none"; 295} 296 297function ft_resize(event) { 298 if (menuActive) return; 299 var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 300 var x = document.getElementById("ft_menu"); 301 if (!x) return; 302 x.style.opacity = (w > 568 ? 1 : 0); 303}; 304 305 306 307// #mark ------ Ferve ------ 308 309function ft_updateFerveNavigation() { 310 if (!document.getElementById("ft_header")) return; 311 var scrolled = document.getElementById("ft_header"); 312 if (scrolled) scrolled = (scrolled.className.indexOf("ft_scrolled") > -1); 313 var navIcons = document.querySelectorAll("div[data-name]"); 314 for (var i = 0; i < navIcons.length; i++) { 315 if (navIcons[i].getAttribute("data-name") != "navIcon") continue; 316 if (scrolled) { 317 //logFerve("setting nav icons to gray"); 318 navIcons[i].className = navIcons[i].className.replace("ft_black", "ft_grey"); 319 navIcons[i].className = navIcons[i].className.replace("ft_white", "ft_grey"); 320 } else if (darkIntroImage) { 321 //logFerve("setting nav icons to white"); 322 navIcons[i].className = navIcons[i].className.replace("ft_black", "ft_white"); 323 navIcons[i].className = navIcons[i].className.replace("ft_grey", "ft_white"); 324 } else { 325 //logFerve("setting nav icons to black"); 326 navIcons[i].className = navIcons[i].className.replace("ft_white", "ft_black"); 327 navIcons[i].className = navIcons[i].className.replace("ft_grey", "ft_black"); 328 } 329 } 330 if (!darkIntroImage) { 331 var navigation = document.getElementById("ft_navigation"); 332 if (navigation) navigation.className += "dark"; 333 } 334} 335 336 337var menuActive = false; 338function ft_toggleNavMenu() { 339 var x = document.getElementById("ft_menu"); 340 menuActive = !menuActive; 341 x.style.opacity = (menuActive ? 1 : 0); 342 x.className = (menuActive ? "ft_open" : "ft_closed"); 343 if ("ontouchend" in window) { 344 if (menuActive) { 345 document.body.addEventListener("touchend", ft_touchEnd, false); 346 } else { 347 document.body.removeEventListener("touchend", ft_touchEnd, false); 348 } 349 } 350} 351 352 353function ft_toggleGreyBoxTab(sel) {
354 var gBoxes = ["ft_eventVenueInformation", "ft_eventVenueTransport", "ft_eventVenueAccessibility"]; 355 for (var i = 0; i < gBoxes.length; i++) { 356 var x = document.getElementById("gb" + i); 357 var selected = false; 358 if (x) { 359 selected = ((sel != -1 && i == sel) || (sel == -1 && x.className.indexOf("ft_greyBoxTabSelected") != -1)); 360 x.className = (selected ? "ft_greyBoxTab ft_greyBoxTabSelected" : "ft_greyBoxTab"); 361 } 362 x = document.getElementById(gBoxes[i]); 363 if (x) x.style.display = (selected ? "" : "none"); 364 if (sel != -1) ft_toggleEllipsis(gBoxes[i], false); 365 } 366 367} 368 369function ft_touchEnd(e) { 370 var t = e.target; 371 var x = document.getElementById("ft_menu"); 372 while (t.parentNode) { 373 if (t == x) return; 374 t = t.parentNode; 375 } 376 e.preventDefault(); 377 ft_toggleNavMenu(); 378} 379 380 381// #mark ------ Ellipsis content ------ 382 383var ft_ellipsisContent = new Array(); 384 385function ft_toggleEllipsis(id, toggle) { 386 var x = document.getElementById(id); 387 if (!x) return; 388 if (toggle && x.innerHTML.substring(x.innerHTML.length - 3) != "...") { 389 ft_createEllipsisElement(id); 390 return; 391 } 392 x.className = x.className.replace("ft_abbreviated", "ft_full"); 393 for (var i = 0; i < ft_ellipsisContent.length; i++) { 394 if (ft_ellipsisContent[i][0] == id) { 395 x.innerHTML = ft_ellipsisContent[i][1]; 396 break; 397 } 398 } 399} 400 401function ft_createEllipsisElement(id) { 402 var x = document.getElementById(id); 403 if (!x) { 404 //logFerve("ft_createEllipsisElement(" + id + ") element not found **", "info"); 405 return; 406 } 407 x.style.display = ""; 408 var logContent = true; 409 for (var i = 0; i < ft_ellipsisContent.length; i++) { 410 if (ft_ellipsisContent[i][0] == id) { 411 logContent = false; 412 break; 413 } 414 } 415 if (logContent) ft_ellipsisContent[ft_ellipsisContent.length] = [id, x.innerHTML]; 416 x.className = x.className.replace("ft_full", "ft_abbreviated"); 417 var s = x.innerHTML; 418 s = s.replace(/<br>/ig, " "); 419 s = s.replace(/<br \/>/ig, " "); 420 s = s.replace(/<\/p>/ig, " "); 421 var regex = /(<([^>]+)>)/ig 422 s = s.replace(regex, ""); 423 var wordArray = s.split(" "); 424 while (x.scrollHeight > x.offsetHeight) { 425 wordArray.pop(); 426 x.innerHTML = wordArray.join(" ") + "..."; 427 } 428 if (x.length == null || x.onclick.indexOf("ft_toggleEllipsis") == -1) x.onclick = function () { ft_toggleEllipsis(id, true); }; 429} 430 431 432// #mark ------ Sharing ------ 433 434function ft_share(mode, url, message, hashTag) { 435 logFerve("ft_share(" + mode + ", " + url + ", " + message + ", " + hashTag + ")"); 436 if (!url || url.length == 0) url = window.location.href; 437 438 var x = document.getElementById("chkWishlist"); 439 var wishlist = (x ? x.checked : true); 440 x = document.getElementById("chkPurchased"); 441 var purchased = (x ? x.checked : false); 442 url += (wishlist ? "1" : "0") + (purchased ? "1" : "0"); 443 message = message.replace("[url]", url); 444 if (wishlist && purchased) { 445 message = message.replace("My Wishlist", "My Wishlist / Sessions"); 446 } if (!wishlist && purchased) { 447 message = message.replace("My Wishlist", "My Sessions"); 448 } 449 450 451 if (mode == 1) { 452 // Calendar 453 var hashes = ""; 454 if (message != null && message == "T") { 455 456 // Merchandise items cannot be added to your calendar. 457 var merchandiseChecked = document.querySelectorAll("input[type='checkbox'][data-time='null']:checked"); 458 if (merchandiseChecked.length > 0) { 459 var x = document.getElementById("viewICS"); 460 ferve.notification.show("local", "red", "Merchandise items cannot be added to your calendar", null, x.getBoundingClientRect(), null); 461 } 462 463 // Add Tickets 464 var checkboxes = document.querySelectorAll("input[type='checkbox']"); 465 for (var i = 0; i < checkboxes.length; i++) { 466 if (checkboxes[i].checked) { 467 hashes += "&hashes=" + checkboxes[i].value; 468 } 469 } 470 if (hashes.length == 0) { 471 var x = document.getElementById("viewICS"); 472 ferve.notification.show("local", "red", "Please select a ticket", null, x.getBoundingClientRect(), null); 473 return; 474 } 475 476 } 477 document.location.href = ferve.url + "api/v1/Items/ICS/?" + (message != null ? "hash=" + message + "&" : "") + (hashes != null ? "hashes=" + hashes + "&" : "") + "rand=" + ferve.returnUniqueID(); 478 479 } else if (mode == 2) { 480 // Twitter / X 481 message = encodeURIComponent(message); 482 ferve.openWindow(2, "https://x.com/intent/tweet?url=" + encodeURIComponent(url.substring(0, url.length - 2)) + "&text=" + message + "&hashtags=" + encodeURIComponent(hashTag.replace("#", "")) + "&via=FerveTickets", "FTShareTW", "toolbar=no,menubar=no,scrollbars=no,resizable=false,width=550,height=350"); 483 484 } else if (mode == 3) { 485 // Facebook 486 ferve.openWindow(2, "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(url.substring(0, url.length - 2)), "FTShareFB", "toolbar=no,menubar=no,scrollbars=no,resizable=false,width=550,height=350"); 487 488 } else if (mode == 4) { 489 // Email 490 var url = "mailto:?subject=" + escape(hashTag) + "&body=" + escape(message); 491 url = url.replace(/%5Bn%5D/g, "%0D%0A"); 492 document.location.href = url; 493 494 } 495} 496 497 498// #mark ------ Mapping ------ 499 500var googleMaps = new Array(); 501function ft_initMaps() { 502 logFerve("ft_initMaps()", "info"); 503 var maps = document.querySelectorAll("div[data-map]"); 504 if (maps.length == 0) return 505 for (var i = 0; i < maps.length; i++) { 506 var key = maps[i].getAttribute("data-key"); 507 var latitude = maps[i].getAttribute("data-latitude"); 508 var longitude = maps[i].getAttribute("data-longitude"); 509 if (latitude.length == 0 || longitude.length == 0) continue; 510 latitude = latitude.split(","); 511 longitude = longitude.split(","); 512 var zoom = parseInt(maps[i].getAttribute("data-zoom")); 513 if (isNaN(zoom)) zoom = 14; 514 var styles = maps[i].getAttribute("data-styles"); 515 var fullScreen = (maps[i].getAttribute("data-fullscreen") == "true"); 516 var fitBounds = (maps[i].getAttribute("data-fitbounds") == "true"); 517 518 var mapOptions = { 519 zoom: zoom,
520 center: new google.maps.LatLng(latitude[0], longitude[0]), 521 disableDefaultUI: true, 522 panControl: false, 523 zoomControl: false, 524 mapTypeControl: false, 525 scaleControl: false, 526 streetViewControl: false, 527 overviewMapControl: false, 528 mapTypeControlOptions: { 529 mapTypeIds: [google.maps.MapTypeId.ROADMAP, maps[i].id] 530 } 531 }; 532 var map = new google.maps.Map(maps[i], mapOptions); 533 var bounds = new google.maps.LatLngBounds(); 534 535 var icon = { 536 url: "/img/ferve/icon_location.png", 537 scaledSize: new google.maps.Size(42, 30), 538 origin: new google.maps.Point(0, 0), 539 anchor: new google.maps.Point(0, 30) 540 }; 541 542 for (var j = 0; j < latitude.length; j++) { 543 logFerve("marker for " + latitude[j] + ", " + longitude[j]); 544 var latLng = new google.maps.LatLng(latitude[j], longitude[j]); 545 bounds.extend(latLng); 546 var marker = new google.maps.Marker({ 547 position: latLng, 548 map: map, 549 icon: icon 550 }); 551 } 552 553 if (styles) { 554 styles = JSON.parse(styles); 555 var styledMap = new google.maps.StyledMapType(styles, { name: "Ferve" }); 556 map.mapTypes.set(maps[i].id, styledMap); 557 map.setMapTypeId(maps[i].id); 558 } 559 560 if (fitBounds) map.fitBounds(bounds); 561 562 googleMaps[googleMaps.length] = [maps[i].id, map]; 563 564 if (fullScreen) { 565 logFerve("setting onclick for " + maps[i].id); 566 var id = maps[i].id; 567 maps[i].onclick = function () { ft_mapToggleFullScreen(id, 1); }; 568 } 569 } 570} 571 572 573function ft_mapToggleFullScreen(id, m) { 574 logFerve("ft_mapToggleFullScreen(" + id + ", " + m + ")"); 575 var mapDiv = document.getElementById(id); 576 if (!mapDiv) return; 577 578 var map; 579 for (var i = 0; i < googleMaps.length; i++) { 580 if (googleMaps[i][0] == id) { 581 map = googleMaps[i][1]; 582 break; 583 } 584 } 585 if (map) { 586 587 var exitDiv = document.getElementById(id + "_exit"); 588 var mapOptions; 589 590 logFerve("mapDiv.className: " + mapDiv.className); 591 if (mapDiv.className == "ft_mapFullScreen") { 592 593 mapDiv.className = ""; 594 mapOptions = { 595 disableDefaultUI: true, 596 panControl: false, 597 zoomControl: false, 598 mapTypeControl: false, 599 scaleControl: false, 600 streetViewControl: false, 601 overviewMapControl: false 602 }; 603 map.setOptions(mapOptions); 604 605 exitDiv.style.display = "none"; 606 setTimeout(function () { mapDiv.onclick = function () { ft_mapToggleFullScreen(id, 2); }; }, 100); 607 if (window.addEventListener) { 608 window.removeEventListener("keydown", ft_mapKeyDown, false); 609 } else if (window.attachEvent) { 610 window.detachEvent("onkeydown", ft_mapKeyDown); 611 } 612 613 } else { 614 615 mapDiv.className = "ft_mapFullScreen"; 616 617 mapOptions = { 618 disableDefaultUI: false, 619 panControl: true, 620 zoomControl: true, 621 mapTypeControl: true, 622 scaleControl: true, 623 streetViewControl: true, 624 overviewMapControl: true 625 }; 626 map.setOptions(mapOptions); 627 628 if (!exitDiv) { 629 var div = document.createElement("div"); 630 div.id = id + "_exit"; 631 div.style.backgroundColor = "#fff"; 632 div.style.color = "#000"; 633 div.style.fontFamily = "Roboto,Arial,sans-serif"; 634 div.style.fontSize = "11px"; 635 div.style.fontWeight = "500"; 636 div.style.padding = "1px 6px"; 637 div.style.borderRadius = "2px"; 638 div.style.border = "1px solid #000"; 639 div.style.webkitBoxShadow = "rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px"; 640 div.style.boxShadow = "rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px"; 641 div.style.marginTop = "5px"; 642 div.style.cursor = "pointer"; 643 div.style.textAlign = "center"; 644 div.title = "Click to exit the full screen map"; 645 div.innerHTML = "Exit full screen"; 646 div.onclick = function () { ft_mapToggleFullScreen(id, 3); }; 647 map.controls[google.maps.ControlPosition.TOP_RIGHT].push(div); 648 exitDiv = document.getElementById(id + "_exit"); 649 } 650 651 exitDiv.style.display = ""; 652 mapDiv.onclick = null; 653 if (window.addEventListener) { 654 window.addEventListener("keydown", ft_mapKeyDown, false); 655 } else if (window.attachEvent) { 656 window.attachEvent("onkeydown", ft_mapKeyDown); 657 } 658 659 } 660 661 662 google.maps.event.trigger(map, "resize"); 663 664 var latitude = mapDiv.getAttribute("data-latitude"); 665 var longitude = mapDiv.getAttribute("data-longitude"); 666 latitude = latitude.split(","); 667 longitude = longitude.split(","); 668 var point = new google.maps.LatLng(latitude[0], longitude[0]); 669 map.setCenter(point, 14); 670 } 671} 672 673function ft_mapKeyDown(e) { 674 if (!e) e = window.event; 675 676 var code; 677 if (e.keyCode) { 678 code = e.keyCode; 679 } else if (e.which) { 680 code = e.which; 681 } 682 if (code == 27) { 683 var ids = document.getElementsByClassName("ft_mapFullScreen"); 684 ft_mapToggleFullScreen(ids[0].id, 4); 685 } 686} 687 688 689 690 691// #mark ------ Utility ------ 692 693 694function ft_getAverageRGB(img, x, y, w, h) { 695 var blockSize = 5, // only visit every 5 pixels 696 defaultRGB = { r: 0, g: 0, b: 0 }, 697 canvas = document.createElement("canvas"), 698 context = canvas.getContext && canvas.getContext("2d"), data, width, height, i = -4, length, rgb = { r: 0, g: 0, b: 0 }, count = 0; 699 700 if (!context) return defaultRGB; 701 702 var imgEl = document.getElementById(img); 703 if (!imgEl) return defaultRGB; 704 705 if (imgEl.tagName == "DIV") { 706 var style = imgEl.currentStyle || window.getComputedStyle(imgEl, false); 707 var background = style.backgroundImage.slice(5, -2); 708 var image = new Image(); 709 image.src = background;
710 imgEl = image; 711 } 712 713 if (w != 0 && h != 0) { 714 width = w; 715 height = h; 716 try { 717 context.drawImage(imgEl, x, y, w, h, 0, 0, w, h); 718 } catch (e) { 719 return defaultRGB; 720 } 721 } else { 722 width = canvas.width = imgEl.naturalWidth || imgEl.offsetWidth || imgEl.width; 723 height = canvas.height = imgEl.naturalHeight || imgEl.offsetHeight || imgEl.height; 724 context.drawImage(imgEl, 0, 0); 725 } 726 727 try { 728 data = context.getImageData(0, 0, width, height); 729 } catch (e) { 730 return defaultRGB; 731 } 732 733 length = data.data.length; 734 735 while ((i += blockSize * 4) < length) { 736 if (data.data[i + 3] == 0) continue;// ignore alpha 737 ++count; 738 rgb.r += data.data[i]; 739 rgb.g += data.data[i + 1]; 740 rgb.b += data.data[i + 2]; 741 } 742 743 // ~~ used to floor values 744 rgb.r = ~~(rgb.r / count); 745 rgb.g = ~~(rgb.g / count); 746 rgb.b = ~~(rgb.b / count); 747 748 return rgb; 749} 750 751 752function minDigits(sInput, noDigits) { 753 var md_output = sInput; 754 if (sInput.toString().length < noDigits) { 755 for (var md_j = 1; md_j <= (noDigits - sInput.toString().length); md_j++) { 756 md_output = "0" + md_output; 757 } 758 } 759 return md_output; 760} 761 762 763function ft_mobileTooltip(selector, suffix, global) { 764 // Bootstrap tooltips compatible on mobile (click once to see tooltip, click again to visit link) 765 if (global) window.ft_tooltipShown = false;// Only show tooltip once globally 766 767 $(selector).each(function (i, obj) { 768 $(this).attr("data-html", true); 769 $(this).attr("title", $(this).attr("title") + suffix); 770 }); 771 772 $(selector).click(function (e) { 773 if (global) { 774 if (!window.ft_tooltipShown) { 775 window.ft_tooltipShown = true; 776 e.preventDefault(); 777 } 778 } else { 779 if (!$(this).attr("data-ft-tooltip-shown")) { 780 $(this).attr("data-ft-tooltip-shown", true); 781 e.preventDefault(); 782 } 783 } 784 }); 785} 786 787 788Number.prototype.formatMoney = function (decimalPlaces) { 789 var re = "\\d(?=(\\d{" + (3) + "}
789)+" + (decimalPlaces > 0 ? "\\." : "$") + ")"; 790 return this.toFixed(Math.max(0, ~~decimalPlaces)).replace(new RegExp(re, "g"), "$&,"); 791}; 792 793 794 795// #mark ------ Utility - Dates ------ 796 797Date.prototype.valid = function () { 798 return isFinite(this); 799} 800 801function parseDate(input) { 802 if (input instanceof Date || !input) return input; 803 804 var parts = input.split(" "); 805 if (parts.length == 1) { 806 parts = input.split("-"); 807 return new Date(parts[0], parts[1] - 1, parts[2]); 808 } else { 809 var parts2 = parts[0].split("-"); 810 var parts3 = parts[1].split(":"); 811 return new Date(parts2[0], parts2[1] - 1, parts2[2], parts3[0], parts3[1], parts3[2]); 812 } 813} 814 815function parseDateTime(input) { 816 // 2014-12-15T05:48:43 817 if (input instanceof Date || !input) return input; 818 819 var parts = (input.indexOf("T") > -1 ? input.split("T") : input.split(" ")); 820 var parts2 = parts[0].split("-"); 821 var parts3 = parts[1].split(":"); 822 return new Date(parts2[0], parts2[1] - 1, parts2[2], parts3[0], parts3[1], (parts3[2] == null ? "00" : parts3[2])); 823} 824 825function weekDayName(d, abbrev) { 826 var day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][d]; 827 828 if (abbrev) { 829 return day.substring(0, 3); 830 } else { 831 return day; 832 } 833} 834 835function monthName(m, abbrev) { 836 var month = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
836November", "December"][m]; 837 838 if (abbrev) { 839 return month.substring(0, 3); 840 } else { 841 return month; 842 } 843} 844 845function noSessionDate(d) { 846 if (!d || typeof d == "string") return true;//3/2/17 0 to 1 847 if (new Date(1975, 4, 17).toDateString() == d.toDateString()) { 848 return true; 849 } else { 850 return false; 851 } 852} 853 854function returnDateTime(d, incDate, incTime) { 855 var d2; 856 if (d instanceof Date && d.valid()) { 857 d2 = d; 858 } else { 859 d2 = parseDate(d); 860 } 861 862 if (!d2 || !d2 instanceof Date || !d2.valid()) return ""; 863 864 if (noSessionDate(d2)) return ""; 865 866 var returnDateTime = ""; 867 868 if (incDate) { 869 returnDateTime = weekDayName(d2.getDay(), true) + " " + d2.getDate() + " " + monthName(d2.getMonth(), true); 870 } 871 872 if (incTime) { 873 if (incDate) returnDateTime += " "; 874 875 var hour = d2.getHours(); 876 var minute = d2.getMinutes(); 877 if (hour == 12) { 878 returnDateTime += " 12:" + minDigits(minute, 2) + " PM" 879 } else if (hour > 12) { 880 returnDateTime += " " + hour - 12 + ":" + minDigits(minute, 2) + " PM" 881 } else { 882 returnDateTime += " " + hour + ":" + minDigits(minute, 2) + " AM" 883 } 884 } 885 return returnDateTime; 886} 887 888 889// #mark Account 890 891function ft_accountReset() { 892 var returnUrl = ferve.utility.queryStringValue("returnUrl"); 893 sessionStorage.setItem("FTAR_" + ferve_h, window.btoa(document.getElementById("LoginViewModel_Email").value)); 894 document.location.href = ferve.url + "Account/Reset" + (!ferve.isNullOrEmpty(returnUrl) ? "?returnUrl=" + encodeURIComponent(returnUrl) : ""); 895} 896 897function ft_accountNavigationToggle() { 898 var x = document.getElementById("ft_accountNavigation"); 899 if (x.className === "open") { 900 x.className = "closed"; 901 } else { 902 x.className = "open"; 903 } 904} 905 906// #mark ------ Utility - Openers ------ 907 908function ft_openReceipt(hash) { 909 if (hash.length == 0) return; 910 var hash2 = (document.querySelector("div[data-hash2]") ? document.querySelector("div[data-hash2]").getAttribute("data-hash2") : ""); 911 var url = ferve.url + "Account/" + (ferve.isNullOrEmpty(hash2) ? "" : "Guest") + "Receipt/?hash=" + hash + (ferve.isNullOrEmpty(hash2) ? "" : "&hash2=" + hash2); 912 var h = Math.min(1150, screen.height - 120); 913 var w = Math.min(900, screen.width - 120); 914 window.open(url, "receipt" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 915} 916 917function ft_openTickets(hash, hashes) { 918 if (hash.length == 0 && hashes.length == 0) return; 919 var hash2 = (document.querySelector("div[data-hash2]") ? document.querySelector("div[data-hash2]").getAttribute("data-hash2") : ""); 920 var url = ferve.url + "Account/" + (ferve.isNullOrEmpty(hash2) ? "" : "Guest") + "TicketsView/?hash=" + hash + "&" + (hashes.length > 0 ? "&" + hashes : "") + (ferve.isNullOrEmpty(hash2) ? "" : "&hash2=" + hash2) + "&group=false"; 921 var h = Math.min(1150, screen.height - 120); 922 var w = Math.min(900, screen.width - 120); 923 window.open(url, "ticket" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 924} 925 926 927 928function ft_openTicketsMobile(hash, hashes) { 929 if (hash.length == 0 && hashes.length == 0) return; 930 var url = ferve.url + "Account/TicketsMobile/?hash=" + hash + "&" + (hashes.length > 0 ? "&" + hashes : "") + "&group=false"; 931 document.location.href = url; 932} 933 934function ft_openPassPDF(hash) { 935 if (hash.length == 0) return; 936 var url = ferve.url + "Account/PassPDF/?hash=" + hash; 937 var h = Math.min(1150, screen.height - 120); 938 var w = Math.min(900, screen.width - 120); 939 window.open(url, "pass" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 940} 941function ft_openPass(hash) { 942 if (hash.length == 0) return; 943 var url = ferve.url + "Account/PassView/?hash=" + hash; 944 var h = Math.min(1150, screen.height - 120); 945 var w = Math.min(900, screen.width - 120); 946 window.open(url, "pass" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 947} 948 949function ft_openMembershipPDF(hash) { 950 if (hash.length == 0) return; 951 var url = ferve.url + "Account/MembershipPDF/?hash=" + hash; 952 var h = Math.min(1150, screen.height - 120); 953 var w = Math.min(900, screen.width - 120); 954 window.open(url, "membership" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width="
954+ w + ",height=" + h); 955} 956 957 958function ft_openMembership(hash) { 959 if (hash.length == 0) return; 960 var url = ferve.url + "Account/MembershipView/?hash=" + hash; 961 var h = Math.min(1150, screen.height - 120); 962 var w = Math.min(900, screen.width - 120); 963 window.open(url, "membership" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 964} 965 966 967 968function ft_openVoucher(hash) { 969 if (hash.length == 0) return; 970 var url = ferve.url + "Account/VoucherPDF/?hash=" + hash; 971 var h = Math.min(1150, screen.height - 120); 972 var w = Math.min(900, screen.width - 120); 973 window.open(url, "voucher" + hash, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 974} 975 976function ft_openWallet_Deprecated(hash, hashes) { 977 if (hash.length == 0 && hashes.length == 0) return; 978 var url = ferve.url + "Account/Wallet/?hash=" + hash + hashes; 979 var h = Math.min(1150, screen.height - 120); 980 var w = Math.min(900, screen.width - 120); 981 window.open(url, "wallet" + hashes, "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 982} 983 984function ft_openWallet(hash, hashes, isAppleWallet) { 985 986 // Open wallet to POST method 987 988 if (hash.length == 0 && hashes.length == 0) return; 989 var url = ferve.url + "Account/Wallet"; 990 var h = Math.min(1150, screen.height - 120); 991 var w = Math.min(900, screen.width - 120); 992 993 // Create a form to post value 994 var form = document.createElement("form"); 995 form.setAttribute("method", "post"); 996 form.setAttribute("action", url); 997 form.setAttribute("target", "form-target"); 998 999 // Add hash value to form 1000 var inputHash = document.createElement("input"); 1001 inputHash.type = "hidden"; 1002 inputHash.name = "hash"; 1003 inputHash.value = hash; 1004 form.appendChild(inputHash); 1005 1006 // Add hashes value to form 1007 var inputHashes = document.createElement("input"); 1008 inputHashes.type = "hidden"; 1009 inputHashes.name = "hashes"; 1010 inputHashes.value = hashes; 1011 form.appendChild(inputHashes); 1012 1013 // isAppleWallet 1014 var inputHashes = document.createElement("input"); 1015 inputHashes.type = "hidden"; 1016 inputHashes.name = "isAppleWallet"; 1017 inputHashes.value = isAppleWallet; 1018 form.appendChild(inputHashes); 1019 1020 // Add form to the body 1021 document.body.appendChild(form); 1022 1023 // Submit the form 1024 var w = window.open("", "form-target", "status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=false,width=" + w + ",height=" + h); 1025 1026 form.submit(); 1027 1028 // Remove form from the body 1029 document.body.removeChild(form); 1030} 1031 1032// #mark ------ Utility - Password ------ 1033 1034function ft_password(b) { 1035 ft_passwordStrength(); 1036 1037 var x = document.getElementById("ft_passwordInfo"); 1038 if (!x) return; 1039 1040 if (b) { 1041 ferve.toggleDisplay("ft_passwordInfo", ""); 1042 setTimeout(function () { x.className = "ft_fade ft_itemVisible"; }, 50); 1043 } else { 1044 x.className = "ft_fade ft_itemHidden"; 1045 setTimeout(function () { ferve.toggleDisplay("ft_passwordInfo", "none"); }, 500); 1046 x = document.getElementById("Password"); 1047 if (!x) x = document.getElementById("AccountViewModel_Password"); 1048 if (x) x.style.borderBottom = "1px solid #ccc"; 1049 x = document.getElementById("PasswordT"); 1050 if (x) x.style.borderBottom = "1px solid #ccc"; 1051 } 1052} 1053 1054function ft_passwordStrength(x) { 1055 if (!x) x = document.querySelector("input[type=password]"); 1056 var password = x.value; 1057 var valid = true; 1058 var html = "Minimum <span class=\"{1}\">7 characters</span>, <span class=\"{2}\">1 letter</span>, <span class=\"{3}\">1 number</span>."; 1059 if (password.length < 7) { 1060 valid = false; 1061 html = html.replace("{1}", "ft_passwordError"); 1062 } else { 1063 html = html.replace("{1}", "ft_passwordOK"); 1064 } 1065 if (!password.match(/[a-z]/) && !password.match(/[A-Z]/)) { 1066 valid = false; 1067 html = html.replace("{2}", "ft_passwordError"); 1068 } else { 1069 html = html.replace("{2}", "ft_passwordOK"); 1070 } 1071 if (!password.match(/[0-9]/)) { 1072 valid = false; 1073 html = html.replace("{3}", "ft_passwordError"); 1074 } else { 1075 html = html.replace("{3}", "ft_passwordOK"); 1076 } 1077 if (document.activeElement == x) { 1078 if (valid) { 1079 x.style.borderBottom = "2px solid #56da32"; 1080 } else { 1081 x.style.borderBottom = "2px solid #fa6767"; 1082 } 1083 } 1084 x = document.getElementById("PasswordT"); 1085 if (x && document.activeElement == x) { 1086 if (valid) { 1087 x.style.borderBottom = "2px solid #56da32"; 1088 } else { 1089 x.style.borderBottom = "2px solid #fa6767"; 1090 } 1091 } 1092 x = document.getElementById("ft_passwordInfo"); 1093 if (x) x.innerHTML = html; 1094 1095 return valid; 1096} 1097 1098 1099// #mark ------ Form ------ 1100 1101function formRequired(form) { 1102 var f = document.forms[form]; 1103 if (!f || !f.elements) { 1104 logFerve("formRequired(" + form + ") null"); 1105 return; 1106 } 1107 var inputs = document.forms[form].elements; 1108 for (var i = 0; i < inputs.length; i++) { 1109 if (inputs[i].required && (inputs[i].type == "text" || inputs[i].type == "select-one")) { 1110 inputs[i].style.backgroundImage = "url('" + ferve.url + "img/ferve/form_required.png')"; 1111 inputs[i].style.backgroundRepeat = "no-repeat"; 1112 inputs[i].style.backgroundPosition = "top right"; 1113 } 1114 } 1115} 1116 1117 1118// TEMP SHIZZLE 1119 1120function quickAddToCart() { 1121 var cartItemsToAdd = new Array(); 1122 cartItemsToAdd[cartItemsToAdd.length] = new ferve.CartItemToAdd(2, 2, 1, "", "", "", "", "", "", "", "", false, "", false, false); 1123 var cartItemsToAddSerialized = JSON.stringify(cartItemsToAdd);
1124 ferve.xmlHttpRequest(ferve.url + "api/v1/Cart/Add?hash=" + ferve.visitor.hash, "POST", cartItemsToAddSerialized, "", "", "ftd_cartAction(" + 2 + ","); 1125}
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.