1var App = function() { 2 3 // Manage page loading screen functionality 4 var loader = function(mode) { 5 var $lpageLoader = jQuery('#page-loader'); 6 7 if (mode === 'show') { 8 if (window.Player) { 9 window.Player.pause(); 10 } 11 if ($lpageLoader.length) { 12 $lpageLoader.fadeIn(250); 13 } else { 14 // var scriptUrl = $("#page-script").attr("src"); 15 // var urlPrefix = getUrlPrefix(); 16 $("body").prepend('<div id="page-loader" class="page-loader"><div class="loading-img"></div><h2 class="text-white text-center">'+AppUIActivity.capitalizeFirstLetter(langLabels.loading)+'...</h2></div>'); 17 $lpageLoader = jQuery('#page-loader'); 18 if ($(".loading-img", $lpageLoader).css("animation").indexOf("fa-spin") > -1) { //for default logo 19 $(".loading-img", $lpageLoader).addClass("fa").addClass("fa-spinner").addClass("fa-4x"); 20 } 21 //$("body").prepend('<div id="page-loader" class="page-loader"><h2 class="text-white text-center">'+AppUIActivity.capitalizeFirstLetter(langLabels.loading)+'...</h2></div>'); 22 } 23 } else if (mode === 'hide') { 24 if ($lpageLoader.length) { 25 $lpageLoader.fadeOut(250); 26 } 27 } else if (mode === 'hidefast') { 28 if ($lpageLoader.length) { 29 $lpageLoader.hide(); 30 } 31 } 32 33 return false; 34 }; 35 36 var initGlobalSearch = function(ajaxCmd) { 37 initAutoCompleteAjaxCustomLook(".js-autocomplete-global-search", ajaxCmd, renderGlobalSearchResult); 38 $(".js-autocomplete").each(function(){ 39 var $this = $(this); 40 $this.focus(function(){ 41 if ($this.hasClass("js-autocomplete-global-search")) { 42 //alert("focus search"); 43 $(".autocomplete-suggestions").css("max-height", "inherit"); 44 } else { 45 //alert("focus other"); 46 $(".autocomplete-suggestions").css("max-height", "400px"); 47 } 48 }); 49 }); 50 $(".js-autocomplete-global-search").change(function(item){ 51 //alert("change " + JSON.stringify(item)); 52 }); 53 $("#global-search-icon").click(function(event) { 54 event.stopPropagation(); 55 $(".js-autocomplete-global-search").trigger("focus"); 56 return false; 57 }); 58 59 }; 60 61 var lastTerm = null; 62 63 var initAutoCompleteAjaxCustomLook = function(key, ajaxCmd, renderItem){ 64 //alert("init " + key); 65 var $input = jQuery(key); 66 $input.keyup(function(){if ($input.val().length<2) return; $input.addClass("stroke"); window.setTimeout(function(){$input.removeClass("stroke");}, 1500); }); 67 var targetUrlPrefix = getUrlPrefix(); 68 var accountCd = App.getAccountCd(); 69 var ajaxUrlPrefix = targetUrlPrefix + accountCd + "/" + ajaxCmd + "?q="; 70 //alert(ajaxUrlPrefix); 71 $input.autoComplete({ 72 minChars: 2, 73 delay: 1000, 74 source: function(term, suggest){ 75 $input.addClass("loading"); 76 term = term.toLowerCase().replace("'", ""); 77 if (lastTerm!=null && term==lastTerm) { /*suggest(autocompleteLastSuggestions);*/ return; } 78 lastTerm = term; 79 //ajax settings 80 var ajaxUrl = ajaxUrlPrefix + encodeURIComponent(term); 81 //alert(ajaxUrl); 82 83 //load data 84 //alert("load data for term " + term); 85 $.get( ajaxUrl, function( data ) { 86 var suggestions = []; 87 88 for (var i = 0; i < data.length; i++) { 89 //suggestions.push(data[i].name); 90 suggestions.push(data[i]); 91 92 //var ajaxData = autocompleteLastAjaxData[key]; 93 //if () { 94 95 //} 96 } 97 autocompleteLastSuggestions = suggestions; 98 suggest(suggestions); 99 if (data.length>0) { 100 //alert(key + ", length " + data.length); 101 autocompleteLastAjaxData[key] = data; 102 } 103 $input.removeClass("loading"); 104 }, "json" ); 105 }, 106 onSelect: function(e, term, item){ 107 $input.trigger("change"); 108 //alert(JSON.stringify(item)); 109 var url = item.data("url"); 110 if (url) { 111 //alert(targetUrlPrefix + url); 112 location.href = targetUrlPrefix + url; 113 } 114 //$input.val(item.data('name')+' ('+item.data('id')+')'); 115 }, 116 renderItem: renderItem 117 /* 118 renderItem: function (item, search){ 119 search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 120 var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); 121 return '<div class="autocomplete-suggestion custom-look" data-val="' + item + '">' 122 + item.replace(re, "<b>$1</b>") + '</div>'; 123 } */ 124 }); 125 }; 126 127 var autocompleteLastAjaxData = new Array(); 128 var autocompleteLastSuggestions = new Array(); 129 130 var getAutoCompleteSelectedId = function(key, name) { 131 var data = autocompleteLastAjaxData[key]; 132 if (data==null) return 0; 133 //alert(data.length); 134 for (var i = 0; i < data.length; i++) { 135 var item = data[i]; 136 if (name==item.name) { 137 //alert(name); 138 return item.id; 139 } 140 } 141 return 0; 142 }; 143 144 var renderGlobalSearchResult = function (item, search){ 145 search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 146 var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi"); 147 //if (search=="bro") { alert(item); } 148 149 //add to list 150 var data = item; //getAutoCompleteData(".js-autocomplete-global-search", item); 151 //if (data == null) { 152 //if (search=="bro") { 153 //alert(item); 154 //} 155 //return ''; 156 // return '<div class="autocomplete-suggestion" data-val="' + item + '">' 157 // + item.replace(re, "<b>$1</b>") + '</div>'; 158 //} 159 160 /* 161 var color = "#b5d0eb"; //blue 162 var customClass = ""; 163 if (data.type == "VIDEO") { 164 color = "#faeab9";
165 customClass = "video"; 166 } else { 167 customClass = "playlist"; 168 } 169 170 //check if event is already displayed 171 if ($(".js-events li[data-oid="+data.id+"]").size()>0) { return ''; } 172 173 174 var $event = $('<li style="background-color: ' + color + ';" data-duration="' + data.duration + '" data-type="' + data.type + '" data-oid="' + data.id + '" class="ui-draggable ui-draggable-handle ' + customClass + '">' 175 + item.replace(re, '<b style="color:#000000bb">$1</b>') + '<br/><small>' + data.tagline + '</small></li>'); 176 $(".js-events").append($event); 177 BaseCompCalendar.initEvent($event);*/ 178 179 var overlayIcon = ""; 180 if (data.type == "Video") { 181 overlayIcon = "fa fa-video-camera"; 182 } else if (data.type == "Image") { 183 overlayIcon = "fa fa-image"; 184 } else if (data.type == "Audio") { 185 overlayIcon = "fa fa-headphones"; 186 } else if (data.type == "Document") { 187 overlayIcon = "fa fa-file"; 188 } else if (data.type == "Blog Post") { 189 overlayIcon = "si si-bubble"; 190 } else if (data.type == "Playlist") { 191 overlayIcon = "fa fa-list-ul"; 192 } else if (data.type == "Gallery") { 193 overlayIcon = "fa fa-th"; 194 } else if (data.type == "Movie") { 195 overlayIcon = "si si-film"; 196 } else if (data.type == "Series") { 197 overlayIcon = "fa fa-television"; 198 } else if (data.type == "Folder") { 199 overlayIcon = "fa fa-folder-o"; 200 } 201 202 203 var targetUrlPrefix = getUrlPrefix(); 204 205 var result = '<div class="autocomplete-suggestion global-search" data-val="' + item.name + '" data-url="' + item.url + '" data-tagline="' + item.tagline + '">' 206 + '<div style="background-size: cover;background-position:center;width:114px;height:76px;float:left;margin-top:4px;border-radius:0px;margin-right:16px;padding:8px;background-color:#c5c5c5'; 207 208 if (data.imgthumb!=null) { 209 result += 'background-size:contain;background-position:center;background-repeat:no-repeat;background-image:url(' + data.imgthumb + ');'; 210 //result += '" ><i class="' + overlayIcon + ' pull-left text-white" style="margin-top:-3px;text-shadow:1px 1px 1px #00000060"></i></div>'; 211 result += '" ></div>'; 212 } else { 213 //result += '" ><i class="' + overlayIcon + ' text-center fa-2x text-white" style="margin-left:0px;margin-top:-3px;display:block"></i></div>'; 214 result += 'background-size:contain;background-position:center;background-repeat:no-repeat;background-image:url(' + targetUrlPrefix + 'img/no-thumb.jpg);'; 215 result += '" ></div>'; 216 } 217 218 219 result += item.name.replace(re, "<b>$1</b>") + '<br/><small>' + data.tagline + '</small></div>'; 220 return result; 221 }; 222 223 var urlPrefix = null; 224 var getUrlPrefix = function() { 225 if (urlPrefix!=null) return urlPrefix; 226 var scriptUrl = $("#page-script").attr("src"); 227 urlPrefix = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1); 228 return urlPrefix; 229 }; 230 231 var getAutoCompleteData = function(key, name) { 232 var data = autocompleteLastAjaxData[key]; 233 if (data==null) return null; 234 //if (name=="Brooklyn Bridge [619]") { 235 //alert(JSON.stringify(data)); 236 //} 237 if (name.indexOf("[")>-1) { 238 var id = name.substring(name.indexOf("[")+1, name.indexOf("]")); 239 //alert(id); 240 for (var i = 0; i < data.length; i++) { 241 var item = data[i]; 242 if (id==item.id) { 243 return item; 244 } 245 } 246 } 247 248 //alert(data.length); 249 for (var i = 0; i < data.length; i++) { 250 var item = data[i]; 251 if (name==item.name) { 252 return item; 253 } 254 } 255 return null; 256 }; 257 258 259 var firstTrackSession = true, sessionTimeout = 15, currSessionTimeout = 0; //15min session timeout 260 261 var initSessionTracking = function() { 262 currSessionTimeout = sessionTimeout + 1;
263 trackSession(); 264 window.setInterval(trackSession, 60000); //60 secs intervals 265 }; 266 267 var resetSessionTracking = function() { 268 currSessionTimeout = sessionTimeout + 1; 269 }; 270 271 var trackSession = function() { 272 if (currSessionTimeout<1) return; 273 var paramsEnc = $("#page-script").attr("data-capture"); 274 var params = JSON.parse(Base64.decode(paramsEnc)); 275 var base = params["base"]; 276 delete params["base"]; 277 278 var dateKey = localStorage.getItem(`katapy_${getAccountCd()}_dailySessionDate`); 279 var dateTime = moment().tz("UTC").format("YYYYMMDD"); 280 // console.log("dateKey: ", dateKey, "dateTime: ", dateTime); 281 282 params["action"] = "current"; 283 if(dateKey === null || dateKey != dateTime ) { 284 // console.log("Updating dateKey"); 285 dateKey = dateTime; 286 params["date"] = dateKey; 287 params["action"] = "daily"; 288 localStorage.setItem(`katapy_${getAccountCd()}_dailySessionDate`, dateKey); 289 } 290 291 paramsEnc = Base64.encode(JSON.stringify(params)); 292 var ajaxCmd = "/web/ping-active"; 293 //var ajaxUrl = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + ajaxCmd; 294 var ajaxUrl = base + ajaxCmd + "?u=" + paramsEnc; 295 //console.log(ajaxUrl); 296 $.post( ajaxUrl, function( data ) { 297 //console.log(data); 298 if (firstTrackSession==false) return; 299 firstTrackSession = false; 300 $("#page-heading").attr("data-rs", data); 301 // updateSession(data); 302 if (typeof initPlayer === "function") { 303 initPlayer(); 304 } 305 }); 306 currSessionTimeout--; 307 }; 308 309 var updateSession = function(rs) { 310 var elem = document.getElementById("page-script"); 311 var scriptUrl = elem.src; 312 var accountCd = App.getAccountCd(); 313 var ajaxCmd = accountCd + "/submit/session"; 314 var params = {"rs":rs}; 315 var paramsEnc = Base64.encode(JSON.stringify(params)); 316 var ajaxUrl = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + ajaxCmd + "?u=" + paramsEnc; 317 $.post( ajaxUrl, function( data ) { 318 console.log("updateSession, result = " + data); 319 }); 320 }; 321 322 var pad = function(n, width, z) { 323 z = z || '0'; 324 n = n + ''; 325 return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; 326 }; 327 328 let url = new URL(location.href); 329 var widgetId = url.searchParams.get("widget"); 330 var token = null; 331 var referral = null; 332 333 var getWidgetId = function() { 334 return widgetId; 335 } 336 337 var getToken = function() { 338 if (navigator.cookieEnabled === false) { 339 return null; 340 } 341 token = url.searchParams.get("token"); 342 if (typeof window !== 'undefined' && 'localStorage' in window) { 343 try { 344 if (token != null) { 345 localStorage.setItem(`katapy_${getAccountCd(false)}_token`, token); 346 } else { 347 token = localStorage.getItem(`katapy_${getAccountCd(false)}_token`); 348 } 349 } catch (e) { 350 console.error("Error accessing localStorage"); 351 } 352 } 353 // console.log(token); 354 return token; 355 } 356 357 var getReferral = function() { 358 if (navigator.cookieEnabled === false) { 359 return null; 360 } 361 referral = url.searchParams.get("referral"); 362 try { 363 if (referral != null) { 364 var object = {value: referral, timestamp: new Date().getTime()}; //timestamp in millisecs 365 localStorage.setItem(`katapy_${getAccountCd(false)}_referral`, JSON.stringify(object)); 366 } else { 367 var data = localStorage.getItem("katapy_${getAccountCd(false)}_referral"); 368 if (data && data.indexOf("{") > -1) { 369 var object = JSON.parse(data); 370 var dateString = object.timestamp; 371 var now = new Date().getTime(); 372 var daysExpire = 7; 373 if (now - dateString < daysExpire * 86400000) { //expire in x days 374 referral = object.value; 375 } 376 } else { 377 //console.log("old referral code"); 378 //referral = data; 379 } 380 } 381 } catch (e) { 382 console.error("Error accessing localStorage"); 383 } 384 // console.log(referral); 385 return referral; 386 }; 387 388 var checkForCookies = function() { 389 if (widgetId) return; 390 if (location.href.indexOf("cookie-policy")>-1) return; 391 //alert(AppActions.cookiesEnabled()); 392 if (AppActions.cookiesEnabled() == false) { 393 var elem = document.getElementById("page-script"); 394 var scriptUrl = elem.src; 395 location.href = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + "cookie-policy"; 396 } 397 }; 398 399 var getPlaystate = function(contentId) { 400 if (playstates == null) return; 401 for (var i = 0; i <= playstates.length - 1; i++) { 402 var playstate = playstates[i]; 403 //alert(playstate.contentId); 404 if (playstate.contentId == contentId) return playstate; 405 } 406 return null; 407 }; 408 409 var applyPlaystates = function($data) { 410 if (playstates == null) return; 411 //alert($data.filter(".video-thumbnail").size()); 412 $data.each(function(){ 413 var $this = $(this); 414 var contentId = $this.find(".video-selection").attr("data-oid"); 415 var playstate = getPlaystate(contentId); 416 var percent = 0; 417 if (playstate!=null && playstate.time!=null && playstate.totalTime==null) { 418 playstate.totalTime = $this.find(".video-selection").attr("data-secs"); 419 } 420 if (playstate!=null && playstate.time!=null && playstate.totalTime!=null && playstate.totalTime>0 && playstate.totalTime > playstate.time) { 421 percent = Math.floor(playstate.time / playstate.totalTime * 100); 422 //var remaining = playstate.totalTime - playstate.time; 423 if (percent>97) percent = 100; 424 } 425 if (percent>0) { 426 $this.find(".progress-bar").addClass("init").attr("data-percentage", percent); 427 } else { 428 $this.find(".progress").addClass("hidden"); 429 } 430 431 }); 432 433 $data.find('.progress-bar.init').each(function() { 434 var me = $(this); 435 var perc = me.attr("data-percentage"); 436 437 //TODO: left and right text handling 438 me.css('width', (perc)+'%'); 439 //var meandclass = me.find(".skills-percentage"); 440 //meandclass.text((perc)+'%'); 441 }).removeClass("init"); 442 }; 443 444 var initHelper = function(helper) { 445 //console.log("initHelper, " + $helper); 446 switch (helper) { 447 case 'live-timestamp-converter': 448 AppUIActivity.initLiveTimestamps(); 449 break; 450 case 'autocomplete-search': 451 initGlobalSearch("ajax/get-global-search.php"); 452 break; 453 case 'session-tracking': 454 initSessionTracking(); 455 break; 456 case 'live-countdown': 457 AppUIActivity.initLiveCountdown(); 458 break; 459 case 'linear-playlist': 460 AppUIActivity.initLinearPlaylist(); 461 break; 462 case 'playstates': 463 applyPlaystates($(".owl-item")); 464 break; 465 case 'event-progress': 466 AppUIActivity.initEventProgress(); 467 break; 468 case 'reg-install': 469 registerInstall(); 470 break; 471 case 'print-page': 472 AppUIActivity.initPrint(); 473 break; 474 default: 475 return false;
476 } 477 }; 478 479 var initHelpers = function(helpers) { 480 if (helpers instanceof Array) { 481 for(var index in helpers) { 482 App.initHelper(helpers[index]); 483 } 484 } else { 485 App.initHelper(helpers); 486 } 487 }; 488 489 var getAccountCd = function(withLang = true) { 490 if (withLang) { 491 return accountCd; //global var in metainf script tag 492 } 493 return loadAccountCd; //global var in metainf script tag 494 }; 495 496 var getCurrentUrl = function() { 497 return currentUrl; //global var in metainf script tag 498 }; 499 500 var prepareFormForInstall = async function(formId) { 501 var $form = $(formId); 502 if ($("#deviceId").size()>0) return; 503 //add install data 504 var data = await getInstallData(); 505 $form.append(createHiddenInput("deviceId", data.deviceId)); 506 $form.append(createHiddenInput("deviceType", data.deviceType)); 507 $form.append(createHiddenInput("screenSize", data.screenSize)); 508 //add user timezone 509 var userTz = null; 510 if (window.moment) { 511 userTz = moment.tz.guess(); 512 } else { 513 userTz = await getUserTimezone(); 514 } 515 $form.append(createHiddenInput("userTz", userTz)); 516 517 }; 518 519 var createHiddenInput = function(name, value) { 520 return $("<input>").attr("type", "hidden").attr("id", name).attr("name", name).val(value); 521 } 522 523 var registerInstall = async function() { 524 //install data 525 var data = await getInstallData(); 526 //user timezone 527 var userTz = null; 528 if (window.moment) { 529 userTz = moment.tz.guess(); 530 } else { 531 userTz = await getUserTimezone(); 532 } 533 var targetUrlPrefix = getUrlPrefix(); 534 var accountCd = App.getAccountCd(); 535 var ajaxCmd = accountCd + "/ajax/reg-install.php"; 536 var ajaxUrl = targetUrlPrefix + ajaxCmd + "?deviceId=" + data.deviceId + "&deviceType=" + data.deviceType + "&screenSize=" + data.screenSize + "&userTz=" + userTz; 537 //console.log(ajaxUrl); 538 $.get( ajaxUrl, function( response ) { 539 //console.log("Response: \n" + response); 540 } ); 541 }; 542 543 var getUserTimezone = async function() { 544 let old_tz = localStorage.getItem("katapy_tz"); 545 let old_tz_ts = localStorage.getItem("katapy_tz_ts"); 546 if ( old_tz && (old_tz_ts && old_tz_ts > Date.now() - 86400*1000) ) return old_tz; 547 const momentTimezone = await import('https://cdn.skypack.dev/moment-timezone'); 548 var tz = momentTimezone.tz.guess(); 549 localStorage.setItem("katapy_tz", tz); 550 localStorage.setItem("katapy_tz_ts", Date.now()); 551 return tz; 552 }; 553 554 var registerTimezone = async function() { 555 //user timezone 556 var userTz = null; 557 if (window.moment) { 558 userTz = moment.tz.guess(); 559 } else { 560 userTz = await getUserTimezone(); 561 } 562 var targetUrlPrefix = getUrlPrefix(); 563 var accountCd = App.getAccountCd(); 564 var ajaxCmd = accountCd + "/ajax/reg-tz.php"; 565 var ajaxUrl = targetUrlPrefix + ajaxCmd + "?userTz=" + userTz; 566 //console.log(ajaxUrl); 567 $.get( ajaxUrl, function( response ) { 568 //console.log("Response: \n" + response); 569 } ); 570 }; 571 572 var getInstallData = async function() { 573 let old_install_data = null; 574 if (typeof window !== 'undefined' && 'localStorage' in window) { 575 try { 576 old_install_data = localStorage.getItem("katapy_install_data"); 577 if (old_install_data) { 578 return JSON.parse(old_install_data); 579 } 580 } catch (e) { 581 console.error("Error accessing localStorage"); 582 } 583 } 584 const FingerprintJS = await import('https://openfpcdn.io/fingerprintjs/v3'); 585 const fpPromise = await FingerprintJS.load(); 586 const fp = await fpPromise.get(); 587 const visitorId = fp.visitorId; 588 var deviceType = (navigator?.userAgentData?.mobile)?"MOBIL":"DESKT"; 589 var screenSize = $(document).width() + "x" + $(document).height(); 590 var data = {"deviceId":visitorId, "deviceType":deviceType, "screenSize":screenSize}; 591 if (typeof window !== 'undefined' && 'localStorage' in window) { 592 try { 593 localStorage.setItem("katapy_install_data", JSON.stringify(data)); 594 } catch (e) { 595 console.error("Error accessing localStorage"); 596 } 597 } 598 return data; 599 }; 600 601 var isIphone = function() { 602 const platform = navigator.userAgentData?.platform || navigator.platform; 603 return /iPhone|iPod/.test(platform); 604 } 605 606 return { 607 resetSessionTracking: resetSessionTracking, 608 getWidgetId, 609 getToken, 610 getReferral, 611 checkForCookies: checkForCookies, 612 initSessionTracking: initSessionTracking, 613 initHelpers: initHelpers, 614 initHelper: initHelper, 615 getPlaystate: getPlaystate, 616 loader: loader, 617 getUrlPrefix: getUrlPrefix, 618 getUserTimezone, 619 registerTimezone, 620 getAccountCd, 621 getCurrentUrl, 622 registerInstall, 623 prepareFormForInstall, 624 getInstallData, 625 isIphone, 626 init: function() { 627 getToken(); 628 getReferral(); 629 } 630 }; 631 632}(); 633 634 635var AppUIActivity = function() { 636 637 var capitalizeFirstLetter = function(text) { 638 return text.charAt(0).toUpperCase() + text.slice(1); 639 } 640 641 var toggleSearch = function() { 642 var $searchIcon = $("#searchIcon i"); 643 $(".kt-search-bar").parent().toggleClass("hidden"); 644 if ($searchIcon.hasClass("fa-search")) { 645 $searchIcon.removeClass("fa-search"); 646 $searchIcon.addClass("fa-times"); 647 $("#q:last").focus(); 648 $(".options-menu").addClass("hidden"); 649 } else { 650 $searchIcon.addClass("fa-search"); 651 $searchIcon.removeClass("fa-times"); 652 $("#q").val(""); 653 $(".options-menu").removeClass("hidden"); 654 } 655 $searchIcon.parent().parent().prevAll().toggleClass("hidden"); 656 $("#searchIcon .nav-link-title").toggleClass("hidden"); 657 }; 658 659 var titleCase = function(str) { 660 var splitStr = str.toLowerCase().split(' '); 661 for (var i = 0; i < splitStr.length; i++) { 662 // You do not need to check if i is larger than splitStr length, as your for does that for you 663 // Assign it back to the array 664 splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1); 665 } 666 // Directly return the joined string 667 return splitStr.join(' '); 668 } 669 670 var showSignupDialog = function(redirectUrlEnc) { 671 if(! redirectUrlEnc) redirectUrlEnc = ""; 672 var htmlContent; 673 var mainButtonLabel; 674 var logo = $("title").data("logo"); 675 var offerTitle = $("title").data("offertitle"); 676 var offerTagline = $("title").data("offertagline"); 677 //console.log("redirect = " + redirectUrlEnc); 678 /* 679 if (App.getWidgetId()) { 680 htmlContent = '<center><img src="https://funeralvideonetwork.com/img/logo-white-text4.png" style="max-width:200
680px"></center><br/><b>Do You Have Your Amplify Access Code?</b><br/><small>Enter it here and enjoy thousands of resources for study, reflection and worship.</small><br/><br/><small>Already set up your account? <a href="javascript:AppActions.loadPage(App.getAccountCd() + \'/login\');" style="color:black">Login</a></small>'; 681 mainButtonLabel = 'Click here to enter your code'; 682 } else { 683 htmlContent = '<center><img src="https://funeralvideonetwork.com/img/logo-white-text4.png" style="max-width:200px"></center><br/>Stream 1000s of reliable Christian videos from any device, anytime, anywhere.<br/><br/><small>Already a subscriber? <a href="javascript:AppActions.loadPage(App.getAccountCd() + \'/login\');" style="color:black">Login</a></small>'; 684 mainButtonLabel = 'Start Your Free Trial'; 685 }*/ 686 htmlContent = ` 687 <center> 688 <img src=${logo} style="max-width:200px; max-height:200px"> 689 </center> 690 <br/> 691 <div class="container text-center"> 692 <p>${offerTitle}</p> 693 <small class="pt-3 pb-2">${offerTagline}</small> 694 </div> 695 <br> 696 <small> 697 ${alreadySubscribedLabel} 698 <a href="javascript:AppActions.loadPage('${App.getAccountCd()}/login?redirect=${encodeURIComponent(redirectUrlEnc)}');"> 699 Login 700 </a> 701 </small> 702 `; 703 mainButtonLabel = titleCase(langLabels.getAccess); //'Create a Free Account'; 704 swal({ 705 //title: 'Start Your Free Trial', 706 //text: 'Stream 1000s of reliable Christian videos from any device, anytime, anywhere.', 707 //type: 'info', 708 //showCancelButton: true, 709 confirmButtonColor: '#d26a5c', 710 confirmButtonText: mainButtonLabel, 711 //cancelButtonText: 'Already a subscriber? Login', 712 html: htmlContent, 713 preConfirm: function() { 714 return new Promise(function (resolve) { 715 setTimeout(function () { 716 resolve(); 717 }, 50); 718 }); 719 } 720 }).then(function(result){ 721 if (result.value) { 722 //swal('Ok, let\'s go', '', 'info'); 723 //if (App.getWidgetId()) { 724 AppActions.loadPage(App.getAccountCd() + '/get-access?redirect=' + encodeURIComponent(redirectUrlEnc)); 725 //} else { 726 // location.href = "https://www.funeralvideonetwork.com/pricing"; 727 //} 728 } else if (result.dismiss === 'cancel') { 729 //swal('Cancelled', '', 'error'); 730 } 731 }); 732 }; 733 734 735 736 var showMembersOnlyTrackingDialog = function(redirect) { 737 var htmlContent = ""; 738 // console.log(redirect); 739 var htmlContent = `${htmlContent} 740 <small>Fill out the form to watch select videos for free.</small> 741 <br/><br/> 742 <form role="form" id="save-member-external-form" action="${App.getUrlPrefix() + App.getAccountCd() + '/action/save-member-external'}" method="POST"> 743 <input type="hidden" name="video-redirect" value="${redirect}"> 744 <input type="hidden" name="previousUrl" value="${App.getCurrentUrl()}"> 745 <input form="save-member-external-form" type="submit" id="save-member-external-form-btn" class="hidden"> 746 <div class="row"> 747 <div class="inputs form-group col-12"> 748 <label class="control-label col-5" style="color: grey;" for="frstNm">First Name <span class="text-danger">*</span></label> 749 <input class="col-6" type="text" autofocus="autofocus" id="frstNm" name="frstNm" placeholder="" value=""> 750 <label class="control-label col-5" style="color: grey;" for="lstNm">Last Name <span class="text-danger">*</span></label> 751 <input class="col-6" type="text" autofocus="autofocus" id="lstNm" name="lstNm" placeholder="" value=""> 752 <label class="control-label col-5" style="color: grey;" for="emalAddr">Email <span class="text-danger">*</span></label> 753 <input class="col-6" type="email" autofocus="autofocus" id="emalAddr" name="emalAddr" placeholder="" value=""> 754 </div> 755 </div> 756 </form> 757 <small>I agree to share my information with ${siteName}</small> 758 <br/><br/> 759 <small> 760 ${alreadySubscribedLabel} <a href="javascript:AppActions.loadPage(App.getAccountCd() + '/login');" style="color:black">Log In</a> 761 </small> 762 `; 763 //<br/>
763 764 //Have your Amplify access code? <a href="javascript:AppActions.loadPage(App.getAccountCd() + '/enter-access-code');" style="color:black">Click to Enter</a> 765 // console.log(htmlContent); 766 767 swal({ 768 title: "Just Browsing?", 769 confirmButtonColor: '#d26a5c', 770 confirmButtonText: "Watch Video", 771 html: htmlContent, 772 preConfirm: () => { 773 console.log($("#frstNm").val(), $("#lstNm").val(), $("#emalAddr").val()); 774 if( ! ($("#frstNm").val() && $("#lstNm").val() && $("#emalAddr").val()) ) { 775 swal.showValidationError('Please add missing fields'); 776 } 777 }, 778 }).then(function(result){ 779 console.log(result); 780 if (result.value) { 781 App.loader("show"); 782 $("#save-member-external-form").submit(); 783 } 784 }); 785 return; 786 }; 787 788 var initNav = function() { 789 var offset = 0; 790 if ($(".kt-session-nav").size()>0) { 791 offset = 27; //make room for the session nav 792 } 793 $(".navbar-default").sticky({topSpacing:offset}); 794 //$(".navbar-categories").sticky({topSpacing:100}); 795 $(document).scroll(function () { 796 var $nav = $(".navbar, .kt-session-nav"); 797 $nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height()); 798 }); 799 800 if ($("nav.pushy").size()>0) { 801 var scriptUrl = $("#page-script").attr("src"); 802 AppUIActivity.initMobileNav(scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + "js/pushy.min.js"); 803 } 804 805 $('a[data-toggle="dropdown"]').click(function(event){ 806 $(".dropdown-submenu").removeClass("open"); 807 }); 808 809 $('a[href="#submenu"]').click(function(event){ 810 event.stopPropagation(); 811 var $this = $(event.target); 812 813 if ($this.next().hasClass("open")) { 814 $(".dropdown-submenu").removeClass("open"); 815 } else { 816 $(".dropdown-submenu").removeClass("open"); 817 var marginTop = $this.position().top + $this.height()/2; 818 $this.next().addClass("open").css("marginTop", marginTop + "px"); 819 } 820 //$this.parent().siblings().removeClass("open"); */ 821 //$this.next().toggleClass("open"); 822 }); 823 824 $('#joinPartyModal').on('shown.bs.modal', function (e) { 825 $("#partyAccessCode").focus(); 826 }); 827 828 //hide dividers at the end of menu 829 $(".dropdown-menu").each(function(){ 830 var $div = $(":last", $(this)); 831 if ($div.hasClass("dropdown-divider")) { 832 $div.addClass("hidden"); 833 } 834 }); 835 836 }; 837 838 var initOwlCarousel = function() { 839 //if ($.fn.owlCarousel==false) return; 840 if (jQuery.isFunction($.fn.owlCarousel)==false) return; 841 $(".slider").owlCarousel({ 842 autoplay : true, 843 autoplayTimeout: 12000, 844 nav : false, 845 navText : false, 846 slideBy: 'page', 847 lazyLoad : true, 848 loop:true, 849 dots:false, 850 items:1, 851 onInitialized: function(event){ 852 var element = event.target; 853 var $target = $(element); 854 855 $target.css("visibility", "visible"); 856 }, 857 }); 858 859 //init different owl carousels with different amount of icons 860 for (var i = 1; i <= 12; i++) { 861 initOwl(i); 862 } 863 864 }; 865 866 var initOwl = function(maxRowItems) { 867 if (jQuery.isFunction($.fn.owlCarousel)==false) return; 868 var $owlCarousel = $(".owl-carousel.owl-item-" + maxRowItems); 869 $owlCarousel.css("visibility", "hidden"); 870 $owlCarousel.show(); 871 $owlCarousel.owlCarousel(getOwlOptions(maxRowItems)); 872 $(".owl-carousel .owl-next").addClass("fas fa-chevron-right"); 873 $(".owl-carousel .owl-prev").addClass("fas fa-chevron-left"); 874 }; 875 876 var getOwlOptions = function(items) { 877 var items_2 = (items<2)?items:2; 878 var items_3 = (items<3)?items:3; 879 var items_4 = (items<4)?items:4; 880 return { 881 nav : true, 882 navText : false, 883 slideBy: 'page', 884 lazyLoad : true, 885 loop:false, 886 dots:false, 887 responsiveClass:true, 888 responsive:{ 889 0:{ items:3 }, 890 400:{ items:items_3 }, 891 660:{ items:items_3 }, 892 900:{ items:items_4 }, 893 1400:{ items:items } 894 }, 895 onInitialized: function(event){ 896 var element = event.target; 897 var $target = $(element); 898 $target.css("visibility", "visible"); 899 } 900 }; 901 }; 902 903 var initMobileNav = function(scriptUrl) { //pushy menu 904 var $pushy = $(".pushy ul"); 905 906 $(".pushy-overlay button").click(AppUIActivity.hideMobileSubnav); 907 AppActions.loadScript(scriptUrl, function(){}); 908 }; 909 910 var initLiveTimestamps = function() { 911 if ($.fn.moment == false) return; 912 if ($.fn.tz == false) return; 913 //console.log("initLiveTimestamps"); 914 915 var calendarOptions = { 916 sameDay: '['+AppUIActivity.capitalizeFirstLetter(langLabels.today)+'], MMM Do YYYY', 917 nextDay: '['+AppUIActivity.capitalizeFirstLetter(langLabels.tomorrow)+'], MMM Do YYYY', 918 nextWeek: '['+AppUIActivity.capitalizeFirstLetter(langLabels.next)+'] dddd, MMM Do YYYY', 919 lastDay: '['+AppUIActivity.capitalizeFirstLetter(langLabels.yesterday)+'], MMM Do YYYY', 920 lastWeek: '['+AppUIActivity.capitalizeFirstLetter(langLabels.last)+'] dddd, MMM Do YYYY', 921 sameElse: 'dddd, MMM Do YYYY' 922 }; 923 924 jQuery(".live-event-user").each(function(){ 925 var $this = jQuery(this); 926 var timestamp = $this.attr("data-start") * 1000; 927 //console.log("timestamp = " + timestamp); 928 var userTz = moment.tz.guess(); 929 //console.log("timezone is " + userTz); 930 var dateTime = moment.tz(timestamp, "UTC").tz(userTz); 931 var dateFormat = 'h:mmA z'; 932 if (dateTime.minutes()==0) { 933 dateFormat = 'hA z'; 934 } 935 var dateTimeFormatted = AppUIActivity.capitalizeFirstLetter(dateTime.calendar(null, calendarOptions)) + ' ' + dateTime.format(dateFormat); 936 937 var $timeSpan = $this; //jQuery(".start-time", $this); 938 $timeSpan.html(dateTimeFormatted); 939 }); 940 }; 941 942 var toUTC = function(time, zone) { 943 var format = 'MM/DD/YYYY HH:mm:ss'; 944 return moment.tz(time, format, zone).tz("UTC").format(format); 945 }; 946 947 var initLiveCountdown = function() { 948 var $script = $("#page-script"); 949 var liveEventId = $script.attr("data-live-event"); 950 var scriptUrl = $script.attr("src"); 951 var liveIntervalEnc = $script.attr("data-live-interval"); 952 var liveInterval = JSON.parse(Base64.decode(liveIntervalEnc)); 953 var millisTotalAdd = parseInt(liveInterval.days)*24*60*60*1000 + parseInt(liveInterval.hours)*60*60*1000 + parseInt(liveInterval.mins)*60*1000 + parseInt(liveInterval.secs)*1000 - 1000; 954 955 //for testing below 956 //millisTotalAdd = 5000; 957 958 var date = new Date(); 959 date.setTime(date.getTime() + millisTotalAdd); 960 $('.countdown').countdown({ 961 until: date, 962 //until: +2, 963 format: countdownFormat, 964 layout: countdownLayout, 965 padZeroes: true, 966 labels : [langLabels.years,langLabels.months,langLabels.weeks,langLabels.days,langLabels.hours,langLabels.minutes,langLabels.seconds], 967 labels1 : [langLabels.year,langLabels.month,langLabels.week,langLabels.day,langLabels.hour,langLabels.minute,langLabels.second], 968 onExpiry: function(){ 969 970 //if (Player.isPlaying()) { 971 // window.location = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + "live?id=" + liveEventId; 972 //} else { 973 //$(".kt-linear-ad").removeClass("show").addClass("hidden"); 974 //$(".kt-live-ad").addClass("show").removeClass("hidden"); 975 //return; 976 swal({ 977 title: 'Live Broadcast Started', 978 text: 'Would you like to start watching?', 979 type: 'info', 980 showCancelButton: true, 981 confirmButtonColor: '#d26a5c', 982 confirmButtonText: 'Yes', 983 cancelButtonText: 'No', 984 html: false, 985 preConfirm: function() { 986 return new Promise(function (resolve) { 987 setTimeout(function () { 988 resolve(); 989 }, 50); 990 }); 991 } 992 }).then(function(result){ 993 if (result.value) { 994 //swal('Ok, let\'s go', '', 'info'); 995 AppActions.loadPage(App.getAccountCd() + "/live"); 996 } else if (result.dismiss === 'cancel') { 997 //swal('Cancelled', '', 'error'); 998 $(".countdown-display").fadeOut(); 999 //$(".live-display").hide().removeClass("hidden").fadeIn(); 1000 } 1001 }); 1002 1003 //} 1004 } 1005 }); 1006 //$('.countdown').countdown({until: +2, format: 'YDHMS', padZeroes: true}); 1007 $('.countdown-bg').delay(1500).hide().removeClass("hidden").fadeIn(); 1008 }; 1009 1010 var linearPlaylist = null; 1011 1012 var initLinearPlaylist = function() { 1013 if (linearPlaylist!=null) return; 1014 var playlistEnc = $(".kt-linear-ad").attr("data-playlist"); 1015 $(".kt-linear-ad").removeAttr("data-playlist"); 1016 if (playlistEnc===undefined || playlistEnc.length == 0) return; 1017 linearPlaylist = JSON.parse(Base64.decode(playlistEnc)); 1018 }; 1019 1020 var loadNextLinearEvent = function() { 1021 initLinearPlaylist(); 1022 if (linearPlaylist==null || linearPlaylist.length<2) return null; 1023 var expiredItem = linearPlaylist[0]; 1024 linearPlaylist.shift(); 1025 for (var i = 0; i < linearPlaylist.length; i++) { 1026 var nextItem = linearPlaylist[i]; 1027 nextItem.expiry = nextItem.expiry - expiredItem.expiry; 1028 linearPlaylist[i] = nextItem; 1029 } 1030 return linearPlaylist[0]; 1031 }; 1032 1033 var displayNextLinearEvent = function() { 1034 var nextItem = loadNextLinearEvent(); //array 1035 if (nextItem == null) { 1036 $('.kt-live-event-progress').addClass("hidden"); 1037 $(".kt-linear-ad-desc").addClass("hidden"); 1038 $(".kt-linear-ad-name").text("24/7 Broadcast"); 1039 return; 1040 } 1041 var expiry = nextItem["expiry"]; 1042 var duration = nextItem["duration"]; 1043 //console.log("displayNextLinearEvent, next item is " + nextItem["name"] + ", expiry = " + expiry); 1044 var $eventProgress = $(".kt-live-event-progress"); 1045 $eventProgress.attr("data-expiry", expiry); 1046 $eventProgress.attr("data-duration", duration);
1047 $('.kt-live-event-progress .progress-bar').css('width', '0%'); 1048 $(".kt-linear-ad-name").text(decodeHtml(nextItem["name"])); 1049 $(".kt-linear-ad-desc").text(decodeHtml(nextItem["shortDesc"])); 1050 $(".kt-linear-ad-image").css("background-image", "url(\"" + nextItem["imgthumb"] + "\")"); 1051 expireProgress = 0, eventDuration = 0, progressInterval = null; 1052 initEventProgress(); 1053 }; 1054 1055 var decodeHtml = function(html) { 1056 var txt = document.createElement("textarea"); 1057 txt.innerHTML = html; 1058 return txt.value; 1059 }; 1060 1061 var expireProgress = 0, eventDuration = 0, progressInterval = null; 1062 1063 var getMinutesLeftFormatted = function(secs) { 1064 if (secs == 0) return ""; 1065 var mins = Math.floor(secs/60); 1066 if (mins<1) return "<1 "+langLabels.minute+" "+langLabels.remaining; 1067 if (mins==1) return "1 "+langLabels.minute+" "+langLabels.remaining; 1068 return mins + " "+langLabels.minutes+" "+langLabels.remaining; 1069 }; 1070 1071 var updateEventProgress = function() { 1072 expireProgress = expireProgress - 1; 1073 var percent = Math.floor((eventDuration-expireProgress) * 100 / eventDuration); 1074 $(".kt-live-event-progress .progress-bar").css('width', (percent)+'%'); 1075 var $label = $('.kt-live-event-progress-label'); 1076 var value = getMinutesLeftFormatted(expireProgress); 1077 //console.log("expireProgress = " + expireProgress + ", value = " + value); 1078 if (value!=$label.text()) $label.text(value); 1079 if (expireProgress == 0) { 1080 clearInterval(progressInterval); 1081 if ($(".kt-linear-ad").size()>0) { 1082 //display next linear event 1083 displayNextLinearEvent(); 1084 } else if ($(".kt-live-ad").size()>0) { 1085 $(".progress", $(".kt-live-ad")).hide(); 1086 $(".kt-btn-watch-now", $(".kt-live-ad")).hide(); 1087 /* 1088 swal({title: "Live Broadcast Ended", text:"", type:"info", onClose: function(){ 1089 var scriptUrl = $("#page-script").attr("src"); 1090 location.href = scriptUrl.substring(0, scriptUrl.indexOf("/js/")+1) + "home"; 1091 }});*/ 1092 } 1093 } 1094 }; 1095 1096 var initEventProgress = function() { 1097 //console.log("initEventProgress"); 1098 var $eventProgress = $(".kt-live-event-progress"); 1099 expireProgress = $eventProgress.attr("data-expiry"); 1100 eventDuration = $eventProgress.attr("data-duration"); 1101 var percent = Math.floor((eventDuration-expireProgress) * 100 / eventDuration); 1102 $('.kt-live-event-progress .progress-bar').css('width', (percent)+'%'); 1103 $('.kt-live-event-progress-label').text(getMinutesLeftFormatted(expireProgress)); 1104 if (progressInterval!=null) return; 1105 progressInterval = window.setInterval(updateEventProgress, 1000); 1106 }; 1107 1108 var initPrint = function() { 1109 // Store all #page-container classes 1110 var $lPage = jQuery('#page-container'); 1111 var $pageCls = $lPage.prop('class'); 1112 1113 // Remove all classes from #page-container 1114 $lPage.prop('class', ''); 1115 1116 // Print the page 1117 window.print(); 1118 1119 // Restore all #page-container classes 1120 $lPage.prop('class', $pageCls); 1121 }; 1122 1123 var initAlerts = function() { 1124 //dismissible alerts 1125 var futureDate = new Date().setFullYear(new Date().getFullYear() + 1); //a year from now 1126 $(".js-alert-dismissible").each(function(){ 1127 var $this = $(this); 1128 var id = $this.attr("id"); 1129 //console.log("initAlerts, id = " + id); 1130 var savedAlert = localStorage.getItem(id) || ''; 1131 1132 if (savedAlert < new Date()) { //check if it expired 1133 //console.log("initAlerts, show id = " + id); 1134 $this.removeClass('hidden').addClass('show'); 1135 localStorage.removeItem(id); 1136 } 1137 1138 $this.on('closed.bs.alert', function () { 1139 localStorage.setItem(id,futureDate); 1140 }) 1141 }); 1142 1143 //timer alerts 1144 $(".js-alert-timer").each(function(){ 1145 var $this = $(this); 1146 var expirySecs = $this.data("expiry"); 1147 if (!expirySecs) expirySecs = 5; 1148 window.setTimeout(function() { 1149 $this.alert('close'); 1150 }, expirySecs * 1000); 1151 }); 1152 }; 1153 1154 var onFullscreenChange = function() { 1155 var $icon = $(".nav-item .icon-fullscreen"); 1156 if (AppActions.isFullscreen()) { 1157 //console.log("onFullscreenChange, show fullscreen exit icon"); 1158 $icon.text("fullscreen_exit"); 1159 } else { 1160 //console.log("onFullscreenChange, show fullscreen icon"); 1161 $icon.text("fullscreen"); 1162 } 1163 }; 1164 1165 return { 1166 toggleSearch: toggleSearch, 1167 initMobileNav: initMobileNav, 1168 initLiveTimestamps: initLiveTimestamps, 1169 initLiveCountdown: initLiveCountdown, 1170 initEventProgress: initEventProgress, 1171 initPrint: initPrint, 1172 initLinearPlaylist: initLinearPlaylist, 1173 showSignupDialog: showSignupDialog, 1174 showMembersOnlyTrackingDialog, 1175 toUTC: toUTC, 1176 titleCase, 1177 capitalizeFirstLetter, 1178 onFullscreenChange: onFullscreenChange, 1179 init: function() { 1180 App.loader('show'); 1181 //init lazyload 1182 if ($.fn.lazy) { 1183 $('.lazyload').lazy(); 1184 $('.kt-img').lazy(); 1185 } 1186 1187 initNav(); 1188 initOwlCarousel(); 1189 initAlerts(); 1190 1191 //Tooltip 1192 if ($.fn.tooltip) { 1193 $('[data-toggle="tooltip"]').tooltip(); 1194 } 1195 1196 //Dropdown 1197 $('[data-toggle="dropdown"]').click(function(){ 1198 var $dropdown = $(this).next(); 1199 if ($dropdown.hasClass("dropdown-menu")) $dropdown.show(); 1200 }); 1201 $(document).click(function(e){ 1202 e.stopPropagation(); 1203 var $container = $(".dropdown-menu"); 1204 if ($container.has(e.target).length === 0) { //check if the clicked area is dropDown or not 1205 $(".dropdown-menu").hide(); 1206 } 1207 }); 1208 1209 //popover 1210 if ($.fn.popover) { 1211 $('[data-toggle="popover"]').popover({ 1212 html: true, 1213 container: 'body', 1214 placement: function (context, source) { 1215 //console.log("placement"); 1216 var $source = $(source); 1217 var $parent = $source.parentsUntil("div.container-fluid").parent(); 1218 var position = $parent.position(); 1219 var posY = position.top - $(window).scrollTop();
1220 //$("div h3", $source).text(posY); 1221 1222 if (posY < 400){ 1223 return "bottom"; 1224 } 1225 1226 return "top"; 1227 } 1228 }); 1229 } 1230 1231 //placeholder 1232 if ($.fn.placeholder) { 1233 $(':input[placeholder]').placeholder(); 1234 } 1235 1236 //placeholder 1237 if ($.fn.UItoTop) { 1238 $().UItoTop({ easingType: 'easeOutQuart' }); 1239 } 1240 1241 //init thumnail progress bar for playstates 1242 setTimeout(function(){ 1243 $('.progress .progress-bar').each(function() { 1244 var me = $(this); 1245 var perc = me.attr("data-percentage"); 1246 me.css('width', (perc)+'%'); 1247 }); 1248 1249 },0); 1250 1251 //setTimeout(function(){ 1252 App.loader('hide'); 1253 $(".fade").addClass("show"); 1254 //},1000); 1255 } 1256 }; 1257 1258 1259}(); 1260 1261var AppActions = function() { 1262 1263 var loadPage = function(urlPart) { 1264 let url = urlPart; 1265 let relLink = false; 1266 1267 if (urlPart.indexOf("//")<0) { //relative URL 1268 url = App.getUrlPrefix() + urlPart; 1269 relLink = true; 1270 } 1271 1272 App.loader("show"); 1273 if (relLink) { 1274 if (App.getWidgetId()) {
1275 // Widget mode 1276 let params = { 1277 url : url, 1278 }; 1279 1280 window.KATAPY_WIDGET.loadPage(params); 1281 } else { 1282 location.href = url; 1283 } 1284 } else { 1285 let token = App.getToken(); 1286 if (token) { 1287 if(url && url.includes("//") && !url.includes("http")) { 1288 url = "https:" + url; 1289 } 1290 url = new URL(url); 1291 url.searchParams.set("token", token); 1292 } 1293 window.open(url); 1294 } 1295 }; 1296 1297 var setCookie = function(c_name, value, days, domain){ 1298 var exdays = days; //365; 1299 var exdate=new Date(); 1300 exdate.setDate(exdate.getDate() + exdays); 1301 var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString() + "; path=/"); 1302 document.cookie=c_name + "=" + c_value; 1303 }; 1304 1305 var getCookie = function(check_name) { 1306 var a_all_cookies = document.cookie.split( ';' ); 1307 var a_temp_cookie = ''; 1308 var cookie_name = ''; 1309 var cookie_value = ''; 1310 for ( i = 0; i < a_all_cookies.length; i++ ) { 1311 a_temp_cookie = a_all_cookies[i].split( '=' ); 1312 cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); 1313 if ( cookie_name == check_name ) { 1314 if ( a_temp_cookie.length > 1 ) { 1315 cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); 1316 } 1317 return cookie_value; 1318 } 1319 a_temp_cookie = null; 1320 cookie_name = ''; 1321 } 1322 return null; //return_if_not_found; 1323 }; 1324 1325 var updateGtagPermissions = function(isGranted) { 1326 //console.log("updateGtagPermissions, isGranted = " + isGranted); 1327 // console.log(window.dataLayer) 1328 window.dataLayer = window.dataLayer || []; 1329 function gtag(){dataLayer.push(arguments);} 1330 // console.log("updateGtagPermissions, continue"); 1331 gtag('consent', 'update', { 1332 'ad_storage': isGranted? "granted":"denied", 1333 'analytics_storage': isGranted? "granted":"denied", 1334 'ad_user_data': isGranted? "granted":"denied", 1335 'ad_personalization': isGranted? "granted":"denied", 1336 }); 1337 }; 1338 1339 var cookiesEnabled = function() { 1340 if (navigator.cookieEnabled) { 1341 return true; 1342 } 1343 1344 // set and read cookie 1345 document.cookie = "cookietest=1"; 1346 var ret = document.cookie.indexOf("cookietest=") != -1; 1347 1348 // delete cookie 1349 document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT"; 1350 1351 return ret; 1352 }; 1353 1354 var loadScript = function(src, onLoad) { 1355 var script_tag = document.createElement('script'); 1356 script_tag.setAttribute("type", "text/javascript"); 1357 script_tag.setAttribute("src", src); 1358 1359 if (script_tag.readyState) { 1360 script_tag.onreadystatechange = function () { 1361 if (this.readyState == 'complete' || this.readyState == 'loaded') { 1362 onLoad(); 1363 } 1364 }; 1365 } else { 1366 script_tag.onload = onLoad; 1367 } 1368 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); 1369 }; 1370 1371 var initPageLinks = function() { 1372 /* 1373 document.querySelectorAll('a:not(.image-link)').forEach(item => { 1374 console.log(item); 1375 // item.addEventListener('click', event => { 1376 // //handle click 1377 // }) 1378 }) 1379 */ 1380 $("a:not(.image-link)").click(function(e){ 1381 var link = $(this).attr("href"); 1382 if (link === undefined) return; 1383 if (link) { 1384 if (link.indexOf("javascript")>-1) return; 1385 if (link.indexOf("#")>-1) return; 1386 if (link.indexOf("(")>-1) return; 1387 if ($(this).attr("data-toggle")=="lightbox") return; 1388 if ($(this).attr("data-loading")=="off") return; 1389 if ($(this).attr("target")=="_blank") return; 1390 e.preventDefault(); 1391 App.loader("show"); 1392 location.href = link; 1393 return false;
1394 } 1395 return true; 1396 }); 1397 }; 1398 1399 var toggleFullscreen = function() { 1400 //console.log("toggleFullscreen"); 1401 if (isFullscreen()) { 1402 closeFullscreen(); 1403 } else { 1404 openFullscreen(); 1405 } 1406 }; 1407 1408 /* View in fullscreen */ 1409 var openFullscreen = function() { 1410 var elem = document.documentElement; 1411 if (elem.requestFullscreen) { 1412 elem.requestFullscreen(); 1413 } else if (elem.webkitRequestFullscreen) { /* Safari */ 1414 elem.webkitRequestFullscreen(); 1415 } else if (elem.msRequestFullscreen) { /* IE11 */ 1416 elem.msRequestFullscreen(); 1417 } 1418 }; 1419 1420 /* Close fullscreen */ 1421 var closeFullscreen = function() { 1422 if (document.exitFullscreen) { 1423 document.exitFullscreen(); 1424 } else if (document.webkitExitFullscreen) { /* Safari */ 1425 document.webkitExitFullscreen(); 1426 } else if (document.msExitFullscreen) { /* IE11 */ 1427 document.msExitFullscreen(); 1428 } 1429 }; 1430 1431 var isFullscreen = function() { 1432 if (document.fullscreenElement) return true; 1433 if (document.webkitFullscreenElement) return true; 1434 if (document.msFullscreenElement) return true; 1435 return false; 1436 }; 1437 1438 var initFullscreenEventListener = function() { 1439 document.addEventListener('fullscreenchange', (event) => { 1440 AppUIActivity.onFullscreenChange(); 1441 }); 1442 document.addEventListener('webkitFullscreenchange', (event) => { 1443 AppUIActivity.onFullscreenChange(); 1444 }); 1445 document.addEventListener('msFullscreenchange', (event) => { 1446 AppUIActivity.onFullscreenChange(); 1447 }); 1448 AppUIActivity.onFullscreenChange(); 1449 }; 1450 1451 return { 1452 getCookie: getCookie, 1453 setCookie: setCookie, 1454 cookiesEnabled: cookiesEnabled, 1455 loadScript: loadScript, 1456 loadPage: loadPage, 1457 toggleFullscreen: toggleFullscreen, 1458 isFullscreen: isFullscreen, 1459 updateGtagPermissions, 1460 init: function() { 1461 initPageLinks(); 1462 initFullscreenEventListener(); 1463 } 1464 }; 1465 1466}(); 1467 1468jQuery.fn.reverse = [].reverse; 1469 1470jQuery(function(){ 1471 App.init(); 1472 App.checkForCookies(); 1473 AppActions.init(); 1474 AppUIActivity.init(); 1475}); 1476window.addEventListener("pageshow", function(e) { 1477 App.loader("hidefast"); 1478}, false); 1479window.addEventListener("pagehide", function(e) { 1480 App.loader("show"); 1481}, false);
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.