1var call_on_exit = function () { 2}; //reset exit 3var call_on_load = function () { 4}; //reset load 5 6/*Generic Helper Variables*/ 7var defaultPlaceHolderImage = 'https://mediacdns.karnaval.com/static/assets/v7/images/wireframe.png'; 8var footer_banner_timeout = null; 9var footer_banner_check_count = 0; 10var skip_banners = skip_banners || false; 11var last_refresh_time = 0; 12var banners_to_destroy = []; 13var banners_to_refresh = []; 14 15var article_videos = article_videos || {}; 16var yt_player_init_timeout = yt_player_init_timeout || null; 17var video_players = []; 18 19//REGUATH 20var logged_in_member = logged_in_member || null; 21var svg_icon_player_favorite = svg_icon_player_favorite || ""; 22var svg_icon_go = svg_icon_go || ""; 23 24/*PLayer Variables*/ 25/*Player*/ 26var defaultStationPlayed = false; 27var stations = stations || []; 28var active_station = active_station || {}; 29var shows = shows || []; 30var player_current_track = player_current_track || {}; 31var active_show = {}; 32 33let current_loyalty_listening_media = {}; 34 35var player = player || null; 36var podcast_player = podcast_player || null; 37 38var player_time_difference = player_time_difference || (new Date()).getTime() / 1000; 39var session_start_time = session_start_time || (new Date()).getTime(); 40var listening_start_time = listening_start_time || 0; 41var player_pause_time = player_pause_time || 0; 42var player_progress_timer = player_progress_timer || null; 43var player_status = player_status || ""; 44var player_change_timeout = player_change_timeout || null; 45var active_player = active_player || "RADIO"; 46var player_current_podcast = player_current_podcast || null; 47var restored_podcast_position = restored_podcast_position || 0; 48var pending_resume_episode_id = null; 49var pending_resume_position = 0; 50var last_saved_podcast_position = 0; 51var player_progress_is_dragging = player_progress_is_dragging || false; 52var player_active_preroll = player_active_preroll || null; 53var is_debug = is_debug || false; 54var is_secure = is_secure || true; 55var player_volume = player_volume || 0.60; 56var player_preroll_in_progress = player_preroll_in_progress || false; 57var adblock_active = adblock_active || false; 58var player_ready = player_ready || false; 59var player_has_recieved_cuepoint = player_has_recieved_cuepoint || false; 60var podcast_triggered = podcast_triggered || false; 61var player_song_update_timeout = player_song_update_timeout || null; 62var current_song_list = current_song_list || null; 63var random_tab_player_key = random_tab_player_key || ("random_tab_id_" + Math.ceil(Math.random() * 100000)); 64var player_tab_check_timeout = player_tab_check_timeout || null; 65 66var svg_icon_player_toggle_podcast = svg_icon_player_toggle_podcast || ""; 67var svg_icon_player_play = svg_icon_player_play || ""; 68var svg_icon_player_pause = svg_icon_player_pause || ""; 69var sound_manager_url_sound_file = sound_manager_url_sound_file || ""; 70 71var player_targeting_parameters = player_targeting_parameters || {}; 72var has_active_ldr_show = has_active_ldr_show || false; 73var check_ldr_show = check_ldr_show || false; 74/*EOF Player Variables*/ 75 76var lastReceivedVersion = 0; 77 78/*Banner Functions*/ 79let previousElementCount = null; 80 81var totalMsPodcastTime; 82 83// FULL PLAYER 84let isPlayerExpanded = false; 85let is_active_player_favorite = false; 86 87// GOOGLE VIDEO AD INFO 88let videoAdRun = false; 89 90/* ENUMS */ 91const playerViewTypeEnum = { 92 PLAYER_REDUCED: "player_reduced", 93 PLAYER_EXPANDED: "player_expanded", 94 PLAYER_MIDI: "player_midi" 95}; 96 97const playerStatusEnum = { 98 PLAYING: "PLAYING", 99 PAUSED: "PAUSED", 100 STOPPED: "STOPPED" 101} 102const playerTypeEnum = { 103 RADIO: "RADIO", 104 PODCAST: "PODCAST", 105} 106let playerViewStatus = playerViewTypeEnum.PLAYER_REDUCED; 107let previousPlayerViewStatus = playerViewTypeEnum.PLAYER_REDUCED; 108let lastNonExpandedPlayerViewStatus = playerViewTypeEnum.PLAYER_REDUCED; 109 110function buildVersionedMediaImageUrl(imageUrl, version = Date.now(), fallbackImage = defaultPlaceHolderImage) { 111 const normalizedImageUrl = String(imageUrl || fallbackImage).replace("http://mediacdn.", "https://mediacdns."); 112 const [baseUrl, queryString = ""] = normalizedImageUrl.split("?"); 113 const params = new URLSearchParams(queryString);
114 params.set("v", String(version)); 115 return `${baseUrl}?${params.toString()}`; 116} 117 118/*Helper function that fixes the footer banner width or removes it if empty.*/ 119function fix_footer_banner() { 120 debug("Checking footer banner"); 121 122 if (footer_banner_timeout != null) 123 clearTimeout(footer_banner_timeout); 124 125 if ($(window).width() < 981) { 126 debug("Giving up: not fixable"); 127 return false; 128 } 129 130 if (footer_banner_check_count > 10) { 131 debug("Giving up: exhausted"); 132 return false; 133 } 134 if ($(".banner_footer.loaded").length > 0) { 135 if ($(".banner_footer.loaded iframe").length > 0) { 136 if ($(".banner_footer.loaded iframe").hasClass("fixed")) { 137 debug("Clearing footer banner interval, already fixed!"); 138 return false; 139 } 140 if ($("#google_image_div img", $(".banner_footer.loaded iframe").contents()).length > 0) { 141 142 //3000px image fix --> 143 $("#div-gpt-ad-1674818381537-0 iframe").attr('width', '100%'); 144 $("#div-gpt-ad-1674818381537-0 iframe").attr('height', 'auto'); 145 //3000px image fix --< 146 147 $("#google_image_div img", $(".banner_footer.loaded iframe").contents()).css({ 148 display: "block", 149 "width": "100%", 150 "height": "auto" 151 }); 152 $(".banner_footer.loaded iframe").addClass("fixed"); 153 $(".banner_container.banner_footer .banner").addClass("static_banner"); 154 155 if ($("#google_image_div amp-img", $(".banner_footer.loaded iframe").contents()).length > 0) { 156 var to_keep = $("#google_image_div a img", $(".banner_footer.loaded iframe").contents()).clone(); 157 $("#google_image_div a", $(".banner_footer.loaded iframe").contents()).html(""); 158 $("#google_image_div a", $(".banner_footer.loaded iframe").contents()).html(to_keep); 159 } 160 } else if ($("body", $(".banner_footer.loaded iframe").contents()).length == 0) { 161 $(".banner_footer.loaded iframe").addClass("fixed"); 162 $(".banner_container.banner_footer .banner").addClass("script_banner"); 163 } 164 } 165 } else { 166 debug("Giving up: no banner found"); 167 return false; 168 } 169 170 footer_banner_check_count++; 171 footer_banner_timeout = setTimeout(function () { 172 fix_footer_banner(); 173 }, 1500); 174} 175 176/*Close banner button click*/ 177function close_banner(button_clicked) { 178 var container = $(button_clicked).closest(".banner_container"); 179 $(container).slideUp(function () { 180 if ($(container).hasClass("banner_footer")) 181 $("body").css("padding-bottom", "0"); 182 }); 183} 184 185/*Banner Loader, once banners are generated, they have to be loaded using this function*/ 186function load_banners() { 187 $(".banner_container.initialized:not(.loaded)").each(function (index, banner_container) { 188 var banner = $(".banner", banner_container); 189 var banner_id = $(banner).attr("id"); 190 191 $(banner).html("<" + "script>googletag.cmd.push(function(){googletag.display('" + banner_id + "');});" + "</" + "script>"); 192 $(banner_container).addClass("loaded"); 193 194 var banner_code = $(banner_container).data("code"); 195 if (banner_code == "/58225273/Karnaval_Footer") { 196 footer_banner_check_count = 0; 197 fix_footer_banner(); 198 } 199 }); 200} 201 202// Helper function to set active station targeting 203function setActiveStationTargeting(activeStation) { 204 // Use station sanitized url if available, otherwise clear existing GPT station targeting. 205 var activeStationSanitizedUrl = activeStation && (activeStation.sanitizedUrl || activeStation.sanitized_url); 206 if (activeStationSanitizedUrl) { 207 googletag.pubads().setTargeting('active_station', activeStationSanitizedUrl); 208 } else if (typeof googletag.pubads().clearTargeting === "function") { 209 googletag.pubads().clearTargeting('active_station'); 210 } 211} 212 213/*Banner Refresh Function*/ 214function refresh_banners(force_refresh) { 215 216 debug("Refresh banners"); 217 218 if (typeof force_refresh === "undefined") 219 force_refresh = false;
220 221 var current_time = (new Date()).getTime(); 222 223 if (!force_refresh) { 224 if (last_refresh_time > current_time - 3 * 60 * 1000) { //3 minutes. 225 debug("Too early to refresh"); 226 return false; 227 } 228 } 229 var googletagReady = typeof googletag !== 'undefined' && typeof googletag.pubads === 'function'; 230 231 if (googletagReady) { 232 if (typeof googletag.pubads().clearTargeting === "function") { 233 googletag.pubads().clearTargeting('active_player'); 234 googletag.pubads().clearTargeting('active_station'); 235 googletag.pubads().clearTargeting('active_show'); 236 googletag.pubads().clearTargeting('active_page'); 237 } 238 239 googletag.pubads().setTargeting('active_page', getActivePageName()); 240 } 241 242 //if(player_status == "PLAYING"){ 243 if (active_player == "RADIO") { 244 if (googletagReady) { 245 googletag.pubads().setTargeting('active_player', active_player); 246 setActiveStationTargeting(active_station); 247 if (player_status == "PLAYING") { 248 if (((new Date()).getTime() - session_start_time) / 60000 >= 45) 249 googletag.pubads().setTargeting('session_duration', 45); 250 if (listening_start_time != 0 && listening_start_time > 0) 251 googletag.pubads().setTargeting('active_listening', 1); 252 } 253 } 254 } else { 255 if (googletagReady) { 256 googletag.pubads().setTargeting('active_player', active_player); 257 googletag.pubads().setTargeting('active_show', active_show.sanitizedUrl); 258 } 259 } 260 //} 261 if (googletagReady) { 262 googletag.pubads().refresh(); 263 } 264 265 last_refresh_time = current_time; 266 footer_banner_check_count = 0; 267 fix_footer_banner(); 268 269 if (typeof fix_footer_banner2 === 'function') { 270 fix_footer_banner2(); 271 } 272} 273 274/*EOF Banner Functions*/ 275 276/*Generic Helper Functions*/ 277function debug(to_print, function_to_use) { 278 if (!is_debug) 279 return false; 280 if (typeof function_to_use === "undefined") { 281 function_to_use = "log"; 282 } 283 284 console[function_to_use](to_print); 285} 286 287function get_value(array, key, default_value) { 288 if (typeof default_value === "undefined") 289 default_value = false; 290 291 if (typeof array[key] === "undefined") 292 return default_value; 293 294 return array[key]; 295 296} 297 298function load_images() { 299 $(".thumb_container.dynamic:not(.loaded)").each(function (index, thumb_container) { 300 var img = $("img", $(thumb_container)); 301 if (img.length > 0 && img.data("src") != null) { 302 if (img.offset().top > $(window).scrollTop() && (img.offset().top - $(window).height() + 50) < $(window).scrollTop() && img.data("src") != img.attr("src")) { 303 if (img.data("srcset") != null && img.data("srcset") != "") { 304 img.attr("srcset", img.data("srcset")); 305 } 306 307 img.attr("src", img.data("src")); 308 309 $(thumb_container).addClass("loaded"); 310 } 311 } 312 }); 313} 314 315function refresh_addthis() { 316 if (typeof (addthis) !== "undefined") { 317 if (typeof addthis !== "undefined" && typeof addthis.layers !== "undefined" && typeof addthis.layers.refresh === "function") { 318 try { 319 addthis.layers.refresh(); 320 } catch (exception) { 321 debug(exception); 322 } 323 } 324 325 if ($(".addthis_ajax_loaded_follow").length > 0) { 326 try { 327 addthis.toolbox(".addthis_ajax_loaded_follow"); 328 } catch (exception) { 329 debug(exception); 330 } 331 } 332 } 333} 334 335function is_mobile() { 336 if ($(window).width() <= 640) 337 return true; 338 else 339 return false; 340} 341 342function isMobile() { 343 return $(window).width() <= 768; 344} 345 346function is_tablet() { 347 if ($(window).outerWidth() <= 1200 && $(window).outerWidth() > 768) 348 return true; 349 else 350 return false; 351} 352 353function is_safari() { 354 if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { 355 return true; 356 } else 357 return false;
358} 359 360function k_ajax(service_url, params, success_callback, error_callback) { 361 if (typeof success_callback !== "function") 362 success_callback = function () { 363 }; 364 365 if (typeof error_callback !== "function") 366 error_callback = function () { 367 }; 368 369 params.custom_k_parameter = "karnaval_web_v6"; 370 try { 371 debug(params); 372 $.ajax({ 373 url: service_url, 374 data: JSON.stringify(params), 375 processData: false, 376 method: "PUT", 377 dataType: "json", 378 jsonpCallback: "k_jsonp_callback_" + params.command, 379 contentType: "application/json; charset=utf-8", 380 success: function (response) { 381 debug(response, "info"); 382 383 if (response.result === true) 384 return success_callback(response); 385 else 386 return error_callback(response.messages); 387 }, 388 error: function (a, b, c) { 389 debug(params, "error"); 390 debug(service_url, "error"); 391 debug(a, "error"); 392 debug(b, "error"); 393 debug(c, "error"); 394 return error_callback(["Something went terribly wrong... !"]); 395 } 396 }); 397 } catch (exception) { 398 debug(exception, "error"); 399 debug(params); 400 } 401} 402 403async function k_ajax_async(service_url, params) { 404 // console.time("k_ajax_async"); 405 params.custom_k_parameter = "karnaval_web_v6"; 406 407 try { 408 debug(params); 409 const response = await fetch(service_url, { 410 method: "PUT", 411 headers: { 412 "Content-Type": "application/json; charset=utf-8" 413 }, 414 body: JSON.stringify(params) 415 }); 416 417 const data = await response.json(); 418 // console.log("k_ajax success", service_url, params); 419 // console.timeEnd("k_ajax_async"); 420 421 if (data.result === true) { 422 return data; 423 } else { 424 throw new Error(data.messages || "Unknown error"); 425 } 426 } catch (error) { 427 debug(params, "error"); 428 debug(service_url, "error"); 429 debug(error, "error"); 430 throw new Error("Something went terribly wrong... !"); 431 } 432} 433 434function open_link(url_to_open, push_state) { 435 var url_array = url_to_open?.split("?"); 436 var url_base = ""; 437 var search_params = {}; 438 439 if (typeof (push_state) === "undefined") 440 push_state = true; 441 442 if (url_array?.length > 0) { 443 url_base = url_array[0]?.trim(); 444 445 if (url_array.length > 1) { 446 var query_string = url_array[1].split("&"); 447 $.each(query_string, function (index, value) { 448 var split = value.split("="); 449 if (split.length > 1) 450 search_params[split[0]?.trim()] = split[1]?.trim(); 451 }); 452 } 453 } 454 455 debug("URL BASE:" + url_base) 456 debug(search_params); 457 458 if (url_base.indexOf("javascript") == 0) { 459 debug("javascript:;") 460 url_base = ""; 461 return true; 462 } 463 var ajax_domains = [ 464 "/", 465 "http://dev.karnaval.com:8080", 466 "http://dev_ar.karnaval.com:8080", 467 "http://dev_de.karnaval.com:8080", 468 "http://karnaval.com", 469 "https://www.karnaval.com", 470 "https://karnaval.com", 471 "http://de.karnaval.com", 472 "https://de.karnaval.com", 473 "http://ar.karnaval.com", 474 "https://ar.karnaval.com" 475 ]; 476 477 if (url_base != "") { 478 var is_ajax = false; 479 $.each(ajax_domains, function (index, value) { 480 if (url_base.indexOf(value) == 0 && !(url_base == "https://karnaval.com/get" || url_base == "https://karnaval.com/superfm-muzik-jurisi" || url_base == "https://karnaval.com/metrofm-muzik-jurisi" || url_base == "https://karnaval.com/joyturk-muzik-jurisi" || url_base == "https://karnaval.com/joyfm-muzik-jurisi" || url_base == "https://karnaval.com/virginradio-muzik-jurisi")) { 481 is_ajax = true; 482 return false; 483 } 484 }); 485 debug("Ajax:" + is_ajax); 486 if (is_ajax) { 487 if ($("body").hasClass("player_open")) { 488 toggle_player(); 489 } 490 if ($("body").hasClass("menu_open")) { 491 toggle_menu(); 492 } 493 if ($(".site_header").hasClass("regauth_open")) { 494 toggle_regauth(); 495 } 496 if ($(".site_header").hasClass("search_open")) { 497 toggle_search(); 498 } 499 if ($(".site_header").hasClass("profile_open")) { 500 toggle_member(); 501 } 502 search_params.is_ajax = 1; 503 $.ajax({ 504 url: url_base, 505 data: search_params, 506 success: function (response) { 507 call_on_pageexit(); 508 if (typeof (call_on_exit) === "function") { 509 call_on_exit(); 510 } 511 512 call_on_exit = function () { 513 }; //reset exit 514 call_on_load = function () { 515 }; //reset load 516 517 $("#main").html(response); 518 519 var page_title = $("#main_section").data("page_title"); 520 var page_url = $("#main_section").data("page_url"); 521 522 $.each(ajax_domains, function (index, value) { 523 if (value.length > 1) { 524 page_url = page_url.replace(value, ""); 525 debug(page_url); 526 } 527 }); 528 529 $("head title").text(page_title); 530 531 var state_object = { 532 "url": page_url, 533 "title": page_title 534 } 535 if (push_state) 536 history.pushState(state_object, page_title, page_url); 537 538 debug(state_object); 539 debug("URL:" + page_url); 540 541 initialize_lazyload_images(); 542 call_on_pageload(); 543 if (typeof (call_on_load) === "function") { 544 call_on_load(); 545 } 546 547 setTimeout(function () { 548 if (is_mobile() && shouldShowAds()) { 549 $(".banner_interstitial").removeClass("hide_on_mobile").show(); 550 $("#div-gpt-ad-1680678671516-0").show(); 551 } else { 552 if (!(url_to_open == "/programlar/benim-adim-kirmizi" || url_to_open == "https://karnaval.com/programlar/benim-adim-kirmizi" || url_to_open == "/programlar/benimsesim" || url_to_open == "https://karnaval.com/programlar/benimsesim")) 553 show_temp_interstitial_ad(); 554 } 555 }, 500); 556 }, 557 error: function (response) { 558 debug("Something went terribly wrong!"); 559 } 560 }); 561 // setTimeout(function () { 562 // if (!(url_to_open == "/programlar/benim-adim-kirmizi" || url_to_open == "https://karnaval.com/programlar/benim-adim-kirmizi" || url_to_open == "/programlar/benimsesim" || url_to_open == "https://karnaval.com/programlar/benimsesim")) 563 // show_temp_interstitial_ad(); 564 // }, 1000); 565 return false;
566 } else 567 window.open(url_base, '_blank'); 568 } else { 569 return false; 570 } 571 return true; 572} 573 574function pause_article_videos() { 575 if (typeof (article_videos) !== "undefined" && article_videos != null) { 576 $.each(article_videos, function (index, article_video_player) { 577 article_video_player.pauseVideo(); 578 }); 579 } 580 if (typeof (video_players) !== "undefined" && video_players != null) { 581 $.each(video_players, function (index, video_player) { 582 //video_player.setMute(true); 583 video_player.mute(); 584 }); 585 } 586} 587 588function on_youtube_player_state_change(event) { 589 var state = event.data; 590 if (state == 1 || state == 3) { //buffering or playing 591 player_stop(); 592 } 593} 594 595function initialize_article_videos() { 596 597 debug("init article videos called"); 598 if (!player_ready) { 599 if (yt_player_init_timeout != null) 600 clearTimeout(yt_player_init_timeout); 601 602 setTimeout(function () { 603 initialize_article_videos(); 604 }, 1000); 605 606 return false; 607 } 608 if ($("#youtube_script").length == 0) { 609 var tag = document.createElement('script'); 610 tag.id = "youtube_script"; 611 tag.src = "https://www.youtube.com/iframe_api"; 612 var firstScriptTag = document.getElementsByTagName('script')[0]; 613 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 614 615 window.onYouTubeIframeAPIReady = function () { 616 initialize_article_videos(); 617 }; 618 return false; 619 } 620 621 debug("youtube loaded called"); 622 $(".article_video_container:not(.loaded)").each(function (index, container) { 623 if ($(container).data("id") != null) { 624 var id = $(container).data("id"); 625 var type = $(container).data("type"); 626 var container_id = $(container).data("player_id"); 627 628 var article_video_player = new YT.Player(container_id, { 629 height: '390', 630 width: '640', 631 videoId: id, 632 events: { 633 onStateChange: on_youtube_player_state_change 634 } 635 }); 636 637 article_videos[container_id] = article_video_player; 638 $(container).addClass("loaded"); 639 } 640 }); 641} 642 643function destroy_article_videos() { 644 try { 645 if (typeof (article_videos) !== "undefined" && article_videos != null) { 646 $.each(article_videos, function (index, article_video_player) { 647 debug(article_video_player); 648 649 article_video_player.destroy(); 650 }); 651 } 652 } catch (exception) { 653 debug(exception, "error"); 654 } 655 article_videos = {}; 656} 657 658var clappr_player = []; 659 660function initialize_clappr() { 661 debug("initialize CLAPPR called"); 662 if (clappr_player == "") { 663 $(".video_player_container").each(function (index, player_container) { 664 var id = $(player_container).data("player_id"); 665 var video_url = $(player_container).data("video_url"); 666 var video_title = $(player_container).data("video_title"); 667 var video_thumbnail = $(player_container).data("video_thumbnail"); 668 var autoplay = $(player_container).data("autoplay") == true; 669 var is_muted = $(player_container).data("is_muted") == true; 670 var has_preroll = $(player_container).data("preroll_tag_url") != ""; 671 var preroll_key = $(player_container).data("preroll_key"); 672 var url_next = $(player_container).data("url_next"); 673 674 $(".video_player_container").html("<div class='video_player' id='" + id + "'></div>"); 675 676 clappr_player = new Clappr.Player({ 677 source: video_url 678 , parentId: "#" + $(player_container).data("player_id") 679 , width: "100%" 680 , height: "100%" 681 , autoPlay: autoplay 682 , allowUserInteraction: true 683 , mute: is_muted 684 , poster: video_thumbnail 685 }); 686 687 clappr_player.on("play", function (event) { 688 player_stop(); 689 }); 690 691 clappr_player.on("volumeupdate", function (event) { 692 if (clappr_player.getVolume() != 0) { 693 player_stop(); 694 } 695 }); 696 697 clappr_player.on('ended', function () { 698 if (typeof url_next !== undefined && url_next != null && url_next != "") { 699 open_link(url_next); 700 } 701 }); 702 703 video_players.push(clappr_player); 704 }); 705 } else { 706 clappr_player = []; 707 initialize_clappr(); 708 } 709} 710 711function fix_safari() { 712 if (is_tablet() && is_safari()) { 713 $("html,body").hide(); 714 setTimeout(function () { 715 $("html,body").fadeIn(); 716 }, 1000); 717 } else 718 return false;
719} 720 721// Simple function to fix phone number 722function fixPhoneNumber(phoneNumber) { 723 if (!phoneNumber) return phoneNumber; 724 725 // Replace O/o with 0 726 var fixed = phoneNumber.toString().replace(/O/g, '0').replace(/o/g, '0'); 727 728 // Preserve + if present at the beginning 729 var hasPlus = fixed.startsWith('+'); 730 731 // Remove non-numeric characters except + at the start 732 if (hasPlus) { 733 fixed = '+' + fixed.substring(1).replace(/[^0-9]/g, ''); 734 } else { 735 fixed = fixed.replace(/[^0-9]/g, ''); 736 } 737 738 // Ensure Turkish numbers (starting with 90) always have + prefix 739 if (fixed.startsWith('90') && !hasPlus && fixed.length >= 12 && fixed.length <= 13) { 740 fixed = '+' + fixed; 741 hasPlus = true; 742 } 743 744 // If the number doesn't start with +90 and is a valid Turkish number, add +90 prefix 745 if (!hasPlus && fixed.length >= 10 && fixed.length <= 13) { 746 // Check if it's a Turkish number pattern (starts with 0 or doesn't start with 90) 747 if (fixed.startsWith('0')) { 748 fixed = '+90' + fixed.substring(1); 749 } else if (!fixed.startsWith('90')) { 750 // If it's just numbers without country code, add +90 751 if (/^[0-9]{10}$/.test(fixed)) { 752 fixed = '+90' + fixed; 753 } 754 } 755 } 756 757 // Validate with regex - must be 11-15 digits with optional + prefix 758 var phoneRegex = /^[+]?[0-9]{11,15}$/; 759 if (!phoneRegex.test(fixed)) { 760 // If invalid, return as is if it has proper format 761 return phoneNumber; 762 } 763 764 return fixed; 765} 766 767function get_form_data(selector) { 768 var to_return = {"result": true, "data": {}}; 769 $(".error", selector).removeClass("error"); 770 $(".field", $(selector)).each(function (index, field) { 771 var key = $(field).data("key"); 772 var value = ($(field).val())?.trim(); 773 774 if ($(field).is(":radio") || $(field).is(":checkbox")) { 775 if ($(field).is(":checkbox")) { 776 value = $(field).is(":checked") ? 1 : 0; 777 to_return.data[key] = value; 778 } else if ($(field).is(":checked")) { 779 key = $(field).data("key"); 780 value = $(field).val(); 781 to_return.data[key] = value; 782 } 783 } else { 784 key = $(field).data("key"); 785 value = $(field).val(); 786 787 if (key === "phone_number" && value) { 788 value = fixPhoneNumber(value); 789 if (!validatePhone(value)) { 790 $(field).addClass("error"); 791 to_return.result = false;
792 to_return.data[key] = value; 793 } 794 $(field).val(value); 795 } 796 797 to_return.data[key] = value; 798 } 799 800 801 // Skip phone_number validation if phone validation is disabled 802 var skipPhoneValidation = (key === "phone_number" && !profilePhoneValidationEnabled); 803 if ($(field).hasClass("forced") && value == "" && !skipPhoneValidation) { 804 $(field).addClass("error"); 805 to_return.result = false; 806 to_return.data[key] = value; 807 } 808 }); 809 810 return to_return; 811} 812 813function search(form) { 814 var phrase = ($("input", $(form)).val())?.trim(); 815 if (phrase != "") { 816 if ($(".site_header").hasClass("menu_open")) 817 toggle_menu(); 818 819 $("header .search_form_container input").val(""); 820 $("header .search_form_container input").blur(); 821 open_link("/arama?phrase=" + phrase); 822 823 $(".site_header").removeClass("search_open"); 824 825 $(".search_result_container").fadeTo(400, .50) 826 } 827 return false; 828} 829 830function show_notification(to_show) { 831 832 $(".notification_outer_container").removeClass("open"); 833 //return false; 834 835 $(".notification_container .notification_header img").attr("src", to_show["url_background"]); 836 $(".notification_container .notification_title").html(to_show["title"]); 837 $(".notification_container .notification_button a img").attr("src", to_show["url_button_image"]); 838 $(".notification_container a.notification_play").attr("onclick", "player_select_station_from_notification(" + to_show["station_id"] + ");"); 839 $(".notification_container .notification_button a").attr("onclick", "player_select_station_from_notification(" + to_show["station_id"] + ");"); 840 $(".notification_outer_container").attr("notification_id", to_show["id"]); 841 if (is_mobile()) { 842 } 843 844 $(".notification_outer_container").addClass("open"); 845} 846 847function hide_notification() { 848 var notification_id = $(".notification_outer_container").attr("notification_id"); 849 k_ajax("/functions/v6/api.functions.php", 850 {"command": "save_notification_callback", "notification_id": notification_id} 851 ); 852 $(".notification_outer_container").removeClass("open"); 853} 854 855function open_menu_content(to_open) { 856 if (is_mobile()) 857 return true; 858 859 $(".menu_content_container").removeClass("active"); 860 $(".menu_content nav a").removeClass("active"); 861 $(".menu_content [data-content_id='" + to_open + "']").addClass("active"); 862 load_images(); 863} 864 865function open_footer_content(to_open) { 866 $(".footer_tab_container li").removeClass("active"); 867 $(".footer_tab_container nav a").removeClass("active"); 868 $(".footer_tab_container [data-content_id='" + to_open + "']").addClass("active"); 869} 870 871function call_on_pageexit() { 872 debug("Destroying banners!"); 873 if (banners_to_destroy.length > 0) { 874 googletag.destroySlots(banners_to_destroy); 875 debug(banners_to_destroy); 876 banners_to_destroy = []; 877 } 878 //destroy videos 879 debug("Destroying video_players!"); 880 if (typeof (video_players) !== "undefined" && video_players != null) { 881 $.each(video_players, function (index, video_player) { 882 //video_player.remove(); 883 video_player.destroy(); 884 }); 885 video_players = []; 886 } 887 debug("Destroying article videos!"); 888 destroy_article_videos(); 889 890 //destroy everything else that needs destroying 891 debug("Scrolling to top"); 892 893 $("html,body").scrollTop(0); 894} 895 896function call_on_pageload() { 897 debug("Call on pageload called"); 898 track_pageview(); 899 load_images(); 900 //initialize_video_players(); 901 initialize_clappr(); 902 initialize_article_videos(); 903 refresh_addthis(); 904 905 906 $(".menu_container").removeClass("open"); 907 $(".site_header").removeClass("menu_open"); 908 909 $(".group_widget .group_toggle:first-child").trigger("click"); 910 911 var url = getActivePageName(); 912 913 googletag.pubads().setTargeting('active_page', url); 914 googletag?.pubads()?.refresh(); 915 set_selected_menu_item(); 916} 917 918function set_selected_menu_item() { 919 var active_page = getActivePageName(); 920 var active_menu = $(`.topbar_dropdown_items > a[href$="${active_page}"]:first`); 921 $('.topbar_dropdown_items > .selected').each(function (index, item) { 922 $(item).removeClass('selected'); 923 }); 924 925 $('.menu_items > .selected').each(function (index, item) { 926 $(item).removeClass('selected'); 927 }); 928 929 $('.menu_items_mobile > .selected').each(function (index, item) { 930 $(item).removeClass('selected'); 931 }); 932 933 if (active_menu.length > 0) { 934 active_menu.addClass("selected"); 935 } 936 937 active_menu = $(`.menu_items > a[href$="${active_page}"]:first`); 938 939 if (active_menu.length > 0) { 940 active_menu.addClass("selected"); 941 } 942 943 active_menu = $(`.menu_items_mobile > a[href$="${active_page}"]:first`); 944 945 if (active_menu.length > 0) { 946 active_menu.addClass("selected"); 947 } 948} 949 950function toggle_category_lists(button, to_select) { 951 $(".playlist_title_container.button_container a span").removeClass("active"); 952 $("span", button).addClass("active"); 953 $(".v65_category_list").hide(); 954 $(".v65_category_list_" + to_select).show(); 955 load_images(); 956} 957 958function toggle_menu() { 959 if ($("body").hasClass("player_open")) { 960 toggle_player(); 961 } 962 if ($(".site_header").hasClass("regauth_open")) { 963 toggle_regauth(); 964 } 965 if ($(".site_header").hasClass("search_open")) { 966 toggle_search(); 967 } 968 if ($(".site_header").hasClass("profile_open")) { 969 toggle_member(); 970 } 971 972 if ($(".site_header").hasClass("menu_open")) { 973 $(".site_header").removeClass("menu_open"); 974 $("html,body").removeClass("menu_open"); 975 } else { 976 $("html,body").addClass("menu_open"); 977 $(".site_header").addClass("menu_open"); 978 } 979 track_event("Karnaval v6", "Toggle Menu"); 980} 981 982function load_more(button_clicked, limit, limit_mobile, is_playlist) { 983 var parent = $(button_clicked).closest(".lazy_loading_container"); 984 var button_container = $(button_clicked).closest(".button_container"); 985 var open_all = false;
986 987 if (typeof (limit) == "undefined") 988 limit = 5; 989 990 if (typeof (limit_mobile) == "undefined") 991 limit_mobile = 6; 992 993 if (is_mobile()) 994 limit = limit_mobile; 995 996 if (limit == 1000) { 997 open_all = true; 998 limit = $(".lazy_loading_item", $(button_container).parents(".lazy_loading_container")).length - $(".lazy_loading_item.loaded", $(button_container).parents(".lazy_loading_container")).length; 999 } 1000 1001 if (!$(button_container).hasClass("flipped")) { 1002 $(".lazy_loading_item:not(.loaded):lt(" + limit + ")", $(button_container).parents(".lazy_loading_container")).each(function (index, item) { 1003 $(item).slideDown().addClass("loaded"); 1004 if ($(".lazy_loading_item:not(.loaded):lt(" + limit * 2 + ")", $(button_container).parents(".lazy_loading_container")).length < 1) 1005 $(button_container).addClass("flipped"); 1006 }); 1007 } else { 1008 limit_to_close = 5; 1009 if (is_mobile()) 1010 limit_to_close = 3; 1011 1012 if ($(".lazy_loading_item:gt(" + (limit_to_close - 1) + ")", $(button_container).parents(".lazy_loading_container")).hasClass("list_item_news")) 1013 limit_to_close = 3; 1014 if (is_mobile() && $(".lazy_loading_item:gt(" + (limit_to_close - 1) + ")", $(button_container).parents(".lazy_loading_container")).hasClass("list_item_news")) 1015 limit_to_close = 2; 1016 1017 if (is_playlist) 1018 limit_to_close = 3; 1019 if (is_playlist && is_mobile()) 1020 limit_to_close = 2; 1021 1022 $(".lazy_loading_item:gt(" + (limit_to_close - 1) + ")", $(button_container).parents(".lazy_loading_container")).slideUp().removeClass("loaded"); 1023 $(button_container).removeClass("flipped"); 1024 } 1025 load_images(); 1026 1027 if (!open_all & $(".lazy_loading_item", $(button_container).parents(".lazy_loading_container")).length <= limit) 1028 $(button_container).slideUp(); 1029} 1030 1031function toggle_group(button_clicked) { 1032 var group_id = $(button_clicked).data("group_id"); 1033 var widget = $(button_clicked).closest(".group_widget"); 1034 1035 var group_to_open = $(".group_container[data-group_id=" + group_id + "]", widget); 1036 var group_toggle = $(".group_toggle[data-group_id=" + group_id + "]", widget); 1037 1038 if (group_to_open.length > 0) { 1039 $(".group_container", widget).removeClass("active"); 1040 $(".group_toggle", widget).removeClass("active"); 1041 1042 $(group_toggle).addClass("active"); 1043 $(group_to_open).addClass("active"); 1044 } 1045} 1046 1047function toggle_search() { 1048 1049 if ($("body").hasClass("player_open")) { 1050 toggle_player(); 1051 } 1052 if ($("body").hasClass("menu_open")) { 1053 toggle_menu(); 1054 } 1055 if ($(".site_header").hasClass("regauth_open")) { 1056 toggle_member(); 1057 } 1058 if ($(".site_header").hasClass("profile_open")) { 1059 toggle_member(); 1060 } 1061 1062 $(".site_header").removeClass("member_open"); 1063 $(".site_header").removeClass("regauth_open"); 1064 1065 $(".site_header").toggleClass("search_open"); 1066 track_event("Karnaval v6", "Toggle Search"); 1067} 1068 1069/*REGAUTH*/ 1070function toggle_member(isSignIn = false) { 1071 1072 if ($("body").hasClass("player_open")) { 1073 toggle_player(); 1074 } 1075 1076 if ($(".site_header").hasClass("menu_open")) 1077 toggle_menu(); 1078 1079 $(".site_header").removeClass("search_open"); 1080 1081 if (logged_in_member != null && !logged_in_member.isGuest) { 1082 get_logged_in_member(); 1083 $(".site_header").removeClass("regauth_open"); 1084 $(".site_header").toggleClass("profile_open"); 1085 1086 if ($(".site_header").hasClass("profile_open")) { 1087 $("html,body").addClass("body_fixed"); 1088 track_event("Karnaval v6", "Toggle Member"); 1089 } else { 1090 $("html,body").removeClass("body_fixed"); 1091 } 1092 } else { 1093 if ($(".site_header").hasClass("regauth_open")) 1094 toggle_regauth(); 1095 else 1096 toggle_regauth(isSignIn ? "signup" : "login"); 1097 } 1098} 1099 1100function toggle_regauth(to_toggle) { 1101 if (typeof to_toggle === "undefined" || (typeof logged_in_member !== "undefined" && logged_in_member != null && !logged_in_member.isGuest)) { 1102 $(".site_header").removeClass("regauth_open"); 1103 $("html,body").removeClass("body_fixed"); 1104 return; 1105 } 1106 $(".regauth_trigger,.form", $(".regauth_container")).removeClass("active"); 1107 $(".regauth_trigger." + to_toggle + ",.form." + to_toggle + "", $(".regauth_container")).addClass("active"); 1108 $(".site_header").removeClass("search_open"); 1109 $(".site_header").removeClass("profile_open"); 1110 $(".site_header").addClass("regauth_open"); 1111 $("html,body").addClass("body_fixed"); 1112 1113 track_event("Karnaval v6", "Toggle RegAuth"); 1114} 1115 1116/*CAPTCHA - Cloudflare Turnstile*/ 1117var captcha_error_message = "Lütfen güvenlik doÄrulamasını tamamlar mısın?"; 1118 1119function is_captcha_enabled() { 1120 return typeof captcha_enabled !== "undefined" && captcha_enabled === true; 1121} 1122 1123// Reads the token generated by the Turnstile widget of the given container. 1124function get_captcha_token(container_selector) { 1125 if (!is_captcha_enabled()) 1126 return ""; 1127 1128 var token = ""; 1129 1130 try { 1131 if (typeof turnstile !== "undefined") 1132 token = turnstile.getResponse(container_selector) || ""; 1133 } catch (exception) { 1134 debug(exception, "error"); 1135 } 1136 1137 if (!token) 1138 token = $(container_selector).find("input[name='cf-turnstile-response']").val() || ""; 1139 1140 return token; 1141} 1142 1143// A token can be used only once, so the widget has to be reset after every request. 1144function reset_captcha(container_selector) { 1145 if (!is_captcha_enabled()) 1146 return; 1147 1148 try { 1149 if (typeof turnstile !== "undefined") 1150 turnstile.reset(container_selector); 1151 } catch (exception) { 1152 debug(exception, "error"); 1153 } 1154} 1155 1156function show_captcha_error(form_selector) { 1157 $(form_selector + " .error_container").html(captcha_error_message); 1158 $(form_selector + " .error_container").slideDown(); 1159} 1160 1161function login() { 1162 $(".form.login .error_container").slideUp(function () { 1163 var form_data = get_form_data(".form.login"); 1164 if (form_data.result) { 1165 var captcha_token = get_captcha_token("#login_captcha"); 1166 1167 if (is_captcha_enabled() && !captcha_token) { 1168 show_captcha_error(".form.login"); 1169 return; 1170 } 1171 1172 $(".site_overlay").fadeIn(function () { 1173 var post_data = form_data.data; 1174 post_data.command = "login"; 1175 post_data.captcha_token = captcha_token; 1176 //if(logged_in_member !== "null" && logged_in_member.is_guest) 1177 // post_data.guest_user_id = logged_in_member.id; 1178 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 1179 1180 if (response.result === true) { 1181 logged_in_member = response.data; 1182 // Store new API tokens in localStorage if available 1183 if (response.new_api_success) { 1184 // logged_in_member = response.new_api_data; 1185 const tokenData = { 1186 accessToken: response.new_api_data.accessToken, 1187 refreshToken: response.new_api_data.refreshToken, 1188 refreshTokenExpiresAt: response.new_api_data.tokenExpiresAt, 1189 storedAt: new Date().toISOString() 1190 }; 1191 localStorage.setItem('karnaval_new_api_token', JSON.stringify(tokenData)); 1192 1193 // Fetch tokens securely from server 1194 fetch('/functions/v6/member.functions.php', { 1195 method: 'POST', 1196 headers: { 1197 'Content-Type': 'application/x-www-form-urlencoded', 1198 }, 1199 credentials: 'same-origin', // Include cookies to maintain session 1200 body: 'command=get_logged_in_member' 1201 }) 1202 .then(response => { 1203 return response.json(); 1204 }) 1205 .then(memberData => { 1206 if (memberData && memberData.new_api_success && memberData.new_api_data && memberData.new_api_data.data) { 1207 logged_in_member = memberData.new_api_data.data; 1208 } else { 1209 console.warn("Login: get_logged_in_member follow-up did not return new_api_data; keeping profile from login response.", memberData); 1210 } 1211 update_member_ui(); 1212 }) 1213 .finally(() => { 1214 setTimeout(() => { 1215 setEpisodeAsFavorite(); 1216 }, 1000); 1217 }) 1218 .catch(error => { 1219 console.error("â Failed to fetch tokens securely:", error); 1220 }); 1221 } else { 1222 update_member_ui(); 1223 } 1224 toggle_regauth(); 1225 if ($(".reset_password_wrapper").length > 0 || $(".email_verify_wrapper_container").length > 0) { 1226 open_link("/"); 1227 } 1228 // adding member age and gender to player_targeting_parameters 1229 // addPlayerTargetingParameters(); 1230 } else { 1231 let errormessage = "Ãye giriÅi yapılamadı. GiriÅ bilgilerini kontrol edip tekrar deneyebilir misin?"; 1232 if (response.messages && response.messages.length) {
1233 response.messages.forEach(message => { 1234 if (message.includes('Email not verified')) { 1235 errormessage = "E-Posta doÄrulama hatası. Lütfen E-Posta gelen kutunuzu doÄrulama için kontrol ediniz."; 1236 window.location.href = `/auth/verify-email?email=${post_data.email}`; 1237 } 1238 }) 1239 } 1240 $(".form.login .error_container").html(errormessage); 1241 $(".form.login .error_container").slideDown(); 1242 reset_captcha("#login_captcha"); 1243 } 1244 $(".site_overlay").fadeOut(); 1245 1246 }, function (response) { 1247 let errormessage = "Ãye giriÅi yapılamadı. GiriÅ bilgilerini kontrol edip tekrar deneyebilir misin?"; 1248 if (response && response.length) { 1249 response.forEach(message => { 1250 if (message.includes('Email not verified')) { 1251 errormessage = "E-Posta doÄrulama hatası. Lütfen E-Posta gelen kutunuzu doÄrulama için kontrol ediniz."; 1252 window.location.href = `/auth/verify-email?email=${post_data.email}`; 1253 } 1254 }) 1255 } 1256 $(".form.login .error_container").html(errormessage); 1257 $(".form.login .error_container").slideDown(); 1258 reset_captcha("#login_captcha"); 1259 $(".site_overlay").fadeOut(); 1260 }); 1261 }); 1262 1263 track_event("Karnaval v6", "Login"); 1264 } 1265 }); 1266} 1267 1268function setEpisodeAsFavorite () { 1269 if (logged_in_member && logged_in_member?.favorite_show_episodes) { 1270 logged_in_member?.favorite_show_episodes.map(episode => { 1271 if ($(`.action_add_favorite_episode_${episode.id}`).length) { 1272 $(`.action_add_favorite_episode_${episode.id}`).css('display', 'none'); 1273 $(`.action_remove_favorite_episode_${episode.id}`).css('display', 'inline-block'); 1274 } 1275 }) 1276 } 1277} 1278function login_facebook() { 1279 FB.getLoginStatus(function (response) { 1280 /*if (response.status === 'connected') { 1281 login_facebook_callback(response.authResponse.accessToken); 1282 } 1283 else {*/ 1284 FB.login(function (response) { 1285 if (response.status === 'connected') { 1286 login_facebook_callback(response.authResponse.accessToken); 1287 } 1288 }, {scope: 'public_profile,email'}); 1289 track_event("Karnaval v6", "Facebook Login"); 1290 /*}*/ 1291 }); 1292} 1293 1294async function handleGoogleResponse(response) { 1295 $(".site_overlay").fadeOut(); 1296 const token = response.credential; 1297 if (token) { 1298 try { 1299 const result = await socialAccountLogin.googleLogin(token); 1300 if (result?.statusCode === 200 && result?.data && result?.data?.GoogleMember) { 1301 logged_in_member = result.data.GoogleMember; 1302 const tokenData = { 1303 accessToken: result.data.accessToken, 1304 refreshToken: result.data.refreshToken, 1305 refreshTokenExpiresAt: result.data.refreshTokenExpiresAt, 1306 storedAt: new Date().toISOString() 1307 }; 1308 localStorage.setItem('karnaval_new_api_token', JSON.stringify(tokenData)); 1309 get_logged_in_member(); 1310 toggle_regauth(); 1311 } else { 1312 var message = googleErrors(result.errorCode); 1313 if (!message) { 1314 message = 'Google ile login olunamadı. Lütfen Tekrar deneyin.' 1315 } 1316 const targetBody = $('.form.signup').hasClass('active') ? '.form.signup' : '.form.login'; 1317 $(`${targetBody} .error_container`).html(message); 1318 $(`${targetBody} .error_container`).slideDown(); 1319 $(".site_overlay").fadeOut(); 1320 } 1321 } catch (e) { 1322 toggle_regauth(); 1323 } 1324 } 1325} 1326 1327function googleErrors(key) { 1328 const messages = { 1329 member_error_google_id_error: "Google ID alınamadı.", 1330 member_error_google_email_error: "Google e-posta adresini payla
1330Åman gerekiyor.", 1331 member_error_google_name_error: "Google adını paylaÅman gerekiyor.", 1332 member_error_google_last_name_error: "Google soyadını paylaÅman gerekiyor." 1333 } 1334 1335 return messages[key] ? messages[key] : false; 1336} 1337 1338function login_facebook_callback(access_token) { 1339 $(".site_overlay").fadeIn(function () { 1340 var post_data = {"command": "login_facebook", "access_token": access_token}; 1341 1342 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 1343 if (response.result === true) { 1344 logged_in_member = response.new_api_data.data; 1345 update_member_ui(); 1346 toggle_regauth(); 1347 if ($(".reset_password_wrapper").length > 0 || $(".email_verify_wrapper_container").length > 0) { 1348 open_link("/"); 1349 } 1350 } else { 1351 var message = "Lütfen daha sonra tekrar dener misin? (-1)"; 1352 if (response.messages.length > 0) 1353 message = response.messages.join("<br>"); 1354 1355 $(".form.login .error_container").html("Ãye giriÅi yapılamadı.<br>" + message); 1356 $(".form.login .error_container").slideDown(); 1357 } 1358 $(".site_overlay").fadeOut(); 1359 }, function (messages) { 1360 1361 var message = "Lütfen daha sonra tekrar dener misin? (-2)"; 1362 if (messages.length > 0) 1363 message = messages.join("<br>"); 1364 1365 $(".form.login .error_container").html("Ãye giriÅi yapılamadı.<br>" + message); 1366 $(".form.login .error_container").slideDown(); 1367 1368 $(".form.login .error_container").slideDown(); 1369 $(".site_overlay").fadeOut(); 1370 }); 1371 }); 1372} 1373 1374// ---- Apple Login Types ---- 1375/** 1376 * @typedef {Object} AppleAuthorization 1377 * @property {string} code 1378 * @property {string} id_token 1379 * @property {string} state 1380 */ 1381 1382/** 1383 * @typedef {Object} AppleUserName 1384 * @property {string} firstName 1385 * @property {string} lastName 1386 */ 1387 1388/** 1389 * @typedef {Object} AppleUser 1390 * @property {string} email 1391 * @property {AppleUserName} name 1392 */ 1393 1394/** 1395 * @typedef {Object} AppleSignInResponse 1396 * @property {AppleAuthorization} authorization 1397 * @property {AppleUser} [user] // missing on refresh logins 1398 */ 1399 1400// ---- Apple Login Types ---- 1401 1402/** 1403 * @param {AppleSignInResponse} eventDetail 1404 */ 1405function login_apple_callback(eventDetail) { 1406 console.log("Login Apple Callback Called", eventDetail); 1407 $(".site_overlay").fadeIn(function () { 1408 var post_data = { 1409 "command": "new_login_apple", 1410 "appleLoginRequestDto": eventDetail 1411 }; 1412 1413 k_ajax("/functions/v6/member.functions.php", post_data, 1414 function (response) { 1415 console.log("Login Apple API Response", response); 1416 if (response.result === true) { 1417 logged_in_member = response.new_api_data.data; 1418 update_member_ui(); 1419 toggle_regauth(); 1420 if ($(".reset_password_wrapper").length > 0) { 1421 open_link("/"); 1422 } 1423 } else { 1424 var message = "Lütfen daha sonra tekrar dener misin? (-1)"; 1425 if (response.messages.length > 0) 1426 message = response.messages.join("<br>"); 1427 1428 $(".form.login .error_container").html("Ãye giriÅi yapılamadı.<br>" + message); 1429 $(".form.login .error_container").slideDown(); 1430 } 1431 $(".site_overlay").fadeOut(); 1432 }, 1433 function (messages) { 1434 var message = "Lütfen daha sonra tekrar dener misin? (-2)"; 1435 if (messages.length > 0) 1436 message = messages.join("<br>"); 1437 1438 $(".form.login .error_container").html("Ãye giriÅi yapılamadı.<br>" + message); 1439 $(".form.login .error_container").slideDown(); 1440 $(".site_overlay").fadeOut(); 1441 } 1442 ); 1443 }); 1444} 1445 1446function get_logged_in_member() { 1447 var post_data = {"command": "get_logged_in_member"}; 1448 var tokenData = localStorage.getItem('karnaval_new_api_token'); 1449 if (tokenData) { 1450 tokenData = JSON.parse(tokenData); 1451 post_data.newApiToken = tokenData; 1452 } 1453 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 1454 1455 if (response.result === true) { 1456 logged_in_member = response.data; 1457 // Handle new API profile data if available 1458 if (response.new_api_success && response.new_api_data) { 1459 logged_in_member = response.new_api_data.data; 1460 // Store new API profile data for future use 1461 if (typeof (Storage) !== "undefined") { 1462 localStorage.setItem('karnaval_new_api_profile', JSON.stringify(response.new_api_data)); 1463 } 1464 } else { 1465 if (response.new_api_error.includes('Email not verified')) { 1466 window.location.href = `/auth/verify-email?email=${logged_in_member.email}`; 1467 } 1468 logged_in_member.firstName = logged_in_member.first_name; 1469 logged_in_member.lastName = logged_in_member.last_name; 1470 } 1471 1472 if (response.token_refreshed && typeof response.new_api_token !== 'undefined') { 1473 setNewApiToken(response.new_api_token); 1474 } 1475 1476 if ($('#profile_country').find('option').length < 2) { 1477 // `fillCountriesToSelect` lives in v7/javascript/pages/shared.js, 1478 // which is loaded asynchronously by the footer IIFE. `get_logged_in_member` 1479 // is called from the inline $(document).ready in the footer, which can fire 1480 // BEFORE the async chain finishes loading pages/shared.js. Guard the call so 1481 // we don't throw a ReferenceError on hard refresh and retry once the script 1482 // has finished loading. 1483 if (typeof fillCountriesToSelect === 'function') { 1484 fillCountriesToSelect().then(r => {}); 1485 } else { 1486 $(document).one('page:loaded', function () { 1487 if (typeof fillCountriesToSelect === 'function' && 1488 $('#profile_country').find('option').length < 2) { 1489 fillCountriesToSelect().then(r => {}); 1490 } 1491 }); 1492 } 1493 } 1494 } else { 1495 logged_in_member = null; 1496 } 1497 update_member_ui(); 1498 }, function (response) { 1499 logged_in_member = null; 1500 update_member_ui(); 1501 }); 1502} 1503 1504// Helper function to set gender field value with validation 1505function setProfileGenderValue(genderValue) { 1506 var $genderField = $("#profile_gender"); 1507 if (genderValue && genderValue !== "") { 1508 // Check if the gender value exists as an option 1509 if ($genderField.find('option[value="' + genderValue + '"]').length > 0) { 1510 $genderField.val(genderValue); 1511 } else { 1512 // If value doesn't match any option, reset to default 1513 $genderField.val(""); 1514 } 1515 } else { 1516 // If gender is empty/null/undefined, reset to default 1517 $genderField.val(""); 1518 } 1519} 1520 1521function update_member_ui() { 1522 var $userNotLoggedInFav = $('.userNotLoggedInFav'); 1523 var $userLoggedInFav = $('.userLoggedInFav'); 1524 var $userNotLoggedInFavMobile = $('.userNotLoggedInFavMobile'); 1525 var $userLoggedInFavMobile = $('.userLoggedInFavMobile'); 1526 if (logged_in_member != null && !logged_in_member.isGuest && logged_in_member.email != "") { 1527 if (logged_in_member.facebook_id > 0 && logged_in_member.facebook_id != "") { 1528 $(".password_change_button").addClass("has_facebook"); 1529 } 1530 var member_first_char = logged_in_member.firstName.substr(0, 1).toUpperCase(); 1531 1532 $(".member_trigger > span").html(member_first_char).parent().addClass("logged_in"); 1533 if (typeof logged_in_member.first_name !== 'undefined') { 1534 $.each(logged_in_member, function (key, value) { 1535 if (key == 'marketing_permissions') { 1536 if (value == "1") { 1537 $('input[name=marketingPermissionsProfile]').prop('checked', true); 1538 } 1539 } else if (key == 'gender') { 1540 // Handle gender field - set value if exists, otherwise reset to default 1541 setProfileGenderValue(value); 1542 } else { 1543 $(".form.profile .field[data-key=" + key + "]").val(value); 1544 } 1545 }); 1546 } else { 1547 $(".form.profile .field[data-key=first_name]").val(logged_in_member.firstName); 1548 $(".form.profile .field[data-key=last_name]").val(logged_in_member.lastName); 1549 1550 // Handle gender field - set value if exists, otherwise reset to default 1551 setProfileGenderValue(logged_in_member.gender); 1552 1553 $(".form.profile .field[data-key=dob]").val(logged_in_member.dateOfBirth); 1554 $(".form.profile .field[data-key=occupation]").val(logged_in_member.occupation); 1555 $(".form.profile .field[data-key=phone_number]").val(logged_in_member.phoneNumber); 1556 if (typeof logged_in_member.marketingPreferences !== 'undefined') { 1557 $.each(logged_in_member.marketingPreferences, function (key, item) { 1558 if (item.pageId && item.status == 'APPROVED' && $(`[data-
1558page=${item.staticPage.sanitizedUrl}]`).length) { 1559 $(`[data-page=${item.staticPage.sanitizedUrl}]`).prop('checked', true); 1560 } 1561 }); 1562 } 1563 if (logged_in_member.contactInfo) { 1564 // Checking the selected country if same with member's country no need to send request again. 1565 if (logged_in_member.contactInfo.countryId != $(".form.profile .field[data-key=country]").val()) { 1566 $(".form.profile .field[data-key=country]").val(logged_in_member.contactInfo.countryId).trigger('change'); 1567 } 1568 } 1569 } 1570 1571 $(".form.profile .profile_header .thumb_container").html(member_first_char); 1572 $(".form.profile .profile_header .member_name").html(logged_in_member.firstName + " " + logged_in_member.lastName); 1573 $(".form.profile .profile_header .member_email").html(logged_in_member.email); 1574 1575 $(".hide_on_login").removeClass("active"); 1576 $(".hide_on_guest").addClass("active"); 1577 if (isMobile()) { 1578 if ($userNotLoggedInFavMobile.hasClass('active')) { 1579 $userNotLoggedInFavMobile.removeClass('active').addClass('not_active'); 1580 $userLoggedInFavMobile.removeClass('not_active').addClass('active'); 1581 } else { 1582 $userNotLoggedInFavMobile.addClass('not_active'); 1583 $userLoggedInFavMobile.addClass('active'); 1584 } 1585 } else { 1586 if ($userNotLoggedInFav.hasClass('active')) { 1587 $userNotLoggedInFav.removeClass('active').addClass('not_active'); 1588 $userLoggedInFav.removeClass('not_active').addClass('active'); 1589 } else { 1590 $userNotLoggedInFav.addClass('not_active'); 1591 $userLoggedInFav.addClass('active'); 1592 } 1593 1594 // Update member container 1595 const memberContainer = document.getElementById('member_container_id'); 1596 if (memberContainer) { 1597 memberContainer.classList.remove('user-logged-in', 'user-not-logged-in'); 1598 1599 if (logged_in_member !== null) { 1600 memberContainer.classList.add('user-logged-in'); 1601 } else { 1602 memberContainer.classList.add('user-not-logged-in'); 1603 } 1604 } 1605 } 1606 1607 ga('karnaval.set', 'dimension2', 'logged_in'); 1608 } else { 1609 $(".thumb_container,.member_name,.member_email", $(".form.profile .profile_header")).html(""); 1610 $(".form.profile .field").val(""); 1611 $(".form.profile .field[type='checkbox']").prop("checked", false); 1612 $(".member_trigger > span").html("ÃYE GİRİÅİ").parent().removeClass("logged_in"); 1613 $(".hide_on_login").addClass("active"); 1614 $(".hide_on_guest").removeClass("active"); 1615 ga('karnaval.set', 'dimension2', 'not_logged_in'); 1616 1617 if ($userNotLoggedInFav.hasClass('not_active')) { 1618 $userNotLoggedInFav.removeClass('not_active').addClass('active'); 1619 $userLoggedInFav.removeClass('active').addClass('not_active'); 1620 } else { 1621 $userNotLoggedInFav.addClass('active'); 1622 $userLoggedInFav.addClass('not_active'); 1623 } 1624 1625 // Update member container 1626 const memberContainer = document.getElementById('member_container_id'); 1627 if (memberContainer) { 1628 memberContainer.classList.remove('user-logged-in', 'user-not-logged-in'); 1629 memberContainer.classList.add('user-not-logged-in'); 1630 } 1631 } 1632 get_member_favorites().then(r => { 1633 }); 1634 $.event.trigger('updateMemberUI', [{}]) // 20210421 m.uob - send global event 1635} 1636 1637// Close global overlay 1638function close_overlay() { 1639 $(".site_overlay").fadeOut(); 1640 1641 // If we're on the reset password page, restore the inputs 1642 try { 1643 if (window.location.pathname.includes('/auth/reset-password')) { 1644 showResetFlow('inputs'); 1645 } 1646 } catch (e) { 1647 } 1648} 1649 1650// Smoothly toggle between reset password flow steps (inputs <-> error) 1651function showResetFlow(step, messageHtml) {
1652 var $inputs = $('#password_reset_inputs'); 1653 var $error = $('#password_reset_error'); 1654 if (!$inputs.length || !$error.length) return; 1655 1656 if (step === 'error') { 1657 if (messageHtml) { 1658 $("#password_reset_error .error_list").html(messageHtml); 1659 } 1660 $inputs.stop(true, true).fadeOut(150, function () { 1661 $error.stop(true, true).fadeIn(200); 1662 }); 1663 } else { // 'inputs' 1664 $error.stop(true, true).fadeOut(150, function () { 1665 $inputs.stop(true, true).fadeIn(200); 1666 }); 1667 } 1668} 1669 1670function logout() { 1671 $(".site_overlay").fadeIn(function () { 1672 var post_data = {"command": "logout"}; 1673 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 1674 logged_in_member = null; 1675 1676 // Clear new API tokens, profile, update, forgot password, and reset password data from localStorage 1677 try { 1678 localStorage.removeItem('karnaval_new_api_token'); 1679 localStorage.removeItem('karnaval_new_api_profile'); 1680 localStorage.removeItem('karnaval_new_api_update'); 1681 localStorage.removeItem('karnaval_new_api_forgot_password'); 1682 localStorage.removeItem('karnaval_new_api_reset_password'); 1683 } catch (error) { 1684 console.error("â Failed to clear tokens from localStorage:", error); 1685 } 1686 1687 update_member_ui(); 1688 $(".site_overlay").fadeOut(); 1689 $(".site_header").removeClass("regauth_open"); 1690 $(".site_header").removeClass("profile_open"); 1691 window.location.href = '/' 1692 }, function (response) { 1693 logged_in_member = null; 1694 1695 // Clear new API tokens, profile, update, forgot password, and reset password data from localStorage even on error 1696 try { 1697 localStorage.removeItem('karnaval_new_api_token'); 1698 localStorage.removeItem('karnaval_new_api_profile'); 1699 localStorage.removeItem('karnaval_new_api_update'); 1700 localStorage.removeItem('karnaval_new_api_forgot_password'); 1701 localStorage.removeItem('karnaval_new_api_reset_password'); 1702 } catch (error) { 1703 console.error("â Failed to clear tokens from localStorage:", error); 1704 } 1705 1706 update_member_ui(); 1707 $(".site_overlay").fadeOut(); 1708 $(".site_header").removeClass("regauth_open"); 1709 $(".site_header").removeClass("profile_open"); 1710 location.reload(); 1711 }); 1712 1713 track_event("Karnaval v6", "Logout"); 1714 }); 1715} 1716 1717function validate_email(email) { 1718 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 1719 return re.test(String(email).toLowerCase()); 1720} 1721 1722function signup() { 1723 if (validate_email($("#signup_email").val())) { 1724 // Validate password before proceeding 1725 var password = $("#signup_password").val(); 1726 var passwordValidation = validatePasswordPattern(password); 1727 1728 if (!passwordValidation.isValid) { 1729 $("#signup_password").addClass('error'); 1730 $(".form.signup .error_container").html(passwordValidation.errors.join('<br>')); 1731 $(".form.signup .error_container").slideDown(); 1732 return; 1733 } 1734 1735 if ($(".kvkk_signup").is(':checked')) { 1736 $(".form.signup .error_container").slideUp(function () { 1737 var form_data = get_form_data(".form.signup"); 1738 if (form_data.result) { 1739 var captcha_token = get_captcha_token("#signup_captcha"); 1740 1741 if (is_captcha_enabled() && !captcha_token) { 1742 show_captcha_error(".form.signup"); 1743 return; 1744 } 1745 1746 $(".site_overlay").fadeIn(function () { 1747 var post_data = form_data.data; 1748 post_data.command = "signup"; 1749 post_data.captcha_token = captcha_token; 1750 post_data.marketingPermSource = "HS_WEB"; 1751 post_data.kvkk = $(".kvkk_signup").is(':checked') ? 1 : 0; 1752 post_data.marketingPerms = $("input[name=marketingPermissions]").is(':checked') ? 1 : 0; 1753 post_data.kvkkPermit = $("[name=kvkkPermit]").is(':checked') ? 1 : 0; 1754 //if(logged_in_member.is_guest) 1755 // post_data.guest_user_id = logged_in_member.id; 1756 1757 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 1758 if (response.result === true) { 1759 // Commented these lines because after signup user has to do email verification 1760 /* logged_in_member = response.data; 1761 update_member_ui(); 1762 toggle_regauth(); 1763 */ 1764 gtag('event', 'conversion', {'send_to': 'AW-376454978/_b7RCN3V_YwCEML-wLMB'}); //Event snippet for Ãye Olma conversion page 1765 1766 // Handle new API register response if available 1767 if (response.new_api_success && response.new_api_data) { 1768 // Store new API register data for future use 1769 if (typeof (Storage) !== "undefined") { 1770 localStorage.setItem('karnaval_new_api_register', JSON.stringify(response.new_api_data)); 1771 } 1772 1773 // Show confirmation message using overlay_message 1774 $(".overlay_message strong").text('Kayıt baÅarılı!'); 1775 $(".overlay_message span").text('E-posta adresinize doÄrulama baÄlantısı gönderildi. Lütfen e-postanızı kontrol edin.'); 1776 $(".site_overlay").fadeIn(); 1777 1778 // Overlay stays visible - user needs to manually close it 1779 } else { 1780 // If new API is not successful, hide the overlay normally 1781 $(".site_overlay").fadeOut(); 1782 } 1783 } else { 1784 var message = "Lütfen daha sonra tekrar dener misin? (-1)"; 1785 if (response.messages.length > 0) 1786 message = response.messages.join("<br>"); 1787 1788 $(".form.signup .error_container").html("Kayıt yapılamadı.<br>" + message); 1789 $(".form.signup .error_container").slideDown(); 1790 reset_captcha("#signup_captcha"); 1791 $(".site_overlay").fadeOut(); 1792 } 1793 }, function (messages) { 1794 1795 var message = "Lütfen daha sonra tekrar dener misin? (-2)"; 1796 if (messages.length > 0) 1797 message = messages.join("<br>"); 1798 1799 $(".form.signup .error_container").html("Kayıt yapılamadı.<br>" + message); 1800 $(".form.signup .error_container").slideDown(); 1801 reset_captcha("#signup_captcha"); 1802 $(".site_overlay").fadeOut(); 1803 }); 1804 }); 1805 track_event("Karnaval v6", "Signup"); 1806 } 1807 }); 1808 } else { 1809 $(".form.signup .error_container").html("ÃyeliÄinizin tamamlanabilmesi için <a href='kisisel-verilerin-korunmasi-politikamiz'>KiÅisel Verileri Koruma Metni</a>'ni okuyup kabul etmeniz gerekmektedir."); 1810 $(".form.signup .error_container").slideDown(); 1811 } 1812 } else { 1813 $(".form.signup .error_container").html("Lütfen geçerli bir mail adresi girin."); 1814 $(".form.signup .error_container").slideDown(); 1815 } 1816} 1817 1818// Password validation function (used for signup and reset password) 1819function validatePasswordPattern(password) { 1820 var errors = []; 1821 1822 // Password cannot contain whitespace 1823 if (/\s/.test(password)) { 1824 errors.push("Åifre boÅluk içeremez."); 1825 } 1826 1827 // Check minimum length 1828 if (password.length < 8) { 1829 errors.push("Åifre en az 8 karakter olmalıdır."); 1830 } 1831 1832 // Check for at least one capital letter 1833 if (!/[A-Z]/.test(password)) { 1834 errors.push("Åifre en az bir büyük harf içermelidir."); 1835 } 1836 1837 // Check for at least one lower letter 1838 if (!/[a-z]/.test(password)) { 1839 errors.push("Åifre en az bir küçük harf içermelidir."); 1840 } 1841 1842 // Check for at least one special character from @$!%*?&+. 1843 if (!/[@$!%*?&+.]/.test(password)) { 1844 errors.push("Åifre en az bir özel karakter (@$!%*?&+.)
1844içermelidir."); 1845 } 1846 1847 return { 1848 isValid: errors.length === 0, 1849 errors: errors 1850 }; 1851} 1852 1853// Initialize signup password validation 1854function initSignupPasswordValidation() { 1855 var $passwordInput = $('#signup_password'); 1856 var $errorContainer = $('.form.signup .error_container'); 1857 1858 if ($passwordInput.length === 0) { 1859 return; // Password input doesn't exist on this page 1860 } 1861 1862 // Validate on input and blur events 1863 $passwordInput.on('input blur', function () { 1864 var password = $(this).val(); 1865 1866 // Remove previous error styling 1867 $passwordInput.removeClass('error'); 1868 1869 // If password is empty, don't show validation errors 1870 if (password === '') { 1871 $errorContainer.slideUp(); 1872 return; 1873 } 1874 1875 // Validate password pattern 1876 var validation = validatePasswordPattern(password); 1877 1878 if (!validation.isValid) { 1879 // Add error class to input 1880 $passwordInput.addClass('error'); 1881 1882 // Show error message 1883 $errorContainer.html(validation.errors.join('<br>')); 1884 $errorContainer.slideDown(); 1885 } else { 1886 // Password is valid, hide error container 1887 $errorContainer.slideUp(); 1888 } 1889 }); 1890} 1891 1892// Initialize whitespace validation for password inputs with button disabling 1893function initPasswordWhitespaceValidation() { 1894 // Configuration for all password inputs 1895 const configs = [ 1896 {input: '#login_password', errorContainer: '.form.login .error_container', button: '.form.login .button_login'}, 1897 {input: '#password', errorContainer: '#password_reset_error', button: '#reset_password_btn'}, 1898 {input: '#password_re', errorContainer: '#password_reset_error', button: '#reset_password_btn'}, 1899 { 1900 input: '#profile_new_password', 1901 errorContainer: '.profile_container .error_container', 1902 button: '#updateProfileButton' 1903 }, 1904 { 1905 input: '#profile_confirm_password', 1906 errorContainer: '.profile_container .error_container', 1907 button: '#updateProfileButton' 1908 } 1909 ]; 1910 1911 // CSS objects for button states (defined once for efficiency) 1912 const buttonStyles = { 1913 enabled: {'background-color': '', 'cursor': 'pointer', 'pointer-events': 'auto', 'opacity': '1'}, 1914 disabled: {'background-color': '#ccc', 'cursor': 'not-allowed', 'pointer-events': 'none', 'opacity': '0.6'} 1915 }; 1916 1917 configs.forEach(config => { 1918 const $passwordInput = $(config.input); 1919 const $errorContainer = $(config.errorContainer); 1920 const $button = config.button ? $(config.button) : null; 1921 const hasButton = $button && $button.length > 0; 1922 1923 // Prevent button click when disabled 1924 if (hasButton) { 1925 $button.on('click', function (e) { 1926 if ($(this).hasClass('disabled')) { 1927 e.preventDefault(); 1928 e.stopPropagation(); 1929 return false; 1930 } 1931 }); 1932 } 1933 1934 // Validate on input and blur events 1935 $passwordInput.on('input blur', function () { 1936 const password = $(this).val(); 1937 const hasWhitespace = password && /\s/.test(password); 1938 1939 $passwordInput.toggleClass('error', hasWhitespace); 1940 1941 if (!password || !hasWhitespace) { 1942 $errorContainer.slideUp(); 1943 if (hasButton) { 1944 $button.css(buttonStyles.enabled).removeClass('disabled'); 1945 } 1946 } else { 1947 $errorContainer.html('Åifre boÅluk içeremez.').slideDown(); 1948 if (hasButton) { 1949 $button.css(buttonStyles.disabled).addClass('disabled'); 1950 } 1951 } 1952 }); 1953 }); 1954} 1955 1956// Frontend validation state for reset password 1957var resetPasswordValidationEnabled = true; // Default: enabled 1958 1959 1960// For testing purpose - toggle enable/disable frontend password validation 1961function toggleResetPasswordValidation(enabled) { 1962 if (typeof enabled === 'undefined') { 1963 // Toggle the current state 1964 resetPasswordValidationEnabled = !resetPasswordValidationEnabled; 1965 } else { 1966 // Set to specific state 1967 resetPasswordValidationEnabled = enabled; 1968 } 1969 1970 // Re-initialize validation if inputs exist 1971 if ($('#password').length && $('#password_re').length) { 1972 // Remove existing event listeners 1973 $('#password, #password_re').off('input blur'); 1974 1975 // Re-initialize if enabled 1976 if (resetPasswordValidationEnabled) { 1977 initResetPasswordValidation(); 1978 } 1979 } 1980 1981 return resetPasswordValidationEnabled; 1982} 1983 1984// Frontend validation state for profile phone 1985var profilePhoneValidationEnabled = false; // Default: enabled 1986 1987// For testing purpose - toggle enable/disable frontend phone validation 1988function toggleProfilePhoneValidation(enabled) { 1989 if (typeof enabled === 'undefined') { 1990 // Toggle the current state 1991 profilePhoneValidationEnabled = !profilePhoneValidationEnabled; 1992 } else { 1993 // Set to specific state 1994 profilePhoneValidationEnabled = enabled; 1995 } 1996 1997 // Apply changes to phone input and form 1998 if ($('#profile_phone_number').length) { 1999 var $phoneInput = $('#profile_phone_number'); 2000 var $profileForm = $('.form.profile'); 2001 2002 if (profilePhoneValidationEnabled) { 2003 // Re-enable HTML5 pattern validation 2004 $phoneInput.attr('pattern', '^[+]?[0-9]{11,15}$'); 2005 // Remove novalidate from form if it exists 2006 if ($profileForm.length) { 2007 $profileForm.removeAttr('novalidate'); 2008 } 2009 } else { 2010 // Disable HTML5 pattern validation by removing the pattern attribute 2011 $phoneInput.removeAttr('pattern'); 2012 // Remove any existing error class 2013 $phoneInput.removeClass('error'); 2014 // Add novalidate to form to prevent HTML5 validation 2015 if ($profileForm.length) { 2016 $profileForm.attr('novalidate', 'novalidate'); 2017 } 2018 } 2019 } 2020 2021 return profilePhoneValidationEnabled; 2022} 2023 2024// Initialize reset password validation 2025function initResetPasswordValidation() { 2026 // Check if validation is enabled 2027 if (!resetPasswordValidationEnabled) { 2028 return; 2029 } 2030 2031 var $passwordInput = $('#password'); 2032 var $passwordReInput = $('#password_re'); 2033 2034 if ($passwordInput.length === 0 || $passwordReInput.length === 0) { 2035 return; // Password inputs don't exist on this page 2036 } 2037 2038 // Reusable validation function for reset password 2039 function validateResetPasswordInputs() { 2040 var password = $passwordInput.val(); 2041 var passwordRe = $passwordReInput.val(); 2042 2043 // Remove previous error styling 2044 $passwordInput.removeClass('error'); 2045 $passwordReInput.removeClass('error'); 2046 2047 // If password is empty, don't show validation errors 2048 if (password === '') { 2049 movePasswordErrorContainer('toOriginal', 'reset', true); 2050 return; 2051 } 2052 2053 // Validate password pattern using reusable function 2054 var patternValidation = validatePasswordPattern(password); 2055 2056 if (!patternValidation.isValid) { 2057 // Add error class to both password fields 2058 $passwordInput.addClass('error'); 2059 $passwordReInput.addClass('error'); 2060 2061 // Move error container to bottom of password inputs and show error message 2062 var $movedErrorContainer = movePasswordErrorContainer('toFields', 'reset'); 2063 if ($movedErrorContainer && $movedErrorContainer.length) { 2064 $movedErrorContainer.find('.error_list').html(patternValidation.errors.join('<br>')); 2065 $movedErrorContainer.slideDown(); 2066 } 2067 } else if (password !== passwordRe && passwordRe !== '') { 2068 // Passwords don't match (only check if pattern is valid) 2069 $passwordInput.addClass('error'); 2070 $passwordReInput.addClass('error'); 2071 2072 // Move error container to bottom of password inputs and show error message 2073 var $movedErrorContainer = movePasswordErrorContainer('toFields', 'reset'); 2074 if ($movedErrorContainer && $movedErrorContainer.length) { 2075 $movedErrorContainer.find('.error_list').html("Yeni Åifren ile doÄrulama Åifren aynı olmalı."); 2076 $movedErrorContainer.slideDown(); 2077 } 2078 } else { 2079 // Password is valid, move error container back to original position 2080 movePasswordErrorContainer('toOriginal', 'reset', true); 2081 } 2082 } 2083 2084 // Validate on input and blur events for both password fields 2085 $passwordInput.on('input blur', validateResetPasswordInputs); 2086 $passwordReInput.on('input blur', validateResetPasswordInputs); 2087} 2088 2089// Helper function to move error container to bottom of password fields container or back to original position 2090function movePasswordErrorContainer(action, type, clearContent) { 2091 var $errorContainer, $targetContainer, $originalParent, $originalAnchor, errorSelector, targetSelector; 2092 2093 switch (type) { 2094 case 'profile': 2095 $errorContainer = $(".profile_container .error_container"); 2096 $targetContainer = $('.hidden_input_container'); 2097 $originalParent = $("#profileForm"); 2098 $originalAnchor = $originalParent.find('.form.profile'); 2099 errorSelector = '.error_container'; 2100 targetSelector = '.hidden_input_container'; 2101 break; 2102 case 'reset': 2103 $errorContainer = $("#password_reset_error"); 2104 $targetContainer = $('#password_reset_inputs'); 2105 $originalParent = $("#password_reset_form"); 2106 $originalAnchor = $originalParent.find('#password_reset_inputs'); 2107 errorSelector = '#password_reset_error'; 2108 targetSelector = '#password_reset_inputs'; 2109 break; 2110 default: 2111 return null; 2112 } 2113 2114 switch (action) { 2115 case 'toFields': 2116 // Move error container to bottom of password fields container if not already there 2117 if ($errorContainer.length && $targetContainer.length) { 2118 if (!$targetContainer.find(errorSelector).length) { 2119 $errorContainer.appendTo($targetContainer); 2120 } 2121 // Ensure error container is visible 2122 $errorContainer.show(); 2123 } 2124 return $errorContainer; 2125 2126 case 'toOriginal': 2127 // For reset password, error container stays at bottom, just clear content if needed 2128 if (type === 'reset') { 2129 if (clearContent) { 2130 $errorContainer.find('.error_list').html('').parent().slideUp(); 2131 } 2132 return $errorContainer; 2133 } 2134 2135 // For profile, move it back to its original position
2136 if ($errorContainer.closest(targetSelector).length) { 2137 // Move it back to its original position 2138 $errorContainer.insertBefore($originalAnchor); 2139 if (clearContent) { 2140 // For profile, clear entire container 2141 $errorContainer.html('').slideUp(); 2142 } 2143 } 2144 return $errorContainer; 2145 2146 default: 2147 return null; 2148 } 2149} 2150 2151function update_profile() { 2152 if ($('#updateProfileButton').is('[disabled]')) { 2153 $('#updateProfileButton').attr('disabled', false).css('background-color', '#22b573').html('BİLGİLERİMİ GÃNCELLE'); 2154 $('.profile input').attr('disabled', false).css('color', '#000 !important'); 2155 $('.profile select').attr('disabled', false).css('color', '#000 !important'); 2156 2157 // Reset password change checkbox when entering edit mode (only if it wasn't already checked) 2158 var wasPasswordChecked = $('#profile_update_password').is(':checked'); 2159 if (!wasPasswordChecked) { 2160 $('#profile_update_password').prop('checked', false); 2161 $('.hidden_input_container').removeClass('show'); 2162 $('#profile_new_password').val(''); 2163 $('#profile_confirm_password').val(''); 2164 $('#profile_new_password, #profile_confirm_password').removeClass('error'); 2165 // Move error container back to original position if it was moved 2166 movePasswordErrorContainer('toOriginal', 'profile', true); 2167 } 2168 return; 2169 } 2170 2171 $(".profile_container .error_container").slideUp(function () { 2172 // Validate password match if password change is enabled 2173 if ($('#profile_update_password').is(':checked')) { 2174 var newPassword = $('#profile_new_password').val(); 2175 var confirmPassword = $('#profile_confirm_password').val(); 2176 2177 $('#profile_new_password, #profile_confirm_password').removeClass('error'); // Remove any previous error classes 2178 2179 if (newPassword !== confirmPassword) { 2180 $('#profile_new_password, #profile_confirm_password').addClass('error'); // Add error class to both password fields 2181 2182 // Move error container to bottom of password fields and show error message 2183 var $errorContainer = movePasswordErrorContainer('toFields', 'profile'); 2184 $errorContainer.html("Yeni Åifren ile doÄrulama Åifren aynı olmalı.").slideDown(); 2185 2186 return false; 2187 } else { 2188 // Move error container back to original position if passwords match 2189 movePasswordErrorContainer('toOriginal', 'profile', false); 2190 } 2191 } 2192 2193 // Skip phone validation in get_form_data if validation is disabled 2194 var $phoneInput = $('#profile_phone_number'); 2195 var originalPattern = null; 2196 if (!profilePhoneValidationEnabled && $phoneInput.length) { 2197 // Temporarily remove pattern attribute before validation 2198 originalPattern = $phoneInput.attr('pattern'); 2199 if (originalPattern) { 2200 $phoneInput.removeAttr('pattern'); 2201 } 2202 } 2203 2204 var form_data = get_form_data(".form.profile"); 2205 2206 // Restore pattern attribute if it was removed 2207 if (!profilePhoneValidationEnabled && originalPattern && $phoneInput.length) { 2208 $phoneInput.attr('pattern', originalPattern); 2209 } 2210 2211 if (form_data.result) { 2212 $(".site_overlay").fadeIn(function () { 2213 var post_data = form_data.data; 2214 post_data.marketingPerms = $("input[name=marketingPermissionsProfile]").is(':checked') ? 1 : 0; 2215 post_data.command = "update"; 2216 post_data.marketingPermSource = "HS_WEB"; 2217 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 2218 // Check for new_api_error even if result is true 2219 if (response.new_api_error) { 2220 // Extract and format error messages from new_api_error 2221 var displayMessages = extractNewApiErrorMessages(response.new_api_error); 2222 var formattedMessage = displayMessages.length > 0 2223 ? displayMessages.join("<br>") 2224 : response.new_api_error; 2225 2226 // Show error message in profile error container 2227 $(".profile_container .error_container").html("Güncelleme yapılamadı.<br>" + formattedMessage); 2228 $(".profile_container .error_container").slideDown(); 2229 $(".site_overlay").fadeOut(); 2230 return; 2231 } 2232 2233 if (response.result === true) { 2234 $(".profile_container .success_container").slideDown(function () { 2235 setTimeout(function () { 2236 $(".profile_container .success_container").slideUp(); 2237 }, 2000) 2238 }); 2239 logged_in_member = response.new_api_data.data; 2240 2241 // Handle new API update data if available 2242 if (response.new_api_success && response.new_api_data) { 2243 // Store new API update data for future use 2244 if (typeof (Storage) !== "undefined") { 2245 localStorage.setItem('karnaval_new_api_update', JSON.stringify(response.new_api_data)); 2246 } 2247 } 2248 2249 update_member_ui(); 2250 2251 $('#updateProfileButton').attr('disabled', true).css('background-color', 'grey').html('BİLGİLERİMİ DÃZENLE'); 2252 $('.profile input').attr('disabled', true).css('color', ''); 2253 $('.profile select').attr('disabled', true).css('color', ''); 2254 2255 // Reset password change checkbox and hide password fields after saving 2256 $('#profile_update_password').prop('checked', false); 2257 $('.hidden_input_container').removeClass('show'); 2258 $('#profile_new_password').val(''); 2259 $('#profile_confirm_password').val(''); 2260 $('#profile_new_password, #profile_confirm_password').removeClass('error'); // Remove error classes 2261 movePasswordErrorContainer('toOriginal', 'profile', true); // Move error container back to original position if it was moved 2262 } else { 2263 var message = "Lütfen daha sonra tekrar dener misin? (-1)"; 2264 if (response.messages.length > 0) 2265 message = response.messages.join("<br>"); 2266 2267 $(".profile_container .error_container").html("Güncelleme yapılamadı.<br>" + message); 2268 $(".profile_container .error_container").slideDown(); 2269 } 2270 $(".site_overlay").fadeOut(); 2271 }, function (messages) { 2272 2273 var message = "Lütfen daha sonra tekrar dener misin? (-2)"; 2274 if (messages.length > 0) 2275 message = messages.join("<br>"); 2276 2277 $(".profile_container .error_container").html("Güncelleme yapılamadı.<br>" + message); 2278 $(".profile_container .error_container").slideDown(); 2279 $(".site_overlay").fadeOut(); 2280 }); 2281 }); 2282 } 2283 }); 2284} 2285 2286// Handle password change checkbox toggle 2287function init_password_change_toggle() { 2288 $('#profile_update_password').on('change', function () { 2289 var $checkbox = $(this); 2290 var $container = $('.hidden_input_container'); 2291 2292 if ($checkbox.is(':checked')) { 2293 $container.addClass('show'); 2294 // If the button is still disabled (not in edit mode), activate edit mode 2295 if ($('#updateProfileButton').is('[disabled]')) { 2296 activate_profile_edit_mode(); 2297 } 2298 } else { 2299 $container.removeClass('show'); 2300 // Clear password fields when unchecked 2301 $('#profile_new_password').val(''); 2302 $('#profile_confirm_password').val(''); 2303 $('#profile_new_password, #profile_confirm_password').removeClass('error'); // Remove error classes 2304 } 2305 }); 2306} 2307 2308// Helper function to activate edit mode without resetting password checkbox 2309function activate_profile_edit_mode() { 2310 $('#updateProfileButton').attr('disabled', false).css('background-color', '#22b573').html('BİLGİLERİMİ GÃNCELLE'); 2311 $('.profile input').attr('disabled', false).css('color', '#000 !important'); 2312 $('.profile select').attr('disabled', false).css('color', '#000 !important'); 2313} 2314 2315// Initialize password toggle on document ready 2316$(document).ready(function () { 2317 init_password_change_toggle(); 2318 initSignupPasswordValidation(); 2319 initResetPasswordValidation(); 2320 // Initialize whitespace validation for all password inputs with button disabling 2321 initPasswordWhitespaceValidation(); 2322}); 2323 2324function send_recovery_email() { 2325 var form_data = get_form_data(".form.forgot_password"); 2326 debug(form_data); 2327 if (form_data.result) { 2328 var captcha_token = get_captcha_token("#forgot_password_captcha"); 2329 2330 if (is_captcha_enabled() && !captcha_token) { 2331 show_captcha_error(".form.forgot_password"); 2332 return; 2333 } 2334 2335 $(".site_overlay").fadeIn(function () { 2336 $(".form.forgot_password .error_container").slideUp(); 2337 var post_data = form_data.data; 2338 post_data.command = "send_recovery_mail"; 2339 post_data.captcha_token = captcha_token; 2340 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 2341 if (response.result === true) { 2342 $(".form.forgot_password .button_login").html("GÃNDERİLDİ").css("background", "red"); 2343 $(".form.forgot_password #login_email").val(""); 2344 setTimeout(function () { 2345 $(".form.forgot_password .button_login").html("GÃNDER").css("background", "#23b574"); 2346 }, 4000); 2347 2348 // Handle new API forgot password response if available 2349 if (response.new_api_success && response.new_api_data) { 2350 // Store only the email for future use (simplified) 2351 if (typeof (Storage) !== "undefined") { 2352 var emailData = {email: response.new_api_data.data?.email || response.new_api_data.email || ''}; 2353 localStorage.setItem('karnaval_new_api_forgot_password', JSON.stringify(emailData)); 2354 } 2355 2356 // Show confirmation message using overlay_message 2357 $(".overlay_message strong").text('E-posta gönderildi!'); 2358 $(".overlay_message span").text('Åifre sıfırlama baÄlantısı e-posta adresinize gönderildi. Lütfen e-postanızı kontrol edin.'); 2359 $(".site_overlay").fadeIn(); 2360 2361 // Overlay stays visible - user needs to manually close it 2362 } else { 2363 // If new API is not successful, hide the overlay normally 2364 $(".site_overlay").fadeOut(); 2365 } 2366 } else { 2367 if (!$.isArray(response.messages) || response.messages.length < 1) 2368 response.messages = ["Bilinmeyen bir hata oluÅtu, daha sonra tekrar deneyebilir misin? (-1.1)"]; 2369 2370 $(".form.forgot_password .error_container").html(response.messages.join("<br>")); 2371 $(".form.forgot_password .error_container").slideDown(); 2372 reset_captcha("#forgot_password_captcha"); 2373 $(".site_overlay").fadeOut(); 2374 } 2375 }, function (messages) { 2376 if (!$.isArray(messages) || messages.length < 1) 2377 messages = ["Bilinmeyen bir hata oluÅtu, daha sonra tekrar deneyebilir misin? (-1.2)"]; 2378 $(".form.forgot_password .error_container").html(messages.join("<br>")); 2379 $(".form.forgot_password .error_container").slideDown(); 2380 reset_captcha("#forgot_password_captcha"); 2381 $(".site_overlay").fadeOut(); 2382 }); 2383 }); 2384 } 2385} 2386 2387async function get_member_favorite_stations() { 2388 if (!(logged_in_member != null && logged_in_member.email != "")) { 2389 await update_favorite_stations_ui(); 2390 return false;
2391 } 2392} 2393 2394function get_member_favorite_stations_left_section() { 2395 2396 if (!(logged_in_member != null && logged_in_member.email != "")) { 2397 update_favorite_stations_ui(); 2398 return false; 2399 } 2400 2401 k_ajax("/functions/v6/member.functions.php", 2402 {"command": "get_favorite_stations"}, 2403 function (response) { 2404 logged_in_member.favorite_stations = response.data; 2405 update_favorite_stations_ui(); 2406 }, 2407 function (response) { 2408 update_favorite_stations_ui(); 2409 } 2410 ); 2411} 2412 2413function get_member_favorite_songs() { 2414 if ((logged_in_member != null && logged_in_member.email != "")) { 2415 k_ajax("/functions/v6/member.functions.php" 2416 , {"command": "get_favorite_songs"} 2417 , function (response) { 2418 logged_in_member.favorite_songs = response.data; 2419 if (typeof active_station.current_song !== 'undefined') { 2420 player_update_favorite_song(active_station.current_song); 2421 update_favorite_songs_ui(); 2422 } 2423 } 2424 , function (response) { 2425 if (typeof active_station.current_song !== 'undefined') { 2426 player_update_favorite_song(active_station.current_song); 2427 update_favorite_songs_ui(); 2428 } 2429 } 2430 ); 2431 } 2432} 2433 2434async function update_favorite_stations_ui() { 2435 try { 2436 // we dont need here anymore. We trigger favorites fetch and fill here get_member_favorites() 2437 // await fillLeftSideFavourite(); 2438 // fillFavoriteStations(); 2439 } catch (e) { 2440 } 2441} 2442 2443function update_favorite_playlists_ui() { 2444 2445 $(".favorite_playlist_list_container ul").html(""); 2446 2447 if (logged_in_member != null && typeof (logged_in_member.favorite_playlists) != "undefined") { 2448 2449 $(".favorite_playlists_container").removeClass("is_favorite"); 2450 $.each(logged_in_member.favorite_playlists, function (index, playlist) { 2451 $(".favorite_playlists_container").each(function (i, s_container) { 2452 if ($(s_container).data("playlist_id") == playlist.id) { 2453 $(s_container).addClass("is_favorite"); 2454 $("a", s_container).attr("onclick", "remove_from_favorite_playlists(this," + playlist.id + ")"); 2455 } 2456 }); 2457 $(".favorite_playlist_" + playlist.id).addClass("is_favorite"); 2458 $(".favorite_playlist_" + playlist.id + " a").attr("onClick", "remove_from_favorite_playlists(this," + playlist.id + ");"); 2459 if (playlist?.url_thumbnail_1_1?.trim() != "" && typeof (playlists["station_" + playlist.id]) !== "undefined") { 2460 var button_class = ""; 2461 if ($(".favorite_playlist_list_container").hasClass("editable")) 2462 button_class = "active"; 2463 $(".favorite_playlist_list_container ul").append( 2464 '<li class="list_item list_item_favorite" data-playlist_id="' + playlist.id + '">\ 2465 <figure class="thumb_container rounded_corner"><img src="' + playlist.url_thumbnail_1_1 + '"></figure>\ 2466 <a href="' + playlists["station_" + playlist.id]["url"] + '" class="link">' + playlists["station_" + playlist.id]["title"] + '</a>\ 2467 <a class="action action_favorite ' + button_class + '" href="javascript:;" onclick="remove_from_favorite_playlists(this,' + playlist.id + ');">' + svg_icon_close + '</a>\ 2468 <div class="title_container">\ 2469 <strong>' + playlists["station_" + playlist.id]["title"] + '</strong>\ 2470 </div>\ 2471 </li>'); 2472 } 2473 }); 2474 2475 } 2476} 2477 2478function get_member_favorite_playlists() { 2479 2480 if (!(logged_in_member != null && logged_in_member.email != "")) { 2481 update_favorite_playlists_ui(); 2482 return false; 2483 } 2484 2485 k_ajax("/functions/v6/member.functions.php", 2486 {"command": "get_favorite_playlists"}, 2487 function (response) { 2488 logged_in_member.favorite_playlists = response.data; 2489 update_favorite_playlists_ui(); 2490 }, 2491 function (response) { 2492 update_favorite_playlists_ui(); 2493 } 2494 ); 2495} 2496 2497function update_favorite_songs_ui() { 2498 $(".favorite_song_list_container ul").html(""); 2499 2500 if (logged_in_member != null && typeof (logged_in_member.favorite_songs) != "undefined") { 2501 2502 $(".favorite_songs_container").each(function (index, container) { 2503 $(container).removeClass("is_favorite"); 2504 $("a", container).attr("onClick", "add_to_favorite_songs(" + $(container).data("song_id") + "," + $(container).data("station_id") + ");"); 2505 }); 2506 $.each(logged_in_member.favorite_songs, function (index, song) { 2507 $(".favorite_song_" + song.id).addClass("is_favorite"); 2508 $(".favorite_song_" + song.id + " a").attr("onClick", "remove_from_favorite_songs(" + song.id + "," + song.station_id + ");"); 2509 var button_class = ""; 2510 if ($(".favorite_song_list_container").hasClass("editable")) 2511 button_class = "active"; 2512 if (song?.url_thumbnail_1_1?.trim() != "") { 2513 $(".favorite_song_list_container ul").append( 2514 '<li class="list_item list_item_favorite" data-song_id="' + song.id + '">\ 2515 <figure class="thumb_container rounded_corner"><img src="' + song.url_thumbnail_1_1 + '"></figure>\ 2516 <a href="' + song.url + '" class="link">' + song.song_title + '</a>\ 2517 <a class="action action_favorite ' + button_class + '" href="javascript:;" onclick="remove_from_favorite_songs(' + song.id + ',' + song.station_id + ');">' + svg_icon_close + '</a>\ 2518 <div class="title_container">\ 2519 <strong>' + song.song_title + '</strong>\ 2520 <span>' + song.artist_name + '</span>\ 2521 </div>\ 2522 </li>'); 2523 } 2524 /* 2525 if($(".favorite_song_list_container ul li").length == 0){ 2526 $(".current_song_list_container").slideDown(); 2527 }*/ 2528 }); 2529 /* 2530 $.each(current_song_list,function(index,song){ 2531 if(typeof song.song_db_id !== "undefined" && song.song_db_id.trim() != "" && song.song_db_id != "0" && $(".favorite_song_list_container li[data-song_id="+song.song_db_id+"]").length == 0){ 2532 2533 $(".current_song_list_container ul").append( 2534 '<li class="list_item" data-song_id="'+song.song_db_id+'">\ 2535 <figure class="thumb_container "><img src="'+song.album_cover_art+'"></figure>\ 2536 <a href="'+song.url+'" class="link">'+song.title+'</a>\ 2537 <a class="action action_favorite" href="javascript:;" onclick="add_to_favorite_songs('+song.song_db_id+');">'+svg_icon_close+'</a>\ 2538 <div class="item_overlay">\ 2539 <div class="item_overlay_content">\ 2540 <strong>'+song.title+'</strong>\ 2541 <span>'+song.artist+'</span>\ 2542 <a class="action action_go">'+svg_icon_go+'</a>\ 2543 </div>\ 2544 <div>\ 2545 </li>'); 2546 } 2547 }); 2548 if($(".current_song_list_container ul li").length > 0){ 2549 $(".current_song_list_container").slideDown(); 2550 } 2551 else{ 2552 $(".current_song_list_container").slideUp(); 2553 }*/ 2554 } 2555} 2556 2557function add_to_favorite_songs(to_add, station_id) { 2558 if (logged_in_member !== null) { 2559 if (typeof station_id == "undefined") 2560 station_id = -1; 2561 k_ajax("/functions/v6/member.functions.php", { 2562 "command": "save_favorite_song", 2563 "song_id": ("" + to_add), 2564 "station_id": ("" + station_id) 2565 }, function (response) { 2566 if (response.result == true) get_member_favorite_songs(); 2567 }); 2568 } 2569} 2570 2571function hasValidLoggedInMemberId() { 2572 return logged_in_member != null && logged_in_member.id !== undefined && logged_in_member.id !== null && logged_in_member.id !== ''; 2573} 2574 2575async function add_to_favorite_stations(to_select, station_id) { 2576 if (hasValidLoggedInMemberId()) { 2577 const favoriteObj = { 2578 memberId: logged_in_member.id, 2579 itemId: station_id, 2580 itemType: "STATION", 2581 interactionType: "LIKE", 2582 addedFrom: "website" 2583 } 2584 await userPreferencesService.addFavorite(favoriteObj); 2585 await fetchFavoriteStations(); 2586 // These lines will be removed when we don't need V1 2587 // const data = {"command": "save_favorite_station", "station_id": (station_id)}; 2588 // k_ajax("/functions/v6/member.functions.php",data); 2589 // These lines will be removed when we don't need V1 2590 } 2591} 2592 2593async function add_to_favorite_stations_mvp(to_select, station_id) { 2594 is_active_player_favorite = true; 2595 if (hasValidLoggedInMemberId()) { 2596 const favoriteObj = { 2597 memberId: logged_in_member.id, 2598 itemId: station_id, 2599 itemType: "STATION", 2600 interactionType: "LIKE", 2601 addedFrom: "website" 2602 } 2603 await userPreferencesService.addFavorite(favoriteObj); 2604 await fetchFavoriteStations(); 2605 const eventTitle = "AddFavorite"; 2606 const contentType = "Radio"; 2607 const contentDetail = { 2608 active_station_id: station_id, 2609 active_station: active_station.title 2610 } 2611 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2612 } else { 2613 is_active_player_favorite = false;
2614 alert('Favorilerine eklemek için Åimdi giriÅ yap!'); 2615 toggle_member(false); 2616 closeAd(); 2617 } 2618 2619 isActiveFavorite(); 2620} 2621 2622async function add_to_favorite_show_episode(episode_id) { 2623 if (hasValidLoggedInMemberId()) { 2624 const favoriteObj = { 2625 memberId: logged_in_member.id, 2626 itemId: episode_id, 2627 itemType: "SHOW_EPISODE", 2628 interactionType: "LIKE", 2629 addedFrom: "website" 2630 } 2631 await userPreferencesService.addFavorite(favoriteObj); 2632 await fetchFavoriteShowEpisodes(); 2633 const eventTitle = "AddFavorite"; 2634 const contentType = "Episode"; 2635 let active_episode_title = (player_current_podcast && player_current_podcast.id === episode_id) ? player_current_podcast.title : '' 2636 let show_id = (player_current_podcast && player_current_podcast.id === episode_id) ? player_current_podcast.show_id : 0; 2637 if (active_episode_title === '') { 2638 const foundPodcast = await podcastService.getShowEpisodeById(episode_id); 2639 if (foundPodcast && foundPodcast.data) { 2640 const podcastData = Podcast.from(foundPodcast.data); 2641 active_episode_title = podcastData.title; 2642 show_id = foundPodcast.show_id; 2643 } 2644 } 2645 const contentDetail = { 2646 episode_id, 2647 show_id, 2648 active_episode_title 2649 } 2650 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2651 2652 $(`.action_add_favorite_episode_${episode_id}`).css('display', 'none'); 2653 $(`.action_remove_favorite_episode_${episode_id}`).css('display', 'inline-block'); 2654 } else { 2655 alert('Favorilerine eklemek için Åimdi giriÅ yap!'); 2656 toggle_member(false); 2657 closeAd(); 2658 } 2659} 2660 2661 2662async function remove_from_favorite_show_episode(episode_id) { 2663 if (hasValidLoggedInMemberId()) { 2664 await userPreferencesService.removeFavorite(logged_in_member.id, 'SHOW_EPISODE', episode_id); 2665 await fetchFavoriteShowEpisodes(); 2666 const eventTitle = "RemoveFavorite"; 2667 const contentType = "Episode"; 2668 let active_episode_title = (player_current_podcast && player_current_podcast.id === episode_id) ? player_current_podcast.title : '' 2669 let show_id = (player_current_podcast && player_current_podcast.id === episode_id) ? player_current_podcast.show_id : 0; 2670 if (active_episode_title === '') { 2671 const foundPodcast = await podcastService.getShowEpisodeById(episode_id); 2672 if (foundPodcast && foundPodcast.data) { 2673 const podcastData = Podcast.from(foundPodcast.data); 2674 active_episode_title = podcastData.title; 2675 show_id = foundPodcast.show_id; 2676 } 2677 } 2678 const contentDetail = { 2679 episode_id, 2680 show_id, 2681 active_episode_title 2682 } 2683 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2684 2685 $(`.action_add_favorite_episode_${episode_id}`).css('display', 'inline-block'); 2686 $(`.action_remove_favorite_episode_${episode_id}`).css('display', 'none'); 2687 } 2688} 2689 2690function add_to_favorite_playlists(to_select, playlist_id) { 2691 if (logged_in_member !== null) { 2692 k_ajax("/functions/v6/member.functions.php" 2693 , {"command": "save_favorite_playlist", "station_id": (playlist_id)} 2694 , function (response) { 2695 if (response.result == true) { 2696 $(to_select).closest(".favorite_container").addClass("is_favorite"); 2697 $(to_select).attr("onClick", "remove_from_favorite_playlists(this," + playlist_id + ")"); 2698 get_member_favorite_playlists(); 2699 } 2700 } 2701 ); 2702 } 2703} 2704 2705function add_to_favorite_artists(to_select, artist_id) { 2706 if (logged_in_member !== null) { 2707 k_ajax("/functions/v6/member.functions.php" 2708 , {"command": "save_favorite_artist", "artist_id": (artist_id)} 2709 , function (response) { 2710 if (response.result == true) { 2711 $(to_select).closest(".favorite_container").addClass("is_favorite"); 2712 $(to_select).attr("onClick", "remove_from_favorite_artists(this," + artist_id + ")"); 2713 get_member_favorite_artists(); 2714 } 2715 } 2716 ); 2717 } 2718} 2719 2720function update_favorite_artists_ui() { 2721 2722 $(".favorite_artist_list_container ul").html(""); 2723 2724 if (logged_in_member != null && typeof (logged_in_member.favorite_artists) != "undefined") { 2725 2726 $(".favorite_artists_container").removeClass("is_favorite"); 2727 $.each(logged_in_member.favorite_artists, function (index, artist) { 2728 $(".favorite_artists_container").each(function (i, p_container) { 2729 if ($(p_container).data("artist_id") == artist.id) { 2730 $(p_container).addClass("is_favorite"); 2731 $("a", p_container).attr("onclick", "remove_from_favorite_artists(this," + artist.id + ")"); 2732 } 2733 }); 2734 $(".favorite_artist_" + artist.id).addClass("is_favorite"); 2735 $(".favorite_artist_" + artist.id + " a").attr("onClick", "remove_from_favorite_artists(this," + artist.id + ");"); 2736 if (artist?.url_thumbnail?.trim() != "") { 2737 var button_class = ""; 2738 if ($(".favorite_artist_list_container").hasClass("editable")) 2739 button_class = "active"; 2740 $(".favorite_artist_list_container ul").append( 2741 '<li class="list_item list_item_favorite" data-artist_id="' + artist.id + '">\ 2742 <figure class="thumb_container rounded_corner"><img src="' + artist.url_thumbnail + '"></figure>\ 2743 <a href="' + artist.url + '" class="link">' + artist.title + '</a>\ 2744 <a class="action action_favorite ' + button_class + '" href="javascript:;" onclick="remove_from_favorite_artists(this,' + artist.id + ');">' + svg_icon_close + '</a>\ 2745 <div class="title_container">\ 2746 <strong>' + artist.title + '</strong>\ 2747 </div>\ 2748 </li>'); 2749 } 2750 }); 2751 } 2752} 2753 2754function get_member_favorite_artists() { 2755 2756 if (!(logged_in_member != null && logged_in_member.email != "")) { 2757 update_favorite_artists_ui(); 2758 return false;
2759 } 2760 2761 k_ajax("/functions/v6/member.functions.php", 2762 {"command": "get_favorite_artists"}, 2763 function (response) { 2764 logged_in_member.favorite_artists = response.data; 2765 update_favorite_artists_ui(); 2766 }, 2767 function (response) { 2768 update_favorite_artists_ui(); 2769 } 2770 ); 2771} 2772 2773function remove_from_favorite_artists(to_select, artist_id) { 2774 k_ajax("/functions/v6/member.functions.php", 2775 {"command": "delete_favorite_artist", "artist_id": (artist_id)}, 2776 function (response) { 2777 if (response.result == true) { 2778 $(to_select).closest(".favorite_container").removeClass("is_favorite"); 2779 $(to_select).attr("onClick", "add_to_favorite_artists(this," + artist_id + ")"); 2780 get_member_favorites().then(r => { 2781 }); 2782 } 2783 } 2784 ); 2785} 2786 2787async function update_favorite_shows_ui() { 2788 try { 2789 // we dont need here anymore. We trigger favorites fetch and fill here get_member_favorites() 2790 // await fillLeftSideFavourite(); 2791 // fillFavoriteShows(); 2792 } catch (e) { 2793 } 2794 /*$(".favorite_show_list_container ul").html(""); 2795 2796 if (logged_in_member != null && typeof (logged_in_member.favorite_shows) != "undefined") { 2797 2798 $(".favorite_shows_container").removeClass("is_favorite"); 2799 $.each(logged_in_member.favorite_shows, async function (index, show) { 2800 if (show.id && !$(`[data-show_id=${show.id}]`, ".favorite_show_list_container ul").length) { 2801 $(".favorite_shows_container").each(function (i, p_container) { 2802 if ($(p_container).data("show_id") == show.id) { 2803 $(p_container).addClass("is_favorite"); 2804 $("a", p_container).attr("onclick", "remove_from_favorite_shows(this," + show.id + ")"); 2805 } 2806 }); 2807 2808 const selectedPodcast = await podcastService.getPodcastById(show.id); 2809 const favShow = selectedPodcast.data; 2810 if (favShow) { 2811 var button_class = ""; 2812 if ($(".favorite_show_list_container").hasClass("editable")) 2813 button_class = "active"; 2814 2815 $(".favorite_show_list_container ul").append( 2816 `<li class="list_item list_item_favorite" data-show_id="${show.id}"> 2817 <figure class="thumb_container rounded_corner"> 2818 <img src="${favShow.thumbnailImageUrl}" alt="${favShow.title}"> 2819 </figure> 2820 <a href="/programlar/${favShow.sanitizedUrl}" class="link">${favShow.title}</a> 2821 <a class="action action_favorite ${button_class}" href="javascript:;" onclick="remove_from_favorite_shows(this,${show.id});">${svg_icon_close}</a> 2822 <div class="title_container"> 2823 <strong>${favShow.title}</strong> 2824 </div> 2825 </li>`); 2826 $(".favorite_show_" + show.id).addClass("is_favorite"); 2827 $(".favorite_show_" + show.id + " a").attr("onClick", "remove_from_favorite_shows(this," + show.id + ");"); 2828 } 2829 } 2830 }); 2831 }*/ 2832} 2833 2834function add_to_favorite_videos(to_select, video_id, channel_id) { 2835 if (logged_in_member !== null) { 2836 k_ajax("/functions/v6/member.functions.php" 2837 , {"command": "save_favorite_video", "video_id": (video_id), "channel_id": (channel_id)} 2838 , function (response) { 2839 if (response.result == true) { 2840 $(to_select).closest(".favorite_container").addClass("is_favorite"); 2841 $(to_select).attr("onClick", "remove_from_favorite_videos(this," + video_id + "," + channel_id + ")"); 2842 get_member_favorite_videos(); 2843 } 2844 } 2845 ); 2846 } 2847} 2848 2849function update_favorite_videos_ui() { 2850 2851 $(".favorite_video_list_container ul").html(""); 2852 2853 if (logged_in_member != null && typeof (logged_in_member.favorite_videos) != "undefined") { 2854 2855 $(".favorite_videos_container").removeClass("is_favorite"); 2856 $.each(logged_in_member.favorite_videos, function (index, video) { 2857 $(".favorite_videos_container").each(function (i, p_container) { 2858 if ($(p_container).data("video_id") == video.video_id) { 2859 $(p_container).addClass("is_favorite"); 2860 $("a", p_container).attr("onclick", "remove_from_favorite_videos(this," + video.video_id + "," + video.channel_id + ")"); 2861 } 2862 }); 2863 $(".favorite_video_" + video.video_id).addClass("is_favorite"); 2864 $(".favorite_video_" + video.video_id + " a").attr("onClick", "remove_from_favorite_videos(this," + video.video_id + "," + video.channel_id + ");"); 2865 if (video?.url_thumbnail?.trim() != "") { 2866 var button_class = ""; 2867 if ($(".favorite_video_list_container").hasClass("editable")) 2868 button_class = "active"; 2869 $(".favorite_video_list_container ul").append( 2870 '<li class="list_item list_item_favorite" data-video_id="' + video.video_id + '">\ 2871 <figure class="thumb_container rounded_corner"><img src="' + video.url_thumbnail + '"></figure>\ 2872 <a href="' + video.url + '" class="link">' + video.title + '</a>\ 2873 <a class="action action_favorite ' + button_class + '" href="javascript:;" onclick="remove_from_favorite_videos(this,' + video.video_id + ',' + video.channel_id + ');">' + svg_icon_close + '</a>\ 2874 <div class="title_container">\ 2875 <strong>' + video.title + '</strong>\ 2876 </div>\ 2877 </li>'); 2878 } 2879 }); 2880 } 2881} 2882 2883function get_member_favorite_videos() { 2884 2885 if (!(logged_in_member != null && logged_in_member.email != "")) { 2886 update_favorite_videos_ui(); 2887 return false;
2888 } 2889 2890 k_ajax("/functions/v6/member.functions.php", 2891 {"command": "get_favorite_videos"}, 2892 function (response) { 2893 logged_in_member.favorite_videos = response.data; 2894 update_favorite_videos_ui(); 2895 }, 2896 function (response) { 2897 update_favorite_videos_ui(); 2898 } 2899 ); 2900} 2901 2902function remove_from_favorite_videos(to_select, video_id, channel_id) { 2903 k_ajax("/functions/v6/member.functions.php", 2904 {"command": "delete_favorite_video", "video_id": (video_id), "channel_id": (channel_id)}, 2905 function (response) { 2906 if (response.result == true) { 2907 $(to_select).closest(".favorite_container").removeClass("is_favorite"); 2908 $(to_select).attr("onClick", "add_to_favorite_videos(this," + video_id + "," + channel_id + ")"); 2909 get_member_favorites().then(r => { 2910 }); 2911 } 2912 } 2913 ); 2914} 2915 2916async function get_member_favorite_shows() { 2917 if (!(logged_in_member != null && logged_in_member.email !== "")) { 2918 await update_favorite_shows_ui(); 2919 return false; 2920 } 2921} 2922 2923async function add_to_favorite_shows(to_select, show_id) { 2924 if (hasValidLoggedInMemberId()) { 2925 const favoriteObj = { 2926 memberId: logged_in_member.id, 2927 itemId: show_id, 2928 itemType: "SHOW", 2929 interactionType: "LIKE", 2930 addedFrom: "website" 2931 } 2932 await userPreferencesService.addFavorite(favoriteObj); 2933 await fetchFavoriteShows(); 2934 const eventTitle = "AddFavorite"; 2935 const contentType = "Podcast"; 2936 const contentDetail = { 2937 show_id: show_id, 2938 sanitized_url: active_show.sanitizedUrl, 2939 episode_id: player_current_podcast.id 2940 } 2941 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2942 } 2943} 2944 2945async function remove_from_favorite_shows(to_select, show_id) { 2946 if (hasValidLoggedInMemberId()) { 2947 await userPreferencesService.removeFavorite(logged_in_member.id, 'SHOW', show_id); 2948 await fetchFavoriteShows(); 2949 const eventTitle = "RemoveFavorite"; 2950 const contentType = "Podcast"; 2951 let showUrl = (active_show && active_show.id === show_id) ? active_show.sanitizedUrl : '' 2952 if (showUrl === '') { 2953 const foundShow = await podcastService.getPodcastById(show_id); 2954 if (foundShow && foundShow.data) { 2955 const showData = Show.from(foundShow.data); 2956 showUrl = showData.sanitizedUrl; 2957 } 2958 } 2959 const contentDetail = { 2960 show_id: show_id, 2961 sanitized_url: showUrl 2962 } 2963 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2964 } 2965} 2966 2967async function add_to_favorite_shows_mvp(to_select, show_id) { 2968 is_active_player_favorite = true; 2969 if (hasValidLoggedInMemberId()) { 2970 const favoriteObj = { 2971 memberId: logged_in_member.id, 2972 itemId: show_id, 2973 itemType: "SHOW", 2974 interactionType: "LIKE", 2975 addedFrom: "website" 2976 } 2977 await userPreferencesService.addFavorite(favoriteObj); 2978 await fetchFavoriteShows(); 2979 const eventTitle = "AddFavorite"; 2980 const contentType = "Podcast"; 2981 const contentDetail = { 2982 show_id: show_id, 2983 sanitized_url: active_show.sanitizedUrl, 2984 episode_id: player_current_podcast.id 2985 } 2986 pushEventToDataLayer(eventTitle, contentType, contentDetail); 2987 } else { 2988 is_active_player_favorite = false; 2989 alert('Favorilerine eklemek için Åimdi giriÅ yap!'); 2990 toggle_member(false); 2991 closeAd(); 2992 } 2993 isActiveFavorite(); 2994} 2995 2996async function remove_from_favorite_shows_mvp(to_select, show_id) { 2997 if (hasValidLoggedInMemberId()) { 2998 is_active_player_favorite = false; 2999 await userPreferencesService.removeFavorite(logged_in_member.id, 'SHOW', show_id); 3000 await fetchFavoriteShows(); 3001 isActiveFavorite(); 3002 const eventTitle = "RemoveFavorite"; 3003 const contentType = "Podcast"; 3004 let showUrl = (active_show && active_show.id === show_id) ? active_show.sanitizedUrl : '' 3005 if (showUrl === '') { 3006 const foundShow = await podcastService.getPodcastById(show_id); 3007 if (foundShow && foundShow.data) { 3008 const showData = Show.from(foundShow.data); 3009 showUrl = showData.sanitizedUrl; 3010 } 3011 } 3012 const contentDetail = { 3013 show_id: show_id, 3014 sanitized_url: showUrl 3015 } 3016 pushEventToDataLayer(eventTitle, contentType, contentDetail); 3017 } else { 3018 is_active_player_favorite = true; 3019 alert('Favorilerine eklemek için Åimdi giriÅ yap!'); 3020 } 3021} 3022 3023async function remove_from_favorite_stations(to_select, station_id) { 3024 if (hasValidLoggedInMemberId()) { 3025 await userPreferencesService.removeFavorite(logged_in_member.id, 'STATION', station_id); 3026 await fetchFavoriteStations(); 3027 const eventTitle = "RemoveFavorite"; 3028 const contentType = "Radio"; 3029 let activeStationTitle = (active_station && active_station.id === station_id) ? active_station.title : '' 3030 if (activeStationTitle === '') { 3031 const foundRadio = await stationService.getStationById(station_id); 3032 if (foundRadio && foundRadio.data) { 3033 const radioData = Station.from(foundRadio.data); 3034 activeStationTitle = radioData.title; 3035 } 3036 } 3037 const contentDetail = { 3038 active_station_id: station_id, 3039 active_station: activeStationTitle 3040 } 3041 pushEventToDataLayer(eventTitle, contentType, contentDetail); 3042 } 3043} 3044 3045async function remove_from_favorite_stations_mvp(to_select, station_id) { 3046 if (hasValidLoggedInMemberId()) { 3047 is_active_player_favorite = false;
3048 await userPreferencesService.removeFavorite(logged_in_member.id, 'STATION', station_id); 3049 await fetchFavoriteStations(); 3050 const eventTitle = "RemoveFavorite"; 3051 const contentType = "Radio"; 3052 let activeStationTitle = (active_station && active_station.id === station_id) ? active_station.title : '' 3053 if (activeStationTitle === '') { 3054 const foundRadio = await stationService.getStationById(station_id); 3055 if (foundRadio && foundRadio.data) { 3056 const radioData = Station.from(foundRadio.data); 3057 activeStationTitle = radioData.title; 3058 } 3059 } 3060 const contentDetail = { 3061 active_station_id: station_id, 3062 active_station: activeStationTitle 3063 } 3064 pushEventToDataLayer(eventTitle, contentType, contentDetail); 3065 } else { 3066 is_active_player_favorite = true; 3067 } 3068 isActiveFavorite(); 3069} 3070 3071function remove_from_favorite_playlists(to_select, playlist_id) { 3072 k_ajax("/functions/v6/member.functions.php", 3073 {"command": "delete_favorite_playlist", "station_id": (playlist_id)}, 3074 function (response) { 3075 if (response.result == true) { 3076 $(to_select).closest(".favorite_container").removeClass("is_favorite"); 3077 $(to_select).attr("onClick", "add_to_favorite_playlists(this," + playlist_id + ")"); 3078 get_member_favorites().then(r => { 3079 }); 3080 } 3081 } 3082 ); 3083} 3084 3085function remove_from_favorite_songs(to_remove) { 3086 k_ajax("/functions/v6/member.functions.php", { 3087 "command": "delete_favorite_song", 3088 "song_id": ("" + to_remove) 3089 }, function (response) { 3090 if (response.result == true) get_member_favorites().then(r => { 3091 }); 3092 }); 3093} 3094 3095async function get_member_favorites() { 3096 /*get_member_favorite_songs(); 3097 get_member_favorite_playlists(); 3098 get_member_favorite_artists(); 3099 get_member_favorite_videos();*/ 3100 // get_member_favorite_stations(); 3101 // get_member_favorite_shows(); 3102 3103 // fillLeftSideFavourite lives in pages/shared.js which loads asynchronously. 3104 // On staging the member AJAX response can arrive before that script finishes loading. 3105 // Defer the entire call to page:loaded when the function isn't ready yet. 3106 if (typeof fillLeftSideFavourite !== 'function') { 3107 $(document).one('page:loaded', function () { 3108 get_member_favorites().then(r => {}); 3109 }); 3110 return; 3111 } 3112 3113 // Separated as fetchFavoriteShows and fetchFavoriteStations functions 3114 await fillLeftSideFavourite(); 3115 isMobile() ? 3116 await homepageLeftSectionFavoritesRendererMobile() : 3117 await homepageLeftSectionFavoritesRenderer(); 3118} 3119 3120function toggle_favorite_genre(to_select, genre_id) { 3121 if (!$(to_select).hasClass("disabled")) { 3122 $(to_select).toggleClass("favorite"); 3123 } 3124} 3125 3126function edit_genre_container(to_select) { 3127 var fav_container = $(to_select).closest(".favorite_list_container"); 3128 if ($(fav_container).hasClass("editable")) { 3129 $(fav_container).removeClass("editable"); 3130 $("ul li .action_favorite", fav_container).removeClass("active"); 3131 $("ul li", $(fav_container)).addClass("disabled"); 3132 $(to_select).html("DÃZENLE"); 3133 var to_save = ""; 3134 $(".favorite_genre_list_container ul li.favorite").each(function (i, genre_container) { 3135 to_save = to_save == "" ? $(genre_container).data("genre_id") : to_save + "," + $(genre_container).data("genre_id"); 3136 }); 3137 to_save = '[' + to_save + ']'; 3138 k_ajax("/functions/v6/member.functions.php", { 3139 "command": "answer_survey", 3140 "question_id": 2, 3141 "answers": to_save 3142 }, function (response) { 3143 player_targeting_parameters.dist = window.location.href; 3144 }); 3145 } else { 3146 $(fav_container).addClass("editable"); 3147 $("ul li .action_favorite", fav_container).addClass("active"); 3148 $("ul li", $(fav_container)).removeClass("disabled"); 3149 $(to_select).html("TAMAM"); 3150 } 3151 3152} 3153 3154/*PLAYER*/ 3155function player_update_progress() {
3156 if (player_progress_timer != null) 3157 clearTimeout(player_progress_timer); 3158 3159 if (active_player == "RADIO") { 3160 if (player_current_track != null && typeof player_current_track !== "undefined" && typeof player_current_track.timestamp !== "undefined") { 3161 if (player_status == "PAUSED") { 3162 player_pause_time++; 3163 } else { 3164 var current_time = (new Date()).getTime() / 1000 + player_time_difference; 3165 var time_elapsed = (current_time - player_current_track.timestamp) - player_pause_time; 3166 var progress = (time_elapsed * 100 / player_current_track.duration_sec); 3167 3168 var song_duration = player_current_track.duration_sec; 3169 if (progress > 100) 3170 progress = 100; 3171 if (progress < 0) 3172 progress = 0; 3173 3174 var time_remaining = Math.floor(song_duration - time_elapsed); 3175 if (time_remaining < 0) 3176 time_remaining = 0; 3177 3178 var remaining_minutes = Math.floor(time_remaining / 60); 3179 var remaining_seconds = time_remaining % 60; 3180 $(".ldr_container .timer_container").html( 3181 ("00" + remaining_minutes).slice(-2) + ":" + ("00" + remaining_seconds).slice(-2) 3182 ); 3183 3184 $(".player_container .progress_container").slider('value', progress); 3185 $(".list_item_station.active .song_progress_container .progress_bar").css("width", progress + "%"); 3186 } 3187 } else { 3188 debug("Undefined track"); 3189 } 3190 } else { 3191 debug("Not radio, skipping update"); 3192 } 3193 player_progress_timer = setTimeout(function () { 3194 player_update_progress(); 3195 }, 1000); 3196} 3197 3198function player_switch(to_set) { 3199 active_player = to_set; 3200 3201 player_has_recieved_cuepoint = false; 3202 3203 const radioLyricsButton = document.getElementById("radioLyricsButton"); 3204 const podcastEpisodesButton = document.getElementById("podcastEpisodesButton"); 3205 3206 if (active_player === "RADIO") { 3207 radioLyricsButton.style.display = "block" 3208 podcastEpisodesButton.style.display = "none" 3209 } else if (active_player === "PODCAST") { 3210 radioLyricsButton.style.display = "none" 3211 podcastEpisodesButton.style.display = "block" 3212 } 3213 3214 if (podcast_player != null) { 3215 try { 3216 podcast_player.stop(); 3217 } catch (e) { 3218 debug(e, "error"); 3219 } 3220 3221 podcast_player.destruct(); 3222 podcast_player = null; 3223 } 3224 if (player != null && player_status != "STOPPED") { 3225 player.stop(); 3226 } 3227 3228 player_status = "STOPPED"; 3229 $(".player_container").attr("data-status", player_status).data("status", player_status); 3230 3231 if (active_player == "RADIO") { 3232 $('#podcast_timers').remove(); 3233 $(".player_container .progress_container").slider("disable"); 3234 } else { 3235 $(".player_container .progress_container").slider("enable"); 3236 } 3237} 3238 3239function initialize_player() { 3240 $(".player_container .volume_slider").slider({ 3241 range: "min", 3242 value: 60, 3243 min: 0, 3244 max: 100, 3245 slide: function (event, ui) { 3246 if (active_player == "PODCAST") { 3247 podcast_player.setVolume(ui.value); 3248 3249 } else { 3250 player.setVolume(ui.value / 100); 3251 } 3252 3253 player_volume = ui.value / 100; 3254 3255 if (ui.value < 2) { 3256 $(".player_container .volume_container").addClass("muted"); 3257 listening_start_time = 0; 3258 $(".player_container .volume_slider").slider("value", 0); 3259 } else { 3260 $(".player_container .volume_container").removeClass("muted"); 3261 } 3262 }, 3263 start: function (event, ui) { 3264 }, 3265 stop: function (event, ui) { 3266 }, 3267 change: function (event, ui) { 3268 if (active_player == "PODCAST") { 3269 podcast_player.setVolume(ui.value); 3270 3271 } else { 3272 player.setVolume(ui.value / 100); 3273 } 3274 3275 player_volume = ui.value / 100; 3276 3277 if (ui.value < 2) { 3278 listening_start_time = 0; 3279 $(".player_container .volume_container").addClass("muted"); 3280 if (ui.value > 0) 3281 $(".player_container .volume_slider").slider("value", 0); 3282 } else { 3283 $(".player_container .volume_container").removeClass("muted"); 3284 } 3285 } 3286 }); 3287 3288 $(".player_container .progress_container").slider({ 3289 range: "min", 3290 value: 0, 3291 min: 0, 3292 max: 100, 3293 disabled: true, //disabled on RADIO 3294 slide: function (event, ui) { 3295 }, 3296 start: function (event, ui) { 3297 player_progress_is_dragging = true; 3298 }, 3299 stop: function (event, ui) { 3300 if (active_player == "PODCAST") { 3301 var cursor_position = Math.floor(ui.value * player_current_podcast.duration_seconds / 100); 3302 omnyStudioTracker.createEvent("Stop"); 3303 podcast_player.setPosition(cursor_position * 1000); 3304 omnyStudioTracker.createEvent("Start"); 3305 } 3306 3307 player_progress_is_dragging = false;
3308 } 3309 }); 3310 3311 player_update_progress(); 3312 3313 $(window).scroll(function () { 3314 if ($(window).scrollTop() > 10) 3315 $("body").addClass("scrolling"); 3316 else 3317 $("body").removeClass("scrolling"); 3318 3319 3320 load_images(); 3321 }); 3322 3323 $(".player_container .scroll_container").scroll(function () { 3324 load_images(); 3325 }); 3326 3327 initialize_player_sdk(); 3328} 3329 3330function initialize_player_sdk() { 3331 debug('Player Ready', "info"); 3332 3333 //Player SDK is ready to be used, this is where you can instantiate a new TDSdk instance. 3334 //Player configuration: list of modules 3335 try { 3336 var player_config = { 3337 coreModules: [ 3338 { 3339 id: 'MediaPlayer', 3340 playerId: 'player', 3341 platformId: 'prodsecured01', 3342 plugins: [{id: "vastAd"}], 3343 timeShift: {active: 1, max_listening_time: 15}, 3344 techPriority: ['Html5', 'Flash'], 3345 sbm: {active: 1}, 3346 playerServicesRegion: 'eu' 3347 }, 3348 { 3349 id: 'SyncBanners', 3350 keepElementsVisible: false, 3351 elements: [{id: 'player_companion_banner', width: 300, height: 250}] 3352 }], 3353 playerReady: player_event_on_ready, 3354 configurationError: player_event_on_config_error, 3355 moduleError: player_event_on_module_error, 3356 adBlockerDetected: player_event_on_adblock_detected 3357 }; 3358 3359 //Player instance 3360 player = new TDSdk(player_config); 3361 } catch (e) { 3362 debug(e); 3363 } 3364} 3365 3366/* Callback function called to notify that the SDK is ready to be used */ 3367 3368function player_event_on_ready() { 3369 debug("PLAYER READY", "info"); 3370 player.addEventListener('track-cue-point', player_event_on_track_cuepoint); 3371 player.addEventListener('custom-cue-point', player_event_on_custom_cuepoint); 3372 player.addEventListener('ad-break-cue-point', player_event_on_ad_cuepoint); 3373 player.addEventListener('time-shift-playhead-update', player_event_on_playhead_update); 3374 player.addEventListener('ad-playback-start', player_event_on_ad_playback_start); 3375 player.addEventListener('ad-playback-complete', player_event_on_ad_playback_complete); 3376 player.addEventListener('ad-playback-destroy', player_event_on_ad_playback_destroy); 3377 player.addEventListener('ad-countdown', player_event_on_ad_countdown); 3378 player.addEventListener('ad-quartile', player_event_on_ad_quartile); 3379 player.addEventListener('ad-playback-error', player_event_on_ad_playback_error); 3380 player.addEventListener('stream-status', player_event_on_status_change); 3381 player.addEventListener('stream-fail', player_event_on_stream_fail); 3382 player.addEventListener('stream-error', player_event_on_stream_error); 3383 player.addEventListener('stream-select', player_event_on_stream_select); 3384 player.addEventListener('stream-stop', player_event_on_stream_stop); 3385 player.addEventListener('stream-start', player_event_on_stream_start); 3386 player.addEventListener('time-shift-playback-mode-change', player_event_on_playback_mode_change); 3387 player.addEventListener('media-playback-status', player_event_on_playback_status); 3388 player.addEventListener('timeout-alert', player_event_on_timeout_alert); 3389 player.addEventListener('timeout-reach', player_event_on_timeout_reach); 3390 3391 3392 player_update_targeting_parameters(); 3393 debug("Creating Podcast Player", "info"); 3394 3395 window.soundManager = new SoundManager(); 3396 soundManager.setup({ 3397 url: '/assets/v6/libraries/soundmanager/swf/', 3398 onready: function () { 3399 podcast_player_ready = true; 3400 debug("Podcast Player Ready", "info"); 3401 if (typeof autoplay_enabled !== 'undefined' && autoplay_enabled === 'true') { 3402 setTimeout(function () { 3403 player_play(); 3404 }, 5000); 3405 } 3406 }, 3407 debugMode: true, 3408 forceUseGlobalHTML5Audio: true 3409 }); 3410 3411 player_ready = true; 3412 player_animate_track_titles(); 3413 player_update_songs(); 3414} 3415 3416function player_update_targeting_parameters() { 3417 player_targeting_parameters.dist = window.location.href; 3418} 3419 3420function player_event_on_playhead_update(e) { 3421} 3422 3423function player_event_on_playback_mode_change(e) { 3424 debug("player_event_on_playback_mode_change", "info"); 3425} 3426 3427function player_event_on_playback_status(e) { 3428 debug("player_event_on_playback_mode_change", "info"); 3429} 3430 3431function player_event_on_status_change(e) { 3432 $('#playButton').css('display', 'none'); 3433 $('#stopButton').css('display', 'none'); 3434 $('#mvp_loader').css('display', 'flex '); 3435 3436 player_status = "LOADING"; 3437 updateMiniPlayerPlayingButtons(); 3438 3439 debug("STATUS CHANGE") 3440 debug(e); 3441 3442 player_status = "PLAYING"; 3443 3444 if (e.data.code == "LIVE_PAUSE") { 3445 player_status = "PAUSED"; 3446 } else if ( 3447 e.data.code == "LIVE_STOP" 3448 || e.data.code == "LIVE_FAILED" 3449 || e.data.code == "STREAM_GEO_BLOCKED" 3450 || e.data.code == "STATION_NOT_FOUND") { 3451 player_status = "STOPPED"; 3452 $('#playButton').css('display', 'flex '); 3453 $('#stopButton').css('display', 'none '); 3454 $('#mvp_loader').css('display', 'none '); 3455 $('#playerLoader').css('display', 'none '); 3456 } 3457 3458 player_update_ui(); 3459 setTimeout(() => { 3460 updateMiniPlayerPlayingButtons(); 3461 }, 300) 3462 3463 3464 console.timeLog("Player Until Play", 'player_event_on_status_change', e.data.status, e.data.code); 3465 /* 3466 LIVE_PAUSE 3467 LIVE_STOP 3468 LIVE_FAILED 3469 STREAM_GEO_BLOCKED 3470 STATION_NOT_FOUND 3471 */ 3472} 3473 3474var preroll_duration_sec = 0; 3475 3476function player_event_on_ad_playback_start() { 3477 debug("Preroll Start", "info"); 3478 $(".preroll_container").addClass("active"); 3479 3480 pause_article_videos(); 3481 3482 if (player_active_preroll != null) { 3483 var duration_sec = parseInt(player_active_preroll.duration_in_sec) > 0 ? parseInt(player_active_preroll.duration_in_sec) : parseInt(player_active_preroll.duration); 3484 preroll_duration_sec = duration_sec;
3485 $(".preroll_background").off("click").css({"display": "none", "background-image": "none"}); 3486 3487 if (player_active_preroll.background_url) { 3488 $(".preroll_background").css({ 3489 "display": "block", 3490 "background-image": "url(" + player_active_preroll.background_url + ")" 3491 }); 3492 if (player_active_preroll.click_url != "") { 3493 $(".preroll_background").on("click", function () { 3494 window.open(player_active_preroll.click_url) 3495 }); 3496 } 3497 } 3498 3499 $(".preroll_container .preroll_countdown").html(duration_sec); 3500 3501 if (typeof player_active_preroll.impression_callback_url !== "undefined" && player_active_preroll.impression_callback_url != "") { 3502 $.ajax({ 3503 url: player_active_preroll.impression_callback_url 3504 , dataType: "jsonp" 3505 , success: function (response) { 3506 } 3507 , error: function () { 3508 } 3509 }); 3510 } 3511 3512 track_event("Karnaval v6 Player", "Preroll Start " + player_active_preroll.title, "Active Station:" + active_station.mount); 3513 } 3514} 3515 3516function player_event_on_ad_playback_destroy() { 3517 debug("Preroll Destroy", "info"); 3518 $(".preroll_container").removeClass("active"); 3519 player_play_active_station(true); 3520} 3521 3522function player_event_on_ad_playback_complete() { 3523 is_25 = false; 3524 is_50 = false; 3525 is_75 = false; 3526 debug("Preroll Complete", "info"); 3527 $(".preroll_container").removeClass("active"); 3528 track_event("Karnaval v6 Player", "Preroll Complete " + player_active_preroll.title, "Active Station:" + active_station.mount); 3529 player_play_active_station(true); 3530} 3531 3532function player_event_on_ad_playback_error(e) { 3533 $('#playButton').css('display', 'none'); 3534 $('#stopButton').css('display', 'flex '); 3535 $('#mvp_loader').css('display', 'none '); 3536 debug("Preroll Error", "error"); 3537 debug(e, "error"); 3538 $(".preroll_container").removeClass("active"); 3539 track_event("Karnaval v6 Player", "Preroll Error", "Active Station:" + active_station.mount + " - Reason:" + e.message); 3540 player_play_active_station(true); 3541} 3542 3543var preroll_remaining = 0; 3544var is_25 = false; 3545var is_50 = false; 3546var is_75 = false; 3547 3548function player_event_on_ad_countdown(event) { 3549 debug("Preroll Countdown:" + event.data.countDown, "info"); 3550 if (preroll_duration_sec > 0) { 3551 var elapsed_time_percent = 100 - Math.floor(100 * (event.data.countDown / preroll_duration_sec)); 3552 if (is_25 == false && is_50 == false && is_75 == false && elapsed_time_percent >= 25 && elapsed_time_percent < 50) { 3553 is_25 = true; 3554 track_event("Karnaval v6 Player", "Preroll First Quartile " + player_active_preroll.title, "Active Station:" + active_station.mount); 3555 } else if (is_25 == true && is_50 == false && is_75 == false && elapsed_time_percent >= 50 && elapsed_time_percent < 75) { 3556 is_25 = false; 3557 is_50 = true; 3558 track_event("Karnaval v6 Player", "Preroll Second Quartile " + player_active_preroll.title, "Active Station:" + active_station.mount); 3559 } else if (is_25 == false && is_50 == true && is_75 == false && elapsed_time_percent >= 75 && elapsed_time_percent < 100) { 3560 is_50 = false; 3561 is_75 = true; 3562 track_event("Karnaval v6 Player", "Preroll Third Quartile " + player_active_preroll.title, "Active Station:" + active_station.mount); 3563 } else { 3564 } 3565 } 3566 if (typeof (player_active_preroll) !== "undefined" && player_active_preroll != null) { 3567 /*Skip seconds fix*/ 3568 var duration_sec = parseInt(player_active_preroll.duration_in_sec) > 0 ? parseInt(player_active_preroll.duration_in_sec) : parseInt(player_active_preroll.duration); 3569 $(".preroll_container .preroll_countdown").html(event.data.countDown); 3570 } 3571 $(".preroll_controls .preroll_countdown").html(event.data.countDown); 3572} 3573 3574function player_event_on_ad_quartile(event) { 3575 debug("Preroll Quartile", "info"); 3576 debug(event); 3577 3578 track_event("Karnaval v6 Player", "Preroll Quartile " + player_active_preroll.title, "Active Station:" + active_station.mount); 3579} 3580 3581function player_event_on_config_error(object) { 3582 debug("player_event_on_config_error", "error"); 3583 debug(object.data.errors, "error"); 3584} 3585 3586function player_event_on_module_error(object) { 3587 debug("player_event_on_module_error", "error"); 3588 debug(object.data.errors, "error"); 3589 //Error code : object.data.errors[0].code 3590 //Error message : object.data.errors[0].message 3591} 3592 3593function player_event_on_track_cuepoint(e) { 3594 debug('Cuepoint Recieved', "info"); 3595 debug(e, "info"); 3596 3597 if (typeof e.data !== "undefined" && typeof e.data.cuePoint !== "undefined" && typeof e.data.parameters !== "undefined" || typeof e.data.cuePoint.parameters !== "undefined") { 3598 var cuepoint = e.data.parameters || e.data.cuePoint.parameters; 3599 debug(cuepoint); 3600 if (typeof cuepoint.song_db_id === "undefined") { 3601 debug("undefined cuepoint!"); 3602 3603 if (typeof cuepoint.track_album_publisher !== "undefined" && cuepoint.track_album_publisher != "") { //sidechannel
3604 k_ajax("/functions/v6/api.functions.php", 3605 { 3606 "command": "get_song_info", 3607 "station_id": active_station.id, 3608 "song_id": cuepoint.track_album_publisher 3609 }, 3610 function (response) { 3611 if (response.result == true) { 3612 var current_song = response.data; 3613 current_song.duration_sec = cuepoint.cue_time_duration / 1000; 3614 current_song.timestamp = parseFloat(player_has_recieved_cuepoint ? ((new Date()).getTime()) : cuepoint.cue_time_start) / 1000; 3615 3616 player_has_recieved_cuepoint = true; 3617 track_event("Karnaval v6 Player", "Cuepoint", "Active Station:" + active_station.mount + " Cuepoint Song:" + current_song.song_db_id); 3618 $('#playButton').css('display', 'none'); 3619 $('#stopButton').css('display', 'flex'); 3620 $('#mvp_loader').css('display', 'none'); 3621 player_set_current_track(current_song); 3622 console.timeEnd("Player Until Play"); 3623 } 3624 }, 3625 function (messages) { 3626 } 3627 ); 3628 } else if ((active_station.id == 1 || active_station.id == 2 || active_station.id == 15 || active_station.id == 4) && typeof cuepoint.track_id !== "undefined" && cuepoint.track_id != "") { //Injection! 3629 k_ajax("/functions/v6/api.functions.php", 3630 { 3631 "command": "get_song_info", 3632 "station_id": active_station.id, 3633 "song_id": cuepoint.track_id 3634 }, 3635 function (response) { 3636 if (response.result == true) { 3637 var current_song = response.data; 3638 current_song.duration_sec = cuepoint.cue_time_duration / 1000; 3639 current_song.timestamp = ((new Date()).getTime()) / 1000; 3640 3641 player_has_recieved_cuepoint = true; 3642 track_event("Karnaval v6 Player", "Cuepoint", "Active Station:" + active_station.mount + " Cuepoint Song:" + current_song.song_db_id); 3643 $('#playButton').css('display', 'none'); 3644 $('#stopButton').css('display', 'flex'); 3645 $('#mvp_loader').css('display', 'none'); 3646 player_set_current_track(current_song); 3647 console.timeEnd("Player Until Play"); 3648 } 3649 }, 3650 function (messages) { 3651 } 3652 ); 3653 } else { //Filler or unknown 3654 var current_song = { 3655 song_db_id: "", 3656 sanitized_url: "", 3657 title: active_station.title, 3658 artist: active_station.slogan, 3659 biography_image_16_9: active_station.url_default_artist_image, 3660 lyrics_html: "", 3661 publisher_id: "", 3662 artist_id: "", 3663 artist_is_foreign_artist: active_station.is_foreign, 3664 artist_sanitized_url: "", 3665 url_share: "", 3666 feat_artist_id: "", 3667 feat_artist_name: "", 3668 feat_artist_sanitized_url: "", 3669 artist_3_id: "", 3670 artist_3: "", 3671 artist_3_sanitized_url: "", 3672 artist_4_id: "", 3673 artist_4: "", 3674 artist_4_sanitized_url: "", 3675 artist_5_id: "", 3676 artist_5: "", 3677 artist_5_sanitized_url: "", 3678 url: "", 3679 timestamp: cuepoint.cue_time_start, 3680 duration_sec: cuepoint.cue_time_duration / 1000 3681 3682 }; 3683 if (player_has_recieved_cuepoint) { 3684 current_song.timestamp = (new Date()).getTime() / 1000; 3685 } 3686 player_has_recieved_cuepoint = true; 3687 track_event("Karnaval v6 Player", "Cuepoint", "Active Station:" + active_station.mount + " Cuepoint Song:" + current_song.song_db_id); 3688 $('#playButton').css('display', 'none'); 3689 $('#stopButton').css('display', 'flex'); 3690 $('#mvp_loader').css('display', 'none'); 3691 player_set_current_track(current_song); 3692 console.timeEnd("Player Until Play"); 3693 } 3694 return false;
3695 } 3696 var current_song = { 3697 album_cover_art: cuepoint.track_cover_url, 3698 song_db_id: cuepoint.song_db_id, 3699 sanitized_url: cuepoint.sanitized_url, 3700 title: cuepoint.cue_title, 3701 artist: cuepoint.track_artist_name, 3702 biography_image_16_9: cuepoint.biography_image_mobile, 3703 lyrics_html: cuepoint.lyrics_html, 3704 publisher_id: cuepoint.track_album_publisher, 3705 artist_id: cuepoint.track_artist_id, 3706 artist_is_foreign_artist: cuepoint.artist_is_foreign_artist, 3707 artist_sanitized_url: cuepoint.artist_sanitized_url, 3708 url_share: cuepoint.url_share, 3709 feat_artist_id: cuepoint.custom_artist_2_id, 3710 feat_artist_name: cuepoint.custom_artist_2_name, 3711 feat_artist_sanitized_url: cuepoint.artist_2_sanitized_url, 3712 artist_3_id: cuepoint.custom_artist_3_id, 3713 artist_3: cuepoint.custom_artist_3_name, 3714 artist_3_sanitized_url: cuepoint.artist_3_sanitized_url, 3715 artist_4_id: cuepoint.custom_artist_4_id, 3716 artist_4: cuepoint.custom_artist_4_name, 3717 artist_4_sanitized_url: cuepoint.artist_4_sanitized_url, 3718 artist_5_id: cuepoint.custom_artist_5_id, 3719 artist_5: cuepoint.custom_artist_5_name, 3720 artist_5_sanitized_url: cuepoint.artist_5_sanitized_url, 3721 url: (typeof (cuepoint.sanitized_url) !== "undefined" && cuepoint.sanitized_url != "") ? ("/sarkilar/" + cuepoint.sanitized_url + "-" + cuepoint.song_db_id) : "", 3722 timestamp: cuepoint.cue_time_start, 3723 duration_sec: cuepoint.cue_time_duration / 1000 3724 }; 3725 if (player_has_recieved_cuepoint) { 3726 current_song.timestamp = (new Date()).getTime() / 1000; 3727 } 3728 player_has_recieved_cuepoint = true; 3729 track_event("Karnaval v6 Player", "Cuepoint", "Active Station:" + active_station.mount + " Cuepoint Song:" + current_song.song_db_id); 3730 $('#playButton').css('display', 'none'); 3731 $('#stopButton').css('display', 'flex'); 3732 $('#mvp_loader').css('display', 'none'); 3733 player_set_current_track(current_song); 3734 ldr_update_next_song = true; 3735 console.timeEnd("Player Until Play"); 3736 } 3737} 3738 3739function player_event_on_custom_cuepoint(e) { 3740 debug('Next Song Cuepoint Recieved', "info"); 3741 debug(e, "info"); 3742 3743 if (typeof e.data !== "undefined" && typeof e.data.cuePoint !== "undefined" && typeof e.data.parameters !== "undefined" || typeof e.data.cuePoint.parameters !== "undefined") { 3744 var cuepoint = e.data.parameters || e.data.cuePoint.parameters; 3745 track_event("Karnaval v6 Player", "Next Cuepoint", "Active Station:" + active_station.mount); 3746 $('#playButton').css('display', 'none'); 3747 $('#stopButton').css('display', 'flex'); 3748 $('#mvp_loader').css('display', 'none'); 3749 player_set_next_track(cuepoint); 3750 } 3751 console.timeLog("Player Until Play", "player_event_on_custom_cuepoint"); 3752} 3753 3754function player_event_on_ad_cuepoint(e) { 3755 debug("Ad Break", "info"); 3756 debug(e); 3757 var current_song = { 3758 song_db_id: "", 3759 sanitized_url: "", 3760 title: active_station.title, 3761 artist: active_station.slogan, 3762 biography_image_16_9: active_station.url_default_artist_image, 3763 lyrics_html: "", 3764 bio_html: "", 3765 publisher_id: "", 3766 artist_id: "", 3767 artist_is_foregin_artist: active_station.is_foreign, 3768 artist_sanitized_url: "", 3769 url_share: "", 3770 feat_artist_id: "", 3771 feat_artist_name: "", 3772 feat_artist_sanitized_url: "", 3773 artist_3_id: "", 3774 artist_3: "", 3775 artist_3_sanitized_url: "", 3776 artist_4_id: "", 3777 artist_4: "", 3778 artist_4_sanitized_url: "", 3779 artist_5_id: "", 3780 artist_5: "", 3781 artist_5_sanitized_url: "", 3782 url: "", 3783 timestamp: 1, 3784 duration_sec: 1 3785 3786 }; 3787 if (player_has_recieved_cuepoint) { 3788 current_song.timestamp = (new Date()).getTime() / 1000; 3789 } 3790 player_has_recieved_cuepoint = true; 3791 track_event("Karnaval v6 Player", "Ad Break", "Active Station:" + active_station.mount); 3792 $('#playButton').css('display', 'none'); 3793 $('#stopButton').css('display', 'flex'); 3794 $('#mvp_loader').css('display', 'none'); 3795 player_set_current_track(current_song); 3796} 3797 3798function player_event_on_adblock_detected() { 3799 debug('Ad Block Detected', "info"); 3800 adblock_active = true; 3801 track_event("Karnaval v6 Player", "AdBlocker", "Active Station:" + active_station.mount); 3802} 3803 3804function player_event_on_stream_fail(e) { 3805 debug("Stream Failed"); 3806 debug(e); 3807} 3808 3809function player_event_on_stream_error(e) { 3810 debug("Stream Error"); 3811 debug(e); 3812} 3813 3814function player_event_on_stream_select(e) { 3815 debug("Stream Select"); 3816 debug(e); 3817} 3818 3819function player_event_on_stream_stop(e) { 3820 $('#playButton').css('display', 'flex'); 3821 $('#stopButton').css('display', 'none'); 3822 $('#mvp_loader').css('display', 'none'); 3823 debug("Stream Stop"); 3824 debug(e); 3825} 3826 3827function player_event_on_stream_start(e) { 3828 $('#playButton').css('display', 'none'); 3829 $('#stopButton').css('display', 'flex'); 3830 $('#mvp_loader').css('display', 'none'); 3831 player_mute($('#volumeSlider').val()); 3832 debug("Stream Start"); 3833 debug(e); 3834 pause_article_videos(); 3835} 3836 3837function player_event_on_timeout_alert(e) { 3838 debug("player_event_on_timeout_alert"); 3839 player.restartConnectionTimeOut(); 3840 track_event("Karnaval v6 Player", "Connection Timeout Alert", "Active Station:" + active_station.mount); 3841} 3842 3843function player_event_on_timeout_reach(e) { 3844 debug("player_event_on_timeout_reach"); 3845 track_event("Karnaval v6 Player", "Connection Timeout Reach", "Active Station:" + active_station.mount); 3846} 3847 3848/*Player Actions*/ 3849function player_update_ui() { 3850 $(".player_container").attr("data-status", player_status).data("status", player_status); 3851 $(".station_now_playing_container").attr("data-status", "").data("status", ""); 3852 3853 $(".list_item_station").removeClass("active"); 3854 if (active_player == "RADIO") { 3855 $(".station_now_playing_container.station_" + active_station.id).attr("data-status", player_status).data("status", player_status); 3856 3857 $(".list_item_show").removeClass("active"); 3858 if (player_status == "PLAYING") { 3859 $(".list_item_station[data-station_id=" + active_station.id + "]").addClass("active"); 3860 } 3861 } else { 3862 $(".player_list_container.player_list_container_shows .list_item_show.active").removeClass("active"); 3863 $(".list_item_episode").removeClass("active"); 3864 3865 if (player_status == "PLAYING") { 3866 if (typeof (player_current_track.show_id) !== "undefined") 3867 $(".player_list_container.player_list_container_shows .list_item_show[data-id=" + player_current_track.show_id + "]").addClass("active"); 3868 if (typeof (player_current_track.episode_id) !== "undefined") 3869 $(".list_item_episode[data-episode_id=" + player_current_track.episode_id + "]").addClass("active"); 3870 } 3871 } 3872 3873 set_player_status(); 3874 3875 playerUpdateUI(); 3876 updateMiniPlayerPlayingButtons(); 3877} 3878 3879function player_skip_ad() { 3880 try { 3881 if (typeof (player_active_preroll) !== "undefined" && player_active_preroll != null) { 3882 player.skipAd(); 3883 //setTimeout(function(){player_play_active_station(true);},1000); 3884 } else { 3885 player.skipAd(); 3886 } 3887 } catch (ex) { 3888 debug(ex, "error"); 3889 setTimeout(function () { 3890 player_play_active_station(true); 3891 }, 1000); 3892 } 3893} 3894 3895function player_stop() { 3896 3897 if (active_player == "PODCAST") { 3898 podcast_player.pause(); 3899 updateLoyaltyListeningMedia(LoyaltyEventType.STOP, true); 3900 last_saved_podcast_position = Math.floor(podcast_player.position / 1000);
3901 k_ajax_async("/functions/v6/api.functions.php", { 3902 "command": "set_podcast_position", 3903 "position": last_saved_podcast_position 3904 }); 3905 $('#playButton').css('display', 'flex'); 3906 $('#podcastSection #stopButton').css('display', 'none'); 3907 $('#pauseButton').css('display', 'none'); 3908 if (isMobile()) { 3909 $('#mobileActionPlayPodcast').css('display', 'flex'); 3910 $('#mobileActionPausePodcast').css('display', 'none'); 3911 } 3912 } else { 3913 if (player_status != "STOPPED" && player_status != "PAUSED") { 3914 track_event("Karnaval v6 Player", "Stop", "Active Station:" + active_station.mount); 3915 listening_start_time = 0; 3916 player.stop(); 3917 updateLoyaltyListeningMedia(LoyaltyEventType.STOP, true); 3918 player_status = "STOPPED"; 3919 3920 if (previousElementCount !== null) { 3921 const prevPlayElem = document.getElementById('fav_play_radio_' + previousElementCount); 3922 const prevPlayElemFavMobile = document.getElementById('fav_play_radio_mobile_' + previousElementCount); 3923 const prevplayElemMobile = document.getElementById('mobileActionPlayStationsMobile_' + previousElementCount); 3924 3925 if (prevPlayElem !== null) { 3926 prevPlayElem.style.setProperty('display', 'block', 'important'); 3927 } 3928 3929 if (prevplayElemMobile !== null) { 3930 prevplayElemMobile.style.setProperty('display', 'block', 'important'); 3931 } 3932 if (prevPlayElemFavMobile !== null) { 3933 prevPlayElemFavMobile.style.setProperty('display', 'block', 'important'); 3934 } 3935 } 3936 3937 } 3938 } 3939 player_update_ui(); 3940 updateFullPlayerButtons('STOPPED'); 3941} 3942 3943function player_play() { 3944 try { 3945 if (player_status == "PAUSED") { 3946 if (active_player == "PODCAST") { 3947 if (podcast_player != null) { 3948 track_event("Karnaval v6 Podcast Player", "Resume", "Active Show:" + active_show.title + " - Active Episode:" + player_current_podcast.title); 3949 podcast_player.resume(); 3950 updateLoyaltyListeningMedia(LoyaltyEventType.PLAY); 3951 startPlayerListenTimer(); // TriggeredPlaying() is called automatically every 60 seconds via startPlayerListenTimer() 3952 $(".footer-player .player-content .player-center").css("flex", "4"); 3953 $('#podcastSection').css('display', 'flex'); 3954 $('#radioSection').css('display', 'none'); 3955 $('#playButton').css('display', 'none'); 3956 $('#podcastSection #stopButton').css('display', 'flex'); 3957 $('#pauseButton').css('display', 'flex'); 3958 if (isMobile()) { 3959 // $('#mobileActionPlayPodcast').css('display', 'none'); 3960 $('#mobileActionPausePodcast').css('display', 'flex'); 3961 } 3962 // Mini Player 3963 $("#podcast-slider-container").attr('style', 'display: block'); 3964 3965 $(`.play_${player_current_podcast.id}`).css('display', 'none'); 3966 $(`.continue_${player_current_podcast.id}`).css('display', 'none'); 3967 $(`.pause_${player_current_podcast.id}`).css('display', 'flex'); 3968 } 3969 } else { 3970 if (player != null) { 3971 track_event("Karnaval v6 Player", "Resume", "Active Station:" + active_station.mount); 3972 player.resume(); 3973 updateLoyaltyListeningMedia(LoyaltyEventType.PLAY); 3974 startPlayerListenTimer(); // TriggeredPlaying() is called automatically every 60 seconds via startPlayerListenTimer() 3975 $(".footer-player .player-content .player-center").css("flex", "3"); 3976 $('#podcastSection').css('display', 'none'); 3977 $('#pauseButton').css('display', 'none'); 3978 $('#radioSection').css('display', 'flex'); 3979 } 3980 } 3981 } else { 3982 if (active_player == "RADIO") { 3983 if (!defaultStationPlayed) { 3984 defaultStationPlayed = true; 3985 const eventTitle = "PlayRadio"; 3986 const contentType = "Radio"; 3987 const contentDetail = { 3988 active_station_id: active_station.id, 3989 active_station: active_station.title 3990 } 3991 pushEventToDataLayer(eventTitle, contentType, contentDetail); 3992 } 3993 player_play_active_station(); 3994 $(".footer-player .player-content .player-center").css("flex", "4"); 3995 $('#podcastSection').css('display', 'none'); 3996 $('#pauseButton').css('display', 'none'); 3997 $('#radioSection').css('display', 'flex'); 3998 3999 // Mini Player 4000 $("#podcast-slider-container").attr('style', 'display: none;') 4001 4002 } else if (player_current_podcast != null) { 4003 $(".footer-player .player-content .player-center").css("flex", "4"); 4004 player_play_podcast_episode(player_current_podcast.id); 4005 $('#podcastSection').css('display', 'flex'); 4006 $('#radioSection').css('display', 'none'); 4007 $('#playButton').css('display', 'none'); 4008 $('#podcastSection #stopButton').css('display', 'flex'); 4009 if (isMobile()) { 4010 $('#mobileActionPlayPodcast').css('display', 'none'); 4011 $('#mobileActionPausePodcast').css('display', 'flex'); 4012 } 4013 } 4014 } 4015 updateFullPlayerButtons("PLAYING"); 4016 updateMiniPlayerPlayingButtons(); 4017 } catch (e) { 4018 debug(e); 4019 } 4020} 4021 4022function player_next() { 4023 if (active_player === "PODCAST") { 4024 const nextEpisode = get_value(player_current_podcast, "next"); 4025 const actionButtonStates = { 4026 PLAY_ACTIVE: {play: 'flex', continues: 'none', pause: 'none'}, 4027 PAUSE_ACTIVE: {play: 'none', continues: 'none', pause: 'flex'} 4028 } 4029 if (nextEpisode && typeof nextEpisode.id !== 'undefined') { 4030 // For old episode should be play icon before change 4031 changeActionButtonIconsForPlayer(actionButtonStates.PLAY_ACTIVE); 4032 track_event("Karnaval v6 Podcast Player", "Next", "Active Show:" + active_show.title + " - Active Episode:" + player_current_podcast.title); 4033 player_play_podcast_episode(nextEpisode.id).then(() => { 4034 // For a new episode should be a pause icon before change 4035 changeActionButtonIconsForPlayer(actionButtonStates.PAUSE_ACTIVE); 4036 }); 4037 return true; 4038 } 4039 4040 return false;
4041 } 4042 var next_station = null; 4043 var found_current = false; 4044 4045 var first_station = null; 4046 $.each(stations, function (index, station) { 4047 if (typeof active_station === "undefined" || active_station == null) 4048 active_station = station; 4049 4050 if (first_station == null) 4051 first_station = station; 4052 4053 if (found_current) { 4054 next_station = station; 4055 return false; 4056 } 4057 if (station.id == active_station.id) { 4058 found_current = true; 4059 } 4060 }); 4061 4062 if (typeof next_station === "undefined" || next_station == null) 4063 next_station = first_station; 4064 4065 track_event("Karnaval v6 Player", "Next", "Active Station:" + active_station.mount + " - Next Station:" + next_station.mount); 4066 4067 return player_select_station(next_station); 4068} 4069 4070function player_prev() { 4071 if (active_player === "PODCAST") { 4072 if (get_value(player_current_podcast, "prev") != false) { 4073 track_event("Karnaval v6 Podcast Player", "Previous", "Active Show:" + active_show.title + " - Active Episode:" + player_current_podcast.title); 4074 return player_play_podcast_episode(get_value(player_current_podcast, "prev")); 4075 } 4076 4077 return false; 4078 } 4079 4080 var previous_station = null; 4081 var found_current = false; 4082 ; 4083 var last_station = null; 4084 4085 $.each(stations, function (index, station) { 4086 if (typeof active_station === "undefined" || active_station == null) 4087 active_station = station; 4088 if (station.id == active_station.id) { 4089 found_current = true; 4090 } 4091 4092 if (found_current == false) 4093 previous_station = station; 4094 4095 last_station = station; 4096 }); 4097 4098 if (typeof previous_station === "undefined" || previous_station == null) 4099 previous_station = last_station; 4100 4101 track_event("Karnaval v6 Player", "Previous", "Active Station:" + active_station.mount + " - Previous Station:" + previous_station.mount); 4102 return player_select_station(previous_station); 4103} 4104 4105function player_shuffle() { 4106 if (active_player === "PODCAST") 4107 return false; 4108 4109 var ids = []; 4110 $.each(stations, function (index, station) { 4111 ids.push(index); 4112 }); 4113 var random_station = stations[ids[Math.floor(Math.random() * ids.length) + 1]]; 4114 4115 if (typeof active_station !== "undefined" && active_station != null) { 4116 while (random_station.id == active_station.id) 4117 random_station = stations[ids[Math.floor(Math.random() * ids.length) + 1]]; 4118 } 4119 4120 track_event("Karnaval v6 Player", "Shuffle", "Active Station:" + active_station.mount + " - New Station:" + random_station.mount); 4121 return player_select_station(random_station); 4122} 4123 4124function player_pause() { 4125 debug("Pause - Current Status:" + player_status + " - Active Player:" + active_player); 4126 if (player_status != "STOPPED") { 4127 if (active_player == "PODCAST") { 4128 if (podcast_player != null) { 4129 track_event("Karnaval v6 Podcast Player", "Pause", "Active Show:" + active_show.title); 4130 podcast_player.pause(); 4131 updateLoyaltyListeningMedia(LoyaltyEventType.PAUSE, true); 4132 last_saved_podcast_position = Math.floor(podcast_player.position / 1000); 4133 k_ajax_async("/functions/v6/api.functions.php", { 4134 "command": "set_podcast_position", 4135 "position": last_saved_podcast_position 4136 }); 4137 $('#playButton').css('display', 'flex'); 4138 $('#podcastSection #stopButton').css('display', 'none'); 4139 $('#pauseButton').css('display', 'none'); 4140 if (isMobile()) { 4141 $('#mobileActionPlayPodcast').css('display', 'flex'); 4142 $('#mobileActionPausePodcast').css('display', 'none'); 4143 } 4144 4145 $(`.play_${player_current_podcast.id}`).css('display', 'none'); 4146 $(`.continue_${player_current_podcast.id}`).css('display', 'flex'); 4147 $(`.pause_${player_current_podcast.id}`).css('display', 'none'); 4148 } 4149 4150 } else { 4151 if (player != null) { 4152 track_event("Karnaval v6 Player", "Pause", "Active Station:" + active_show.title); 4153 player.pause(); 4154 updateLoyaltyListeningMedia(LoyaltyEventType.PAUSE, true); 4155 } 4156 } 4157 } 4158 updateFullPlayerButtons(player_status); 4159 updateMiniPlayerPlayingButtons(); 4160} 4161 4162function player_rewind(seconds) { 4163 if (active_player != "PODCAST") { 4164 return false;
4165 } 4166 4167 if (podcast_player == null || typeof (podcast_player) == "undefined") 4168 return false 4169 4170 if (player_status != "PLAYING") 4171 return false 4172 4173 if (typeof (seconds) === "undefined") { 4174 seconds = 15; 4175 } 4176 4177 try { 4178 omnyStudioTracker.createEvent("Stop"); 4179 podcast_player.setPosition(podcast_player.position - seconds * 1000); 4180 omnyStudioTracker.createEvent("Start"); 4181 return true; 4182 } catch (e) { 4183 return false; 4184 } 4185} 4186 4187function player_forward(seconds) { 4188 if (active_player != "PODCAST") { 4189 return false; 4190 } 4191 4192 if (podcast_player == null || typeof (podcast_player) == "undefined") 4193 return false 4194 4195 if (typeof (seconds) === "undefined") { 4196 seconds = 15; 4197 } 4198 4199 if (player_status != "PLAYING") 4200 return false 4201 4202 try { 4203 omnyStudioTracker.createEvent("Stop"); 4204 podcast_player.setPosition(podcast_player.position + seconds * 1000); 4205 omnyStudioTracker.createEvent("Start"); 4206 return true; 4207 } catch (e) { 4208 return false; 4209 } 4210} 4211 4212/*Player Helpers*/ 4213function player_update_favorite_song(song_to_check) { 4214 4215 var parent = $(".now_playing_container"); 4216 4217 $(".track_container .current", parent).removeClass("is_favorite"); 4218 4219 4220 if (active_player != "RADIO") { 4221 $(".track_container .current .action_favorite", parent).fadeOut(); 4222 $(".track_container .current .action_favorite", parent).removeAttr("onclick"); 4223 return false; 4224 } 4225 4226 if (logged_in_member != null) { 4227 if (song_to_check && typeof song_to_check.song_db_id !== "undefined" && parseInt(song_to_check.song_db_id) > 0) { 4228 is_favorite = false; 4229 if (typeof (logged_in_member.favorite_songs) !== "undefined") { 4230 $.each(logged_in_member.favorite_songs, function (index, favorite_song) { 4231 if (favorite_song.id == song_to_check.song_db_id) { 4232 is_favorite = true; 4233 } 4234 }); 4235 } 4236 4237 if (is_favorite) { 4238 $(".track_container .current", parent).addClass("is_favorite"); 4239 $(".track_container .current .action_favorite", parent).attr("onclick", "remove_from_favorite_songs(" + song_to_check.song_db_id + "," + active_station.id + ");").fadeIn(); 4240 } else { 4241 $(".track_container .current .action_favorite", parent).attr("onclick", "add_to_favorite_songs(" + song_to_check.song_db_id + "," + active_station.id + ");").fadeIn(); 4242 } 4243 } else { 4244 $(".track_container .current .action_favorite", parent).fadeOut(); 4245 } 4246 } 4247 4248} 4249 4250function player_set_current_track(to_set) { 4251 var parent = $(".footer-player"); 4252 4253 var lyrics = ""; 4254 var bio = ""; 4255 var bio_image = active_station.androidDefaultLogo; 4256 var artist_html = ""; 4257 var artist_name = ""; 4258 var title_html = ""; 4259 var song_url = ""; 4260 4261 if (typeof to_set.song_db_id === "undefined" && typeof to_set.publisher_id !== "undefined" && !isNaN(parseInt(to_set.publisher_id))) { 4262 return player_get_current_song(active_station.id); 4263 //return player_get_song_info(active_station.publisher_id); 4264 } 4265 if (active_player != "PODCAST") { 4266 if (typeof player_current_track !== "undefined" && player_current_track != null && (to_set.title != player_current_track.title || to_set.artist != player_current_track.artist)) { 4267 toggle_player_companion(null, has_active_ldr_show ? true : false); 4268 } 4269 } 4270 4271 if (typeof to_set.url !== "undefined" && to_set.url != "") 4272 song_url = to_set.url; 4273 else song_url = "javascript:;"; 4274 4275 if (to_set.artist_id == "" && active_station.is_foreign == 1) 4276 to_set.artist_is_foreign_artist = 1; 4277 4278 title_html = to_set.title; 4279 if (typeof (to_set.url) !== "undefined") { 4280 title_html = "<a href='" + song_url + "'>" + to_set.title + "</a>"; 4281 } 4282 4283 if (get_value(to_set, "lyrics_html") !== false) 4284 lyrics = get_value(to_set, "lyrics_html") 4285 4286 4287 if (get_value(to_set, "album_cover_art", "") != "") { 4288 bio_image = get_value(to_set, "album_cover_art", ""); 4289 } else if (get_value(to_set, "biography_image_mobile", "") != "") { 4290 bio_image = get_value(to_set, "biography_image_mobile", ""); 4291 } else if (get_value(to_set, "biography_image_16_9", "") != "") { 4292 bio_image = get_value(to_set, "biography_image_16_9", ""); 4293 } else if (get_value(active_station, "url_default_artist_image_16_9", "") != "") { 4294 bio_image = get_value(active_station, "url_default_artist_image_16_9", ""); 4295 } 4296 4297 if (get_value(to_set, "artist") !== false) { 4298 var url_artist = "javascript:;"; 4299 if (get_value(to_set, "artist_sanitized_url", "") !== "") { 4300 if (get_value(to_set, "artist_sanitized_url", "").indexOf("/sanatcilar") >= 0) 4301 url_artist = get_value(to_set, "artist_sanitized_url", "") 4302 else 4303 url_artist = "/sanatcilar/" + get_value(to_set, "artist_sanitized_url", "") + "-" + get_value(to_set, "artist_id", ""); 4304 } 4305 4306 4307 artist_html = "<a href='" + url_artist + "'>" + to_set.artist + "</a>"; 4308 4309 4310 if (get_value(to_set, "artist_2") != "") { 4311 url_artist = "javascript:;"; 4312 if (get_value(to_set, "artist_2_sanitized_url", "") !== "") { 4313 if (get_value(to_set, "artist_2_sanitized_url", "").indexOf("/sanatcilar") >= 0) 4314 url_artist = get_value(to_set, "artist_2_sanitized_url", "") 4315 else 4316 url_artist = "/sanatcilar/" + get_value(to_set, "artist_2_sanitized_url", "") + "-" + get_value(to_set, "artist_2_id", ""); 4317 } 4318 artist_html += " feat. <a href='" + url_artist + "'>" + get_value(to_set, "artist_2") + "</a>"; 4319 } 4320 if (get_value(to_set, "artist_3") != "") { 4321 url_artist = "javascript:;"; 4322 if (get_value(to_set, "artist_3_sanitized_url", "") !== "") { 4323 if (get_value(to_set, "artist_3_sanitized_url", "").indexOf("/sanatcilar") >= 0) 4324 url_artist = get_value(to_set, "artist_3_sanitized_url", "") 4325 else 4326 url_artist = "/sanatcilar/" + get_value(to_set, "artist_3_sanitized_url", "") + "-" + get_value(to_set, "artist_3_id", ""); 4327 } 4328 4329 artist_html += ", <a href='" + url_artist + "'>" + get_value(to_set, "artist_3") + "</a>"; 4330 } 4331 if (get_value(to_set, "artist_4") != "") { 4332 url_artist = "javascript:;"; 4333 if (get_value(to_set, "artist_4_sanitized_url", "") !== "") { 4334 if (get_value(to_set, "artist_4_sanitized_url", "").indexOf("/sanatcilar") >= 0) 4335 url_artist = get_value(to_set, "artist_4_sanitized_url", "") 4336 else 4337 url_artist = "/sanatcilar/" + get_value(to_set, "artist_4_sanitized_url", "") + "-" + get_value(to_set, "artist_4_id", ""); 4338 } 4339 artist_html += ", <a href='" + url_artist + "'>" + get_value(to_set, "artist_4") + "</a>"; 4340 } 4341 if (get_value(to_set, "artist_5") != "") { 4342 url_artist = "javascript:;"; 4343 if (get_value(to_set, "artist_5_sanitized_url", "") !== "") { 4344 if (get_value(to_set, "artist_5_sanitized_url", "").indexOf("/sanatcilar") >= 0) 4345 url_artist = get_value(to_set, "artist_5_sanitized_url", "") 4346 else 4347 url_artist = "/sanatcilar/" + get_value(to_set, "artist_5_sanitized_url", "") + "-" + get_value(to_set, "artist_5_id", ""); 4348 } 4349 artist_html += ", <a href='" + url_artist + "'>" + get_value(to_set, "artist_5") + "</a>"; 4350 } 4351 } 4352 4353 $(".track_container", parent).removeClass("next_track_active"); 4354 4355 $(".player-content .player-left .album-art", parent).attr("src", buildVersionedMediaImageUrl(bio_image)); 4356 $(".player-content .player-left .track-info .radio-info .song-name", parent).html(to_set.title); 4357 $(".player-content .player-left .track-info .radio-info .artist-name", parent).html(to_set.artist); 4358 4359 player_update_favorite_song(to_set); 4360 4361 $(".player_companion_container .player_companion_lyrics .title").html(title_html); 4362 $(".player_companion_container .player_companion_lyrics .sub_title").html(artist_html); 4363 $(".player_companion_container .player_companion_lyrics .content").html(lyrics); 4364 4365 $(".track_toggle_container .toggle_button_lyrics").removeClass("disabled"); 4366 if (lyrics?.trim() == "") { 4367 if ($(".track_toggle_container .toggle_button_lyrics").hasClass("active")) 4368 toggle_player_companion("lyrics"); 4369 4370 $(".track_toggle_container .toggle_button_lyrics").addClass("disabled"); 4371 } 4372 4373 $(".track_container_next").fadeOut(); 4374 4375 if (get_value(to_set, "is_podcast")) { 4376 4377 $(".player_list_container.player_list_container_shows .list_item_show").removeClass("active"); 4378 $(".player_list_container.player_list_container_shows .list_item_show[data-id=" + to_set.show.id + "]").addClass("active"); 4379 4380 4381 $(".player_companion_container .player_companion_episodes .list_podcast_episodes").html(""); 4382 var count = 0; 4383 var found_current = false;
4384 // $.each(to_set.show.episodes, function (index, episode) { 4385 // if (count > 1) 4386 // return false; 4387 4388 // if (found_current == false && episode.id != to_set.episode_id) { 4389 // return true; 4390 // } 4391 4392 // found_current = true; 4393 4394 // //$(".footer-player .player-content .player-center #podcastSection").css("display", "none"); 4395 // //$(".footer-player .player-content .player-center #radioSection").css("display", "flex"); 4396 // $(".player_companion_container .player_companion_episodes .list_podcast_episodes").append('\ 4397 // <li class="list_item list_item_episode" data-episode_id="' + episode.id + '">\ 4398 // ' + (count == 1 ? ('<div class="super_title">SIRADAKİ</div>') : '') + '\ 4399 // <figure class="thumb_container">' + svg_icon_player_toggle_podcast + '</figure>\ 4400 // <div class="title_container">\ 4401 // <span class="title">' + episode.title + '</span>\ 4402 // <span class="sub_title">' + episode.duration + '</span>\ 4403 // <span class="description">' + episode.sub_title + '</span>\ 4404 // </div>\ 4405 // <!--a href="javascript:;" onclick="player_play_podcast_episode(' + episode.id + ');" class="link">' + episode.title + '</a-->\ 4406 // <div class="action_bar">\ 4407 // <a class="action action_play" href="javascript:;" onClick="player_play_podcast_episode(' + episode.id + ')">\ 4408 // ' + svg_icon_player_play + '\ 4409 // </a>\ 4410 // <a class="action action_pause" href="javascript:;" onClick="player_pause()">\ 4411 // ' + svg_icon_player_pause + '\ 4412 // </a>\ 4413 // </div>\ 4414 // </li>'); 4415 // count++; 4416 // }); 4417 4418 $(".player_companion_container .link_show_episodes").attr("href", to_set.show.url); 4419 4420 $(".list_item_episode").removeClass("active"); 4421 $(".list_item_episode[data-episode_id=" + to_set.episode_id + "]").addClass("active"); 4422 4423 $(".player_container").addClass("podcast"); 4424 $(".player-content .player-left .track-info .podcast-info .podcast-name").html(to_set.show.title); 4425 $(".player-content .player-left .track-info .podcast-info .chapter-name").html(to_set.title); 4426 $(".player-content .player-left .track-info .podcast-info .podcaster-name").html(to_set.artist); 4427 $(".track_container .current .super_title", parent).html("PODCAST");//to_set.show.title); 4428 } else { 4429 $(".player_container").removeClass("podcast"); 4430 4431 $(".player-content .player-left .track-info .radio-info .radio-name", parent).html(active_station.title); 4432 4433 $(".player-content .player-left .track-info .radio-info .song-name").html(to_set.title); 4434 $(".player-content .player-left .track-info .radio-info .artist-name").html(to_set.artist); 4435 4436 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .biography_image_container").css("background-image", "url(" + bio_image.replace("http://mediacdn.", "https://mediacdns.") + ")"); 4437 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .current_song_background").css("background-image", "url(" + bio_image.replace("http://mediacdn.", "https://mediacdns.") + ")"); 4438 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .title").html(to_set.title); 4439 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .sub_title").html(to_set.artist); 4440 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .station_overlay_title").html(to_set.title); 4441 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .station_overlay_sub_itle").html(to_set.artist); 4442 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .song_progress_container").data("duration", to_set.duration_sec).attr("data-duration", to_set.duration_sec); 4443 $(".stations_page .list_item_station[data-station_id=" + active_station.id + "] .song_progress_container").data("position", 0).attr("data-position", 0); 4444 4445 $(".station_page .station_now_playing_container.station_" + active_station.id + " .title_container .title").html(to_set.title); 4446 $(".station_page .station_now_playing_container.station_" + active_station.id + " .title_container .sub_title").html(to_set.artist); 4447 $(".station_page .station_now_playing_container.station_" + active_station.id + " .thumb_container").css("background-image", "url(" + bio_image.replace("http://mediacdn.", "https://mediacdns.") + ")"); 4448 } 4449 4450 player_animate_track_titles(); 4451 player_current_track = to_set; 4452 refresh_banners(); 4453 playerUpdateUI(); 4454 4455 var addthis_parent = $("#player_addthis").parent(); 4456 $("#player_addthis").remove(); 4457 4458 addthis_parent.append('<div id="player_addthis" class="addthis_inline_share_toolbox"></div>'); 4459 4460 4461 var share_title = "Karnaval'da " + active_station.name + " ve " + player_current_track.title + " dinliyorum."; 4462 var share_url = player_current_track.url_share; 4463 4464 if (get_value(to_set, "is_podcast")) { 4465 share_title = "Karnaval'da " + to_set.show.title + " dinliyorum."; 4466 } 4467 4468 $("#player_addthis").data("url", share_url) 4469 .attr("data-url", share_url) 4470 .data("title", share_title) 4471 .attr("data-title", share_title); 4472 4473 refresh_addthis(); 4474 4475 try { 4476 if ('mediaSession' in navigator) { 4477
4478 navigator.mediaSession.metadata = new MediaMetadata({ 4479 title: to_set.title, 4480 artist: to_set.artist, 4481 album: to_set.album, 4482 artwork: [ 4483 {src: bio_image} 4484 ] 4485 }); 4486 } 4487 if (get_value(to_set, "is_podcast")) 4488 podcast_player._a.setAttribute("title", "Karnaval.com'da " + to_set.show.title + " dinliyorsunuz."); 4489 else 4490 player.MediaElement.audioNode.setAttribute("title", "Karnaval.com'da " + active_station.title + " dinliyorsunuz."); 4491 } catch (exception) { 4492 } 4493 4494} 4495 4496function player_set_next_track(to_set) { 4497 debug(to_set, "info"); 4498 var parent = $(".player_container"); 4499 4500 var bio_image = active_station.url_default_artist_image; 4501 if (typeof to_set.biography_image_mobile !== "undefined" && to_set.biography_image_mobile != "") 4502 bio_image = to_set.biography_image_mobile; 4503 4504 $(".track_container", parent).addClass("next_track_active"); 4505 4506 $(".track_container .next .thumb_container", parent).css("background-image", "url(" + bio_image.replace("http://mediacdn.", "https://mediacdns.") + ")"); 4507 $(".track_container .next .title > span", parent).html(to_set.cue_title); 4508 $(".track_container .next .sub_title > span", parent).html(to_set.track_artist_name); 4509 4510} 4511 4512async function player_select_station(to_select, ga_event_data, elementCount) { 4513 if (!defaultStationPlayed) defaultStationPlayed = true; 4514 console.time("Player Until Play"); 4515 updatePlayButton(false); 4516 $(".footer-player .player-content .player-center").css("flex", "3"); 4517 $("#podcastSection").css("display", "none"); 4518 $("#radioSection").css("display", "flex"); 4519 $(".footer-player .player-content .player-center #podcastSection").css("display", "none"); 4520 $(".footer-player .player-content .player-center #radioSection").css("display", "flex"); 4521 if (previousElementCount !== null) { 4522 const prevPlayElem = document.getElementById('fav_play_radio_' + previousElementCount); 4523 const prevPlayElemFavMobile = document.getElementById('fav_play_radio_mobile_' + previousElementCount); 4524 4525 const prevplayElemMobile = document.getElementById('mobileActionPlayStationsMobile_' + previousElementCount); 4526 4527 if (prevPlayElem !== null) { 4528 prevPlayElem.style.setProperty('display', 'block', 'important'); 4529 } 4530 4531 if (prevplayElemMobile !== null) { 4532 prevplayElemMobile.style.setProperty('display', 'flex', 'important'); 4533 } 4534 4535 if (prevPlayElemFavMobile !== null) { 4536 prevPlayElemFavMobile.style.setProperty('display', 'block', 'important'); 4537 } 4538 } 4539 4540 const currentPlayElem = document.getElementById('fav_play_radio_' + elementCount); 4541 const prevPlayElemFavMobile = document.getElementById('fav_play_radio_mobile_' + elementCount); 4542 4543 const currentPlayElemMobile = document.getElementById('mobileActionPlayStationsMobile_' + elementCount); 4544 4545 if (currentPlayElem !== null) { 4546 currentPlayElem.style.setProperty('display', 'block', 'important'); 4547 } 4548 4549 if (currentPlayElemMobile !== null) { 4550 currentPlayElemMobile.style.setProperty('display', 'block', 'important'); 4551 } 4552 4553 if (prevPlayElemFavMobile !== null) { 4554 prevPlayElemFavMobile.style.setProperty('display', 'block', 'important'); 4555 } 4556 4557 previousElementCount = elementCount; 4558 4559 if (typeof (ga_event_data) !== "undefined") { 4560 track_event(ga_event_data.category, ga_event_data.action, ga_event_data.label); 4561 } 4562 4563 player_switch("RADIO"); 4564 4565 if (player_change_timeout != null) 4566 clearTimeout(player_change_timeout); 4567 4568 // if (typeof to_select === "number" && typeof (stations["station_" + to_select]) !== "undefined") { 4569 // to_select = stations["station_" + to_select]; 4570 // } else if (typeof to_select === "number" && typeof (playlists["station_" + to_select]) !== "undefined") { 4571 // to_select = playlists["station_" + to_select]; 4572 // } 4573 if (typeof to_select === "number") { 4574 const foundRadio = await stationService.getStationById(to_select); 4575 if (foundRadio) { 4576 to_select = Station.from(foundRadio.data); 4577 updatePlayerTargetingParameters(to_select.shortName); 4578 CURRENT_SONG_INFO = current_song_list[`station_${to_select.id}`]; 4579 if (typeof CURRENT_SONG_INFO.current_song !== 'undefined') { 4580 CURRENT_SONG_INFO = CURRENT_SONG_INFO.current_song; 4581 } 4582 player_set_current_track(CURRENT_SONG_INFO); 4583 } 4584 } 4585 4586 var old_active_station = active_station; 4587 to_select.current_song = CURRENT_SONG_INFO; 4588 active_station = to_select; 4589 debug(active_station); 4590 //todo: track station 4591 player_current_track = null; 4592 if (active_station) { 4593 const eventTitle = "PlayRadio"; 4594 const contentType = "Radio"; 4595 const contentDetail = { 4596 active_station_id: active_station.id, 4597 active_station: active_station.title 4598 } 4599 pushEventToDataLayer(eventTitle, contentType, contentDetail); 4600 } 4601 4602 $(".player_container .player-content .player-left img").attr("src", "" + active_station.androidDefaultLogo + ""); 4603 $(".player_container .player-content .player-left img").attr("alt", "" + active_station.title + ""); 4604 // $(".station_logo_container a").attr("href", "" + active_station.url + ""); It was not using anywhere 4605 $(".player_container .player-content .player-left .track-info .radio-info .radio-name").html(active_station.title); 4606 player_set_current_track(active_station.current_song); 4607 player_change_timeout = setTimeout(player_play_active_station, 500); 4608 4609 if (old_active_station.id != active_station.id) { 4610 // Set active station on backend
4611 k_ajax_async("/functions/v6/api.functions.php", { 4612 "command": "set_active_station", 4613 "station_id": active_station.id 4614 }).then(r => { 4615 // console.log("set_active_station_result", r) 4616 }); 4617 toggle_player_companion(); 4618 } 4619 check_ldr_show = true; 4620} 4621 4622var mustLoginToListenCurrentStation = false; 4623 4624 4625// Log loyalty listen count to the backend 4626function logLoyaltyListenCount(sessionData) { 4627 if (!sessionData) { 4628 console.error("logLoyaltyListenCount: No session data provided"); 4629 return; 4630 } 4631 4632 try { 4633 const listenCountData = { 4634 userId: sessionData.userId || null, 4635 sessionId: sessionData.sessionId || null, // Use sessionId from current_loyalty_listening_media (null for initial call, then from response) 4636 platform: sessionData.platform || "website", 4637 duration: 60 // Always 60 seconds - no accumulation 4638 }; 4639 4640 // Set stationId or podcastId based on type 4641 if (sessionData.type === 'radio') { 4642 listenCountData.stationId = sessionData.stationId || null; 4643 listenCountData.podcastId = null; 4644 listenCountData.stationTitle = sessionData.stationTitle || null; 4645 } else if (sessionData.type === 'podcast') { 4646 listenCountData.podcastId = sessionData.podcastId || null; 4647 listenCountData.showId = sessionData.showId || null; 4648 listenCountData.stationId = null; 4649 listenCountData.sanitizedUrl = sessionData.sanitizedUrl || null; 4650 } else { 4651 return; // Unknown type - skip the call 4652 } 4653 4654 // Call the new API service 4655 if (typeof window.logListenCount === 'function') { 4656 window.logListenCount(listenCountData).then(function (response) { 4657 // Extract sessionId from response and update current_loyalty_listening_media.sessionId 4658 if (response && response.data && response.data.sessionId) { 4659 if (current_loyalty_listening_media) { 4660 current_loyalty_listening_media.sessionId = response.data.sessionId; 4661 } 4662 } 4663 }).catch(function (e) { 4664 console.error("Failed to log loyalty listening session", e); 4665 }); 4666 } 4667 } catch (e) { 4668 console.error("Failed to log loyalty listening session", e); 4669 } 4670} 4671 4672// function that calls Loyalty API to log the listening count information every 60 seconds 4673function triggeredPlaying() { 4674 // Only send if still playing 4675 if (!current_loyalty_listening_media || current_loyalty_listening_media.status !== LoyaltyStatus.PLAYING) { 4676 return; 4677 } 4678 4679 // Always send duration = 60 seconds (no accumulation) 4680 const sessionDataForLogging = { 4681 status: current_loyalty_listening_media.status, 4682 type: current_loyalty_listening_media.type, 4683 sessionId: current_loyalty_listening_media.sessionId, 4684 userId: logged_in_member ? logged_in_member.id : null, 4685 platform: current_loyalty_listening_media.platform, 4686 duration: 60, // Always 60 seconds 4687 stationId: current_loyalty_listening_media.stationId, 4688 podcastId: current_loyalty_listening_media.podcastId, 4689 showId: current_loyalty_listening_media.showId 4690 }; 4691 4692 let playingInfo = ""; 4693 if (current_loyalty_listening_media.type === 'radio') { 4694 playingInfo = `radio - ${active_station?.title || active_station?.mount || "Unknown Station"}`; 4695 sessionDataForLogging.stationTitle = active_station.title; 4696 } else if (current_loyalty_listening_media.type === 'podcast') { 4697 const episodeTitle = player_current_podcast?.title || "Unknown Episode"; 4698 const showTitle = active_show?.title || player_current_podcast?.Show?.title || "Unknown Show"; 4699 sessionDataForLogging.sanitizedUrl = active_show.sanitizedUrl; 4700 playingInfo = `podcast episode - ${episodeTitle} | ${showTitle}`; 4701 } else { 4702 playingInfo = "unknown"; 4703 return; 4704 } 4705 4706 // Call function for 60-second interval logging 4707 logLoyaltyListenCount(sessionDataForLogging); 4708} 4709 4710// Player tracking system for listen-count logging 4711var playerListenTimer = null; // Timer for 60-second interval logging 4712 4713 4714// Event type enum for loyalty listening media 4715const LoyaltyEventType = { 4716 PLAY: 'play', 4717 PAUSE: 'pause', 4718 STOP: 'stop' 4719}; 4720 4721// Status enum for loyalty listening media 4722const LoyaltyStatus = { 4723 PLAYING: 'playing', 4724 PAUSED: 'paused', 4725 STOPPED: 'stopped' 4726}; 4727 4728// Update current loyalty listening media object (simplified - no duration accumulation) 4729function updateLoyaltyListeningMedia(eventType, manageTimer) { 4730 if (manageTimer === undefined) { 4731 manageTimer = false;
4732 } 4733 4734 // Validate eventType 4735 const validEventTypes = [LoyaltyEventType.PLAY, LoyaltyEventType.PAUSE, LoyaltyEventType.STOP]; 4736 if (!validEventTypes.includes(eventType)) { 4737 console.error("updateLoyaltyListeningMedia: Invalid eventType. Must be 'play', 'pause', or 'stop'. Got:", eventType); 4738 return; 4739 } 4740 4741 if (eventType === LoyaltyEventType.PLAY) { 4742 // Starting a new session or resuming from pause 4743 // sessionId will be null initially, then set from backend response 4744 current_loyalty_listening_media = { 4745 status: LoyaltyStatus.PLAYING, 4746 type: active_player === "RADIO" ? 'radio' : 'podcast', 4747 sessionId: null, // Will be set from backend response after first call 4748 userId: logged_in_member?.id || null, 4749 platform: 'website' 4750 }; 4751 4752 if (active_player === "RADIO") { 4753 current_loyalty_listening_media.stationId = active_station?.id; 4754 current_loyalty_listening_media.podcastId = null; 4755 } else if (active_player === "PODCAST") { 4756 current_loyalty_listening_media.podcastId = player_current_podcast?.id; 4757 current_loyalty_listening_media.showId = active_show?.id || player_current_podcast?.Show?.id || null; 4758 current_loyalty_listening_media.stationId = null; 4759 } 4760 } else if (eventType === LoyaltyEventType.PAUSE || eventType === LoyaltyEventType.STOP) { 4761 // Just stop the timer - no need to log or accumulate duration 4762 // If stopped/paused before 60 seconds, we don't send any request 4763 current_loyalty_listening_media.status = eventType === LoyaltyEventType.PAUSE ? LoyaltyStatus.PAUSED : LoyaltyStatus.STOPPED; 4764 } 4765 4766 // Optionally manage the listen timer based on event type 4767 if (manageTimer) { 4768 if (eventType === LoyaltyEventType.PLAY) { 4769 startPlayerListenTimer(); 4770 } else if (eventType === LoyaltyEventType.PAUSE || eventType === LoyaltyEventType.STOP) { 4771 stopPlayerListenTimer(); 4772 } 4773 } 4774} 4775 4776// Start the 60-second interval timer for logging 4777function startPlayerListenTimer() { 4778 // Clear any existing timer 4779 if (playerListenTimer !== null) { 4780 clearInterval(playerListenTimer); 4781 playerListenTimer = null; 4782 } 4783 4784 // Start new timer - calls TriggeredPlaying every 60 seconds with duration=60 4785 playerListenTimer = setInterval(function () { 4786 if (player_status === "PLAYING" && current_loyalty_listening_media && current_loyalty_listening_media.status === LoyaltyStatus.PLAYING) { 4787 triggeredPlaying(); 4788 } 4789 }, 60000); // 60 seconds 4790} 4791 4792// Stop the 60-second interval timer 4793function stopPlayerListenTimer() { 4794 if (playerListenTimer !== null) { 4795 clearInterval(playerListenTimer); 4796 playerListenTimer = null; 4797 } 4798} 4799 4800function player_play_active_station(skip_ad) { 4801 if (typeof skip_ad === "undefined") 4802 skip_ad = false; 4803 if (/*is_mobile() || is_tablet() || */active_station.has_preroll == "0") 4804 skip_ad = true; 4805 4806 $(".preroll_container").removeClass("active"); 4807 //player_active_preroll = null; 4808 4809 player_switch("RADIO"); 4810 clearTimeout(player_change_timeout); 4811 4812 // Mini Player 4813 $("#podcast-slider-container").attr('style', 'display: none;') 4814 4815 4816 debug(player_status); 4817 if (player_status != "STOPPED") { 4818 // Stop timer for previous station/episode before switching (no request sent if stopped before 60 seconds) 4819 if (current_loyalty_listening_media && current_loyalty_listening_media.status !== LoyaltyStatus.STOPPED) { 4820 updateLoyaltyListeningMedia(LoyaltyEventType.STOP); 4821 } 4822 player.stop(); 4823 } 4824 4825 player.setVolume(player_volume); 4826 4827 if (/* adblock_active */false) { 4828 $(".adblock_warning").slideDown(); 4829 } else { 4830 $(".adblock_warning").slideUp(); 4831 mustLoginToListenCurrentStation = active_station.has_forced_login == "1" && (!logged_in_member || logged_in_member.isGuest); 4832 if (mustLoginToListenCurrentStation) { 4833 toggle_member(active_station.forced_login_sub_title); 4834 } else if (skip_ad) { 4835 debug("CALLING PLAY!"); 4836 player_preroll_in_progress = false;
4837 player.play({ 4838 station: active_station.mount, 4839 connectionType: 'hdAlternate', 4840 connectionTimeOut: 30, 4841 timeShift: false, 4842 trackingParameters: player_targeting_parameters 4843 }); 4844 updateLoyaltyListeningMedia(LoyaltyEventType.PLAY, true); 4845 // Note: TriggeredPlaying() is called automatically every 60 seconds via startPlayerListenTimer() 4846 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 4847 if (!is_mobile() && is_debug) { 4848 show_temp_interstitial_ad(); 4849 } 4850 listening_start_time = (new Date()).getTime(); 4851 console.timeLog("Player Until Play", "player_play_active_station", "skip_ad"); 4852 return true; 4853 } else { 4854 playAd(); 4855 player.play({ 4856 station: active_station.mount, 4857 connectionType: 'hdAlternate', 4858 connectionTimeOut: 30, 4859 timeShift: false, 4860 trackingParameters: player_targeting_parameters 4861 }); 4862 updateLoyaltyListeningMedia(LoyaltyEventType.PLAY, true); 4863 if (videoAdRun) { 4864 setVolume(0); 4865 } 4866 /*$.ajax({ 4867 // TODO: URL Should be taken from a constant 4868 url: "https://handlers.karnaval.com/v6/mobile.functions.php", 4869 dataType: "jsonp", 4870 type: "POST", 4871 data: { 4872 "command": "get_preroll_to_show", 4873 "station_id": active_station.id 4874 }, 4875 timeout: 7500, 4876 success: function (response) { 4877 // console.log("mustLoginToListenCurrentStation ajax success", response); 4878 4879 debug(response); 4880 try { 4881 if (response == null || $.isEmptyObject(response) || !response.result || $.isEmptyObject(response.data)) { 4882 debug("Could not find anything local"); 4883 player_preroll_in_progress = true; 4884 try { 4885 $("#player audio,#player video").prop("volume", player_volume); 4886 } catch (e) { 4887 } 4888 // if (typeof (google) === "undefined") 4889 player.play({ 4890 station: active_station.mount, 4891 connectionType: 'hdAlternate', 4892 connectionTimeOut: 30, 4893 timeShift: false, 4894 trackingParameters: player_targeting_parameters 4895 }); 4896 4897 listening_start_time = (new Date()).getTime(); 4898 show_temp_interstitial_ad(); 4899 return false; 4900 } else { 4901 if (response.data.type == "vast") { 4902 debug("Calling triton player vast"); 4903 player_active_preroll = response.data; 4904 debug(response.data); 4905 player_preroll_in_progress = true; 4906 try { 4907 $("#player audio,#player video").prop("volume", player_volume); 4908 } catch (e) { 4909 } 4910 //player.playAd("vastAd",{ url:"https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/58225273/Karnaval_Preroll&ciu_szs=640x480&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dnonlinear&correlator=",volume:player_volume}); 4911 player.playAd("vastAd", {url: player_active_preroll.code, volume: player_volume}); 4912 } else if (response.data.type == "local") { 4913 player_active_preroll = response.data; 4914 debug("Calling triton player for local"); 4915 player_preroll_in_progress = true; 4916 player.playAd("vastAd", { 4917 url: "https://handlers.karnaval.com/karnaval.functions.php?command=getPrerollVast&key=" + player_active_preroll.cookie_key + "&station_id=" + active_station.id 4918 }); 4919 setTimeout(prerollPlayerMuteToggle, 1500); 4920 } 4921 } 4922 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 4923 listening_start_time = (new Date()).getTime(); 4924 console.timeLog("Player Until Play", "player_play_active_station", "get_preroll_to_show"); 4925 } catch (ex) { 4926 show_temp_interstitial_ad(); 4927 debug(ex); 4928 } 4929 }, 4930 error: function (a, b, c) { 4931 console.log("mustLoginToListenCurrentStation ajax error", a, b, c); 4932 4933 debug("Local Preroll Error"); 4934 debug(a); 4935 debug(b); 4936 debug(c); 4937 player_preroll_in_progress = true; 4938 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 4939 listening_start_time = (new Date()).getTime(); 4940 track_event("Karnaval v6 Player", "Local Preroll Error", "Active Station:" + active_station.mount); 4941 player.playAd("vastAd", {sid: active_station.vast_id, volume: player_volume}); 4942 show_temp_interstitial_ad(); 4943 } 4944 });*/ 4945 } 4946 } 4947} 4948 4949var interstitialSlot; 4950var interstitialObserver; // global reference so we can disconnect it later 4951 4952function playAd() { 4953 window.googletag = window.googletag || {cmd: []}; 4954 googletag.cmd.push(function () { 4955 if (interstitialSlot) { 4956 googletag.destroySlots([interstitialSlot]); 4957 } else { 4958 googletag.pubads().addEventListener("slotRenderEnded",
4958(event) => { 4959 if (event.slot === interstitialSlot && event.isEmpty == false) { 4960 4961 // Show interstitial UI 4962 document.body.style.overflowY = 'hidden'; 4963 document.getElementById("interstitial-wrapper").classList.add('active'); 4964 4965 // Add close button 4966 var closeButton = document.createElement('div'); 4967 closeButton.id = 'intclose'; 4968 closeButton.classList.add('interstitial-close'); 4969 4970 let countdownSeconds = 8; // set the countdown time in seconds 4971 closeButton.innerText = `${countdownSeconds}`; 4972 closeButton.style.pointerEvents = 'none'; // disable click initially 4973 closeButton.style.opacity = '0.6'; // visually indicate it's disabled 4974 closeButton.style.removeProperty('background-image'); // remove background image 4975 4976 // Countdown interval 4977 var countdownInterval = setInterval(function () { 4978 countdownSeconds--; 4979 if (countdownSeconds > 0) { 4980 closeButton.innerText = `${countdownSeconds}`; 4981 } else { 4982 closeButton.innerText = ""; 4983 clearInterval(countdownInterval); 4984 closeButton.style.backgroundImage = 'url(static/assets/v6/styles/images/close-btn.png)'; 4985 closeButton.style.pointerEvents = 'auto'; // enable click 4986 closeButton.style.opacity = '1'; 4987 } 4988 }, 1000); 4989 4990 // Click handler (only works when enabled) 4991 closeButton.onclick = function () { 4992 if (countdownSeconds <= 0) { 4993 closeInterstitial(); 4994 videoAdRun = false; 4995 setVolume(player_volume * 100); 4996 } 4997 }; 4998 4999 document.getElementById("div-for-interstitialslot").append(closeButton); 5000 } 5001 }); 5002 } 5003 5004 let resolutions; 5005 5006 if (is_mobile()) { 5007 resolutions = [[300, 250], [480, 320]] 5008 } else { 5009 resolutions = [[800, 600], [640, 480], [640, 360]]; 5010 } 5011 interstitialSlot = googletag.defineSlot( 5012 '/58225273/Karnaval_Web_InterstitialV2', 5013 resolutions, 5014 'div-for-interstitialslot' 5015 ) 5016 .addService(googletag.pubads()) 5017 // .setTargeting('dev_mode', 1) 5018 .setTargeting('active_player', active_player); 5019 setActiveStationTargeting(active_station); 5020 5021 googletag.enableServices(); 5022 googletag.display('div-for-interstitialslot'); 5023 }); 5024} 5025 5026// Creating observer to catch ad div setted as active. 5027function observerForGoogleVideoAdTarget() { 5028 const googleVideoAdTarget = document.getElementById('interstitial-wrapper'); 5029 const tritonAdTarget = document.getElementById('player_companion_banner'); 5030 if (googleVideoAdTarget) { 5031 const observer = new MutationObserver(function (mutations) { 5032 mutations.forEach(function (mutation) { 5033 if (mutation.type === "attributes" && mutation.attributeName === "class") { 5034 if (googleVideoAdTarget.classList.contains('active')) { 5035 googleAdIframeVideo(); 5036 } 5037 } 5038 }); 5039 }); 5040 5041 observer.observe(googleVideoAdTarget, { 5042 attributes: true 5043 }); 5044 } 5045 if (tritonAdTarget) { 5046 const tritonObserver = new MutationObserver(function (mutations) { 5047 mutations.forEach(function (mutation) { 5048 if (mutation.type === 'childList') { 5049 document.getElementById('div-gpt-ad-138546854688-0').style.display = 5050 tritonAdTarget.childElementCount ? 'none' : 'block'; 5051 } 5052 }); 5053 }); 5054 5055 tritonObserver.observe(tritonAdTarget, { 5056 attributes: true, 5057 childList: true, 5058 subtree: true 5059 }); 5060 } 5061} 5062 5063function googleAdIframeVideo() { 5064 const iframe = $("#div-for-interstitialslot iframe");
5065 var iframeContent = iframe.contents(); 5066 if (iframe.length) { 5067 const limaVideoTag = iframeContent.find('lima-video'); 5068 videoAdRun = true; 5069 if (!limaVideoTag.length) { 5070 setTimeout(() => { 5071 googleAdIframeVideo() 5072 }, 500); 5073 return; 5074 } 5075 5076 iframeContent.find('lima-video').on('playing', function () { 5077 setVolume(0); 5078 this.muted = false; 5079 this.volume = 1; 5080 }); 5081 5082 iframeContent.find('lima-video').on('ended', function () { 5083 setVolume(player_volume * 100); 5084 closeInterstitial(); 5085 videoAdRun = false; 5086 }); 5087 5088 // If ads it already played set volume in here 5089 setTimeout(() => { 5090 setVolume(0); 5091 limaVideoTag[0].muted = false; 5092 limaVideoTag[0].volume = 1; 5093 }, 500); 5094 // Setting time out because there is a timer for closing ad modal. 5095 // After 5 seconds we accept that video ad watched. 5096 // Because there is a close button available on ad modal. 5097 setTimeout(() => { 5098 videoAdRun = false; 5099 }, 5000); 5100 setTimeout(() => { 5101 setVolume(0); 5102 }, 2000); 5103 } 5104} 5105 5106function closeInterstitial() { 5107 document.body.style.overflowY = 'unset'; 5108 document.getElementById("interstitial-wrapper").classList.remove('active'); 5109 googletag.destroySlots([interstitialSlot]); 5110 document.getElementById("div-for-interstitialslot").innerHTML = ''; 5111 interstitialSlot = null; 5112 5113 // Disconnect observer 5114 if (interstitialObserver) interstitialObserver.disconnect(); 5115} 5116 5117function player_play_active_station_old(skip_ad) { 5118 if (typeof skip_ad === "undefined") 5119 skip_ad = false; 5120 if (is_mobile() || is_tablet() || active_station.has_preroll == "0") 5121 skip_ad = true; 5122 5123 $(".preroll_container").removeClass("active"); 5124 //player_active_preroll = null; 5125 5126 player_switch("RADIO"); 5127 clearTimeout(player_change_timeout); 5128 5129 debug(player_status); 5130 if (player_status != "STOPPED") 5131 player.stop(); 5132 5133 5134 player.setVolume(player_volume); 5135 if (skip_ad || adblock_active) { 5136 debug("CALLING PLAY!"); 5137 player_preroll_in_progress = false; 5138 player.play({ 5139 station: active_station.mount, 5140 connectionType: 'hdAlternate', 5141 connectionTimeOut: 30, 5142 timeShift: false, 5143 trackingParameters: player_targeting_parameters 5144 }); 5145 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 5146 return true; 5147 } 5148 $.ajax({ 5149 url: "https://handlers.karnaval.com/v5/api.functions.php", 5150 dataType: "jsonp", 5151 type: "POST", 5152 data: { 5153 "command": "get_preroll_to_show" 5154 , "station_id": active_station.id 5155 }, 5156 timeout: 7500, 5157 success: function (response) { 5158 debug(response); 5159 try { 5160 if (response == null || $.isEmptyObject(response) || !response.result || $.isEmptyObject(response.data)) { 5161 debug("Could not find anything local"); 5162 player_preroll_in_progress = true; 5163 try { 5164 $("#player audio,#player video").prop("volume", player_volume); 5165 } catch (e) { 5166 } 5167 player.playAd("vastAd", {sid: active_station.vast_id, volume: player_volume}); 5168 return false; 5169 } else { 5170 if (response.data.type == "vast") { 5171 debug("Calling triton player vast"); 5172 player_active_preroll = response.data; 5173 debug(response.data); 5174 player_preroll_in_progress = true; 5175 try { 5176 $("#player audio,#player video").prop("volume", player_volume); 5177 } catch (e) { 5178 } 5179 player.playAd("vastAd", {url: player_active_preroll.code, volume: player_volume}); 5180 } else if (response.data.type == "local") { 5181 player_active_preroll = response.data; 5182 debug("Calling triton player for local"); 5183 player_preroll_in_progress = true; 5184 try { 5185 $("#player audio,#player video").prop("volume", player_volume); 5186 } catch (e) { 5187 } 5188 player.playAd("vastAd", { 5189 url: "https://handlers.karnaval.com/karnaval.functions.php?command=getPrerollVast&key=" + player_active_preroll.cookie_key + "&station_id=" + active_station.id, 5190 volume: player_volume 5191 }); 5192 } 5193 } 5194 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 5195 } catch (ex) { 5196 debug(ex); 5197 } 5198 }, 5199 error: function (a, b, c) { 5200 debug("Local Preroll Error"); 5201 debug(a); 5202 debug(b); 5203 debug(c); 5204 player_preroll_in_progress = true; 5205 track_event("Karnaval v6 Player", "Play", "Active Station:" + active_station.mount); 5206 track_event("Karnaval v6 Player", "Local Preroll Error", "Active Station:" + active_station.mount); 5207 player.playAd("vastAd", {sid: active_station.vast_id, volume: player_volume}); 5208 } 5209 }); 5210} 5211 5212function player_get_current_song(station_id) { 5213 if (typeof station_id === "undefined") 5214 station_id = "all"; 5215
5216 k_ajax("/functions/v6/api.functions.php", 5217 { 5218 "command": "get_current_song", 5219 "station_id": station_id, 5220 "platform": "web", 5221 "v": "5" 5222 }, 5223 function (response) { 5224 if (response.result === true) { 5225 CURRENT_SONG_INFO = response.data; 5226 player_set_current_track(response.data); 5227 console.timeLog("Player Until Play", "player_get_current_song") 5228 } 5229 } 5230 ); 5231} 5232 5233function player_play_podcast_last_episode(show_id, ga_event_data) { 5234 if (typeof shows["show_" + show_id] !== "undefined" && shows["show_" + show_id] != null && shows["show_" + show_id].last_episode_id != null) { 5235 return player_play_podcast_episode(shows["show_" + show_id].last_episode_id, ga_event_data); 5236 } 5237 5238 return false; 5239} 5240 5241var play_ad = true; 5242 5243async function player_play_podcast_episode(episode_id, ga_event_data) { 5244 if (!defaultStationPlayed) defaultStationPlayed = true; 5245 // Stop timer for previous episode/station before switching (no request sent if stopped before 60 seconds) 5246 if (current_loyalty_listening_media && current_loyalty_listening_media.status !== LoyaltyStatus.STOPPED) { 5247 updateLoyaltyListeningMedia(LoyaltyEventType.STOP, true); 5248 } 5249 player.stop(); // This added because within the new UI, the player state doesn't reach my scripts. 5250 updatePlayButton(true); 5251 $(".footer-player .player-content .player-center").css("flex", "4"); 5252 $(".footer-player #podcastSection").css("display", "flex"); 5253 $(".footer-player #radioSection").css("display", "none"); 5254 $('#playButton').css('display', 'none'); 5255 $('#podcastSection #stopButton').css('display', 'flex'); 5256 // $('#pauseButton').css('display', 'flex'); 5257 5258 $('#podcastSection').css('display', 'flex'); 5259 if (isMobile()) { 5260 // $('#mobileActionPlayPodcast').css('display', 'none'); 5261 $('#mobileActionPausePodcast').css('display', 'flex'); 5262 } 5263 $(".adblock_warning").slideUp(); 5264 if (typeof (ga_event_data) !== "undefined") { 5265 track_event(ga_event_data.category, ga_event_data.action, ga_event_data.label); 5266 } 5267 5268 if (!podcast_triggered) { 5269 podcast_player = soundManager.createSound({ 5270 id: 'podcast_player', 5271 url: sound_manager_url_sound_file, 5272 useHTML5Audio: true, 5273 volume: player_volume * 100, 5274 }); 5275 safePlayPodcastPlayer({ 5276 onplay: function () { 5277 } 5278 , onpause: function () { 5279 } 5280 , onresume: function () { 5281 } 5282 , whileplaying: function () { 5283 $(".podcast-progress").css('width', ((this.position / this.duration) * 100) + '%'); 5284 } 5285 , whileloading: function () { 5286 //todo: add loader animation here until playing sound 5287 }, 5288 onfinish: function () { 5289 $(".podcast-progress").css('width', '0'); 5290 } 5291 }); 5292 5293 podcast_triggered = true; 5294 } 5295 var post_data = {}; 5296 post_data.command = "get_show_episode"; 5297 post_data.episode_id = episode_id; 5298 5299 const selectedPodcast = await fetchEpisodeById(episode_id); 5300 if (selectedPodcast && selectedPodcast.data && selectedPodcast.statusCode === 200) { 5301 try { 5302 debug(selectedPodcast); 5303 player_current_podcast = selectedPodcast.data; 5304 active_show = player_current_podcast.Show; 5305 5306 var resume_position_ms = 0; 5307 if (pending_resume_episode_id === player_current_podcast.id && pending_resume_position > 0) { 5308 resume_position_ms = pending_resume_position * 1000; 5309 } 5310 pending_resume_episode_id = null; 5311 pending_resume_position = 0; 5312 last_saved_podcast_position = Math.floor(resume_position_ms / 1000); 5313 5314 k_ajax_async("/functions/v6/api.functions.php", { 5315 "command": "set_active_podcast_episode", 5316 "episode_id": player_current_podcast.id, 5317 "position": last_saved_podcast_position 5318 }); 5319 5320 var current_track = { 5321 is_podcast: true, 5322 episode_id: player_current_podcast.id, 5323 show_id: player_current_podcast.showId, 5324 title: player_current_podcast.title, 5325 artist: active_show.subtitle, 5326 biography_image_16_9: active_show.thumbnailImageUrl, 5327 url_share: `${url_root}/programlar/${active_show.sanitizedUrl}`, 5328 show: active_show, 5329 url: `/programlar/${active_show.sanitizedUrl}`, 5330 }; 5331 5332 if (!$('#podcast_timers').length) 5333 $('.progress_container').before('<div id="podcast_timers" style="display: flex;font-size: 9px;justify-content: space-between;
5333height: 12px;"><p id="podcast_current_time"></p><p id="podcast_total_time"></p></div>'); 5334 $("#podcast_total_time").html(player_current_podcast.duration); 5335 5336 player_switch("PODCAST"); 5337 $(".station_logo_container img").attr("src", "" + active_show.thumbnailImageUrl + ""); // TODO url_player_logo field will be replaced. 5338 $(".station_logo_container a").attr("href", "" + current_track.url + ""); 5339 if (podcast_player != null) 5340 podcast_player.destruct(); 5341 5342 var playUrl = player_current_podcast.mediaUrlOmny != null ? player_current_podcast.mediaUrlOmny : player_current_podcast.mediaUrlOmny; 5343 podcast_player = soundManager.createSound({ 5344 id: 'podcast_player', 5345 url: playUrl, 5346 useHTML5Audio: true, 5347 volume: player_volume * 100, 5348 whileplaying: function () { 5349 $(".podcast-progress").css('width', ((this.position / this.duration) * 100) + '%'); 5350 }, 5351 onfinish: function () { 5352 $(".podcast-progress").css('width', '0'); 5353 }, 5354 }); 5355 5356 player_set_current_track(current_track); 5357 play_ad = active_show.has_ads != 0; 5358 if (play_ad) { 5359 playAd(); 5360 } 5361 safePlayPodcastPlayer({ 5362 position: resume_position_ms, 5363 onplay: function () { 5364 if (resume_position_ms > 0) { 5365 try { podcast_player.setPosition(resume_position_ms); } catch (e) { debug(e, "error"); } 5366 } 5367 updateLoyaltyListeningMedia(LoyaltyEventType.PLAY, true); 5368 player_status = "PLAYING"; 5369 player_update_ui(); 5370 pause_article_videos(); 5371 omnyStudioTracker.createSession(); 5372 player_mute($('#volumeSlider').val()); 5373 } 5374 , onpause: function () { 5375 player_status = "PAUSED"; 5376 $(".list_item_episode").removeClass("active"); 5377 player_update_ui(); 5378 omnyStudioTracker.createEvent("Stop"); 5379 } 5380 , onresume: function () { 5381 player_status = "PLAYING"; 5382 player_update_ui(); 5383 pause_article_videos(); 5384 omnyStudioTracker.createEvent("Start"); 5385 } 5386 , whileplaying: function () { 5387 player_status = "PLAYING"; 5388 player_update_ui(); 5389 if (!player_progress_is_dragging) { 5390 var progress = (this.position) > 0 ? (100 * this.position / this.duration) : 0; 5391 $(".player_container .progress_container").slider('value', progress); 5392 //this.position is the current seconds from milliseconds 5393 totalMsPodcastTime = this.duration; 5394 var seconds = Math.floor(this.position / 1000); 5395 if (seconds > 0 && Math.abs(seconds - last_saved_podcast_position) >= 5) { 5396 last_saved_podcast_position = seconds; 5397 k_ajax_async("/functions/v6/api.functions.php", { 5398 "command": "set_podcast_position", 5399 "position": seconds 5400 }); 5401 } 5402 $("#podcast_current_time").html(String(Math.floor(seconds / 60)).padStart(2, '0') + ":" + String(seconds % 60).padStart(2, '0')); 5403 Number.isNaN((this.position / this.duration) * 100) ? $("#podcastProgress").val(0) : $("#podcastProgress").val((this.position / this.duration) * 100).css("background", "linear-gradient(to right, #EB2027 " + ((this.position / this.duration) * 100) + "%, #949494 0%)"); 5404 5405 // Mini Player 5406 $("#podcast-slider-container").attr('style', 'display: block ;') 5407 5408 // Full player 5409 // document.getElementById("footer-player").classList.contains("footer-player-expanded") 5410 // ? $("#podcastSectionFullPlayer").attr('style', 'display: block !important;') 5411 // : $("#podcastSectionFullPlayer").attr('style', 'display: none !important;'); 5412 document.getElementById('podcastSectionFullPlayer').style.display = 5413 isPlayerExpanded 5414 ? $("#podcastSectionFullPlayer").attr('style', 'display: block !important;') 5415 : $("#podcastSectionFullPlayer").attr('style', 'display: none !important;'); 5416 5417 document.getElementById('podcastSectionFullPlayerMobile').style.display = 5418 isPlayerExpanded 5419 ? $("#podcastSectionFullPlayerMobile").attr('style', 'display: block !important;') 5420 : $("#podcastSectionFullPlayerMobile").attr('style', 'display: none !important;'); 5421 5422 Number.isNaN((this.position / this.duration) * 100) ? $("#podcastProgressFullPlayer").val(0) : $("#podcastProgressFullPlayer").val((this.position / this.duration) * 100).css("background", "linear-gradient(to right, #EB2027 " + ((this.position / this.duration) * 100) + "%, #949494 0%)"); 5423 Number.isNaN((this.position / this.duration) * 100) ? $("#podcastProgressFullPlayerMobile").val(0) : $("#podcastProgressFullPlayerMobile").val((this.position / this.duration) * 100).css("background", "linear-gradient(to right, #EB2027 " + ((this.position / this.duration) * 100) + "%, #949494 0%)"); 5424 $(".podcastTimer").html(String(Math.floor(seconds / 60)).padStart(2, '0') + ":" + String(seconds % 60).padStart(2, '0') + " / " + formatTime(this.duration)); 5425 // Full player 5426 $(".podcastTimerFullPlayer").html(String(Math.floor(seconds / 60)).padStart(2, '0') + ":" + String(seconds % 60).padStart(2, '0') + " / " + formatTime(this.duration)); 5427 } 5428 } 5429 , whileloading: function () { 5430 if (active_player != "PODCAST") 5431 return; 5432 var widthToSet = 100 * this.bytesLoaded / this.bytesTotal; 5433 5434 if (widthToSet > 98) 5435 widthToSet = 100; 5436 5437 player_current_podcast.total_loaded = widthToSet; 5438 } 5439 , onfinish: function () { 5440 updateLoyaltyListeningMedia(LoyaltyEventType.STOP, true); 5441 omnyStudioTracker.createEvent("Stop", podcast_player.duration); 5442 last_saved_podcast_position = 0;
5443 k_ajax_async("/functions/v6/api.functions.php", { 5444 "command": "set_podcast_position", 5445 "position": 0 5446 }); 5447 player_next(); 5448 } 5449 , onstop: function () { 5450 omnyStudioTracker.createEvent("Stop"); 5451 } 5452 , onerror: function () { 5453 debug("podcast player error"); 5454 } 5455 }); 5456 5457 if (play_ad) { 5458 show_temp_interstitial_ad(); 5459 if (videoAdRun) { 5460 setVolume(0); 5461 } 5462 } 5463 updateFullPlayerPodcastUIElements("PLAYING"); 5464 if (player_current_podcast) { 5465 const eventTitle = "PlayPodcast"; 5466 const contentType = "Podcast"; 5467 const contentDetail = { 5468 show_id: player_current_podcast.showId, 5469 sanitized_url: active_show.sanitizedUrl, 5470 episode_id: player_current_podcast.id 5471 } 5472 pushEventToDataLayer(eventTitle, contentType, contentDetail); 5473 } 5474 } catch (exception) { 5475 debug(exception, "error"); 5476 } 5477 } 5478} 5479 5480function restore_last_played_podcast() { 5481 if (active_player !== "PODCAST" || !player_current_podcast) return; 5482 5483 active_show = player_current_podcast.Show || {}; 5484 5485 $(".footer-player .player-content .player-center").css("flex", "4"); 5486 $(".footer-player #podcastSection").css("display", "flex"); 5487 $(".footer-player #radioSection").css("display", "none"); 5488 $('#podcastSection').css('display', 'flex'); 5489 $('#playButton').css('display', 'flex'); 5490 $('#podcastSection #stopButton').css('display', 'none'); 5491 if (isMobile()) { 5492 $('#mobileActionPlayPodcast').css('display', 'flex'); 5493 $('#mobileActionPausePodcast').css('display', 'none'); 5494 } 5495 5496 var current_track = { 5497 is_podcast: true, 5498 episode_id: player_current_podcast.id, 5499 show_id: player_current_podcast.showId, 5500 title: player_current_podcast.title, 5501 artist: active_show.subtitle, 5502 biography_image_16_9: active_show.thumbnailImageUrl, 5503 url_share: `${url_root}/programlar/${active_show.sanitizedUrl}`, 5504 show: active_show, 5505 url: `/programlar/${active_show.sanitizedUrl}`, 5506 }; 5507 5508 if (!$('#podcast_timers').length) 5509 $('.progress_container').before('<div id="podcast_timers" style="display: flex;font-size: 9px;justify-content: space-between;height: 12px;"><p id="podcast_current_time"></p><p id="podcast_total_time"></p></div>'); 5510 $("#podcast_total_time").html(player_current_podcast.duration); 5511 5512 player_switch("PODCAST"); 5513 $(".station_logo_container img").attr("src", "" + active_show.thumbnailImageUrl + ""); 5514 $(".station_logo_container a").attr("href", "" + current_track.url + ""); 5515 5516 player_set_current_track(current_track); 5517 5518 if (restored_podcast_position > 0) { 5519 pending_resume_episode_id = player_current_podcast.id; 5520 pending_resume_position = restored_podcast_position; 5521 } 5522} 5523 5524var omnyStudioTracker = { 5525 organizationId: "5af088d6-01f8-4b3d-b372-acb600f45df6", 5526 session: [], 5527 sessionId: null, 5528 createSession: function () { 5529 if (this.session != null && this.session.length > 0) { 5530 omnyStudioTracker.sendEvent(this.session); 5531 } 5532 5533 this.session = []; 5534 this.sessionId = this.generateGuid(); 5535 this.session.push({ 5536 "OrganizationId": this.organizationId, 5537 "ClipId": this.getClipIdFromUrl(podcast_player.options.url), 5538 "SessionId": this.sessionId, 5539 "Type": "Start", 5540 "Position": 0, 5541 "SeqNumber": 1, 5542 "Timestamp": parseInt(new Date().getTime() / 1000) 5543 }); 5544 }, 5545 createEvent: function (type, position) { 5546 this.session.push({ 5547 "OrganizationId": this.organizationId, 5548 "ClipId": this.getClipIdFromUrl(podcast_player.options.url), 5549 "SessionId": this.sessionId, 5550 "Type": type, 5551 "Position": ((position ? position : podcast_player.position) / 1000).toFixed(3), 5552 "SeqNumber": this.session.length + 1, 5553 "Timestamp": parseInt(new Date().getTime() / 1000) 5554 }); 5555 }, 5556 generateGuid: function () { 5557 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 5558 var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); 5559 return v.toString(16); 5560 }); 5561 }, 5562 getClipIdFromUrl: function (url) { 5563 var podcastUrl = url; 5564 var clipIdFinishIndex = podcastUrl.indexOf("/audio.mp3?"); 5565 var clipId = podcastUrl.substr(0, clipIdFinishIndex); 5566 var clipIdStartIndex = clipId.lastIndexOf("/"); 5567 return clipId.substr(clipIdStartIndex + 1); 5568 }, 5569 sendEvent: function (session) { 5570 var sessionEvent = { 5571 "Source": "Web", 5572 "Events": session, 5573 "Completed": true 5574 }; 5575 //console.log("Omny Data:" + JSON.stringify(sessionEvent)); 5576 $.ajax({ 5577 url: "https://traffic.omny.fm/api/consumption/events?organizationId=" + omnyStudioTracker.organizationId, 5578 type: "POST", 5579 data: JSON.stringify(sessionEvent), 5580 dataType: "json", 5581 success: function (data) { 5582 //console.log("omny consumption event send succeeded : " + JSON.stringify(data)); 5583 }, 5584 error: function (request, error) { 5585 console.log("omny consumption event send failed : " + JSON.stringify(request) + " : " + error); 5586 updateMiniPlayerPlayingButtons(); 5587 } 5588 }); 5589 } 5590}; 5591 5592function player_toggle_share() { 5593 $(".player_container .share_container").fadeToggle(); 5594 $(".player_container .action.action_share").toggleClass("active"); 5595 5596 if ($(".player_container .action.action_share").hasClass("active")) { 5597 if (active_player == "PODCAST") 5598 track_event("Karnaval v6 Podcast Player", "Toggle Share", "Active Station:" + active_station.mount); 5599 else 5600 track_event("Karnaval v6 Player", "Toggle Share", "Active Station:" + active_station.mount); 5601 } 5602} 5603 5604function player_toggle_next_track() { 5605 $(".player_container .track_container").toggleClass("show_next_track"); 5606} 5607 5608function player_animate_track_titles() { 5609 $(".player_container").each(function (index, player_container) { 5610 5611 var title = $(".track_container .track.current .title > span", $(player_container)); 5612 var sub_title = $(".track_container .track.current .sub_title > span", $(player_container)); 5613 5614 var parent = $(title).parent(); 5615 var title_animation_duration = (title.width() * 2.5 / 100); 5616 var sub_title_animation_duration = (sub_title.width() * 3.5 / 100); 5617 5618 if (title.width() < parent.width() + 10) { 5619 debug("removing animation from title in container: " + index); 5620 $(title).css("animation", ""); 5621 } else { 5622 debug("adding animation to title in container: " + index); 5623 $(title).css("animation", "title_animation " + title_animation_duration + "s linear infinite"); 5624 } 5625 5626 if (sub_title.width() < parent.width() + 10) { 5627 debug("removing animation from sub title in container: " + index); 5628 $(sub_title).css("animation", ""); 5629 } else { 5630 debug("adding animation to sub title in container: " + index); 5631 $(sub_title).css("animation", "title_animation " + sub_title_animation_duration + "s linear 2s infinite"); 5632 } 5633 }); 5634} 5635 5636function player_mute(value = 100) { 5637 if (value) { 5638 if (active_player == "PODCAST" && podcast_player != null) { 5639 podcast_player.setVolume(value); 5640 if (value == "1" || value == 0 || value == 1) { 5641 podcast_player.setVolume(0); 5642 return null; 5643 } 5644 } else { 5645 if (player_status === "STOPPED") { 5646 return null; 5647 } 5648 if (value == "1" || value == 0 || value == 1) { 5649 player.setVolume(value == 0 ? 1 : value / 10000000); 5650 return null; 5651 } 5652 player.setVolume(value / 100); 5653 } 5654 } 5655 5656 track_event("Karnaval v6 Player", "Mute", "Active Station:" + active_station.mount); 5657} 5658 5659function player_update_songs() { 5660 if (typeof player_song_update_timeout !== "undefined" && player_song_update_timeout != null) 5661 clearTimeout(player_song_update_timeout); 5662
5663 k_ajax("/functions/v6/api.functions.php", 5664 {"command": "get_current_song", "station_id": "all", "lastVersion": lastReceivedVersion}, 5665 function (response) { 5666 debug(response); 5667 if (response.result === true) { 5668 if (response.lastVersion) { 5669 lastReceivedVersion = response.lastVersion; 5670 } 5671 5672 notification_list = response.notifications; 5673 if (notification_list != "" && notification_list[0]["is_active"] == 1) { 5674 if (typeof notification_list !== "undefined" && notification_list != "") { 5675 var station_to_select = "station_" + notification_list[0]["station_id"]; 5676 if (typeof stations[station_to_select] !== "undefined" && stations[station_to_select] != "") { 5677 show_notification(notification_list[0]); 5678 } 5679 } 5680 } 5681 5682 current_song_list = response.data; 5683 $.each(response.data, function (station_key, current_song) { 5684 if (typeof stations[station_key] !== "undefined") { 5685 var station_id = station_key.replace("station_", ""); 5686 if (active_player == "RADIO" && player_status != "STOPPED" && station_id == active_station.id) { 5687 //TODO: do something but don't update it. 5688 } else { 5689 stations[station_key].current_song = current_song; 5690 let stationSelector = ".player_container .list_item_station[data-station_id=" + station_id + "]"; 5691 let stationTitleSelector = stationSelector + " .title"; 5692 let stationSubtitleSelector = stationSelector + " .sub_title"; 5693 $(stationTitleSelector).html(current_song.title); 5694 $(stationTitleSelector).prop('title', current_song.title); 5695 $(stationSubtitleSelector).html(current_song.artist); 5696 $(stationSubtitleSelector).prop('title', current_song.artist); 5697 5698 let stationPageSelector = ".stations_page .list_item_station[data-station_id=" + station_id + "]"; 5699 $(stationPageSelector + " .biography_image_container").css("background-image", "url(" + current_song.biography_image_mobile + ")"); 5700 let stationPageTitleSelector = stationPageSelector + " .title strong"; 5701 const stationPageTitleElem = $(stationPageTitleSelector); 5702 stationPageTitleElem.html(current_song.title); 5703 stationPageTitleElem.prop('title', current_song.title); 5704 5705 let stationPageSubtitleSelector = stationPageSelector + " .sub_title"; 5706 const stationPageSubtitleElem = $(stationPageSubtitleSelector); 5707 stationPageSubtitleElem.html(current_song.artist); 5708 stationPageSubtitleElem.prop('title', current_song.artist); 5709 5710 let stationPageOverlayTitleSelector = stationPageSelector + " .station_overlay_title"; 5711 const stationPageOverlayTitleElem = $(stationPageOverlayTitleSelector); 5712 stationPageOverlayTitleElem.html(current_song.title); 5713 stationPageOverlayTitleElem.prop('title', current_song.artist); 5714 5715 $(".stations_page .list_item_station[data-station_id=" + station_id + "] .station_overlay_sub_itle").html(current_song.artist); 5716 5717 current_song.position = Math.round((current_song.progress * current_song.duration_sec) / 100); 5718 const songProgressElem = $(stationPageSelector + " .song_progress_container"); 5719 songProgressElem.data("duration", current_song.duration_sec).attr("data-duration", current_song.duration_sec); 5720 songProgressElem.data("position", current_song.position).attr("data-position", current_song.position); 5721 } 5722 } 5723 }); 5724 } 5725 player_song_update_timeout = setTimeout(function () { 5726 player_update_songs(); 5727 }, 60000); 5728 }, 5729 function (messages) { 5730 debug(messages); 5731 player_song_update_timeout = setTimeout(function () { 5732 player_update_songs(); 5733 }, 60000); 5734 } 5735 ); 5736} 5737 5738function toggle_player() { 5739 $("section.player_container").toggleClass("open"); 5740 if ($("section.player_container").hasClass("open")) { 5741 $("html,body").addClass("body_fixed").addClass("player_open").scrollTop(0); 5742 } else { 5743 $("html,body").removeClass("body_fixed").removeClass("player_open"); 5744 toggle_player_companion(); 5745 } 5746} 5747 5748function toggle_player_companion(to_toggle, skip_scroll) { 5749 var close_all = false;
5750 5751 if (typeof to_toggle === "undefined" || to_toggle == null) { 5752 close_all = true; 5753 to_toggle = ""; //to prevent undefined exceptions. 5754 } 5755 if (typeof skip_scroll === "undefined") { 5756 skip_scroll = false; 5757 } 5758 5759 5760 if ($(".track_toggle_container .toggle_button_" + to_toggle).hasClass("disabled")) 5761 return false; 5762 5763 var remove = $(".track_toggle_container .toggle_button_" + to_toggle).hasClass("active"); 5764 5765 $(".track_toggle_container .toggle_button").removeClass("active"); 5766 $(".player_companion_container .player_companion").removeClass("active").slideUp(); 5767 5768 var scroll_container = $(".player_container .scroll_container"); 5769 var track_toggle_container = $(".player_container .scroll_container .track_toggle_container"); 5770 5771 var scroll_position = 0; 5772 if (!close_all) { 5773 if (!remove) { 5774 $(".track_toggle_container .toggle_button_" + to_toggle).addClass("active"); 5775 $(".player_companion_container .player_companion_" + to_toggle).addClass("active").slideDown(); 5776 //$(".station_list_container").slideUp(); 5777 5778 scroll_position = track_toggle_container.position().top + $(".site_header").height() - 40; 5779 } 5780 5781 track_event("Karnaval v6 Player", "Toggle Companion", "Container:" + to_toggle + " - Active Station:" + active_station.mount); 5782 } 5783 if (skip_scroll) 5784 return; 5785 //else $(".station_list_container").slideDown(); 5786 if ($(".player_container .action_toggle.hide_on_desktop").is(":visible")) { 5787 } 5788} 5789 5790function toggle_player_lists(to_toggle, is_sub, to_sub_toggle) { 5791 var player_companion_height = 0; 5792 if ($(".player_companion.active").length > 0) { 5793 player_companion_height + $(".player_companion.active").height(); 5794 } 5795 5796 toggle_player_companion(null, true); 5797 5798 $(".player_toggle_container .toggle_button").removeClass("active"); 5799 $(".player_container .player_list_container").removeClass("active"); 5800 $(".player_container .sub_toggle_container .sub_toggle_item").removeClass("active"); 5801 $(".player_container .player_list_container .list_wrapper .list").removeClass("active"); 5802 $(".sub_toggle_container .sub_toggle_" + to_toggle + " a").removeClass("active"); 5803 $(".player_container .player_list_container_" + to_toggle + " .list_wrapper .list").removeClass("active"); 5804 5805 $(".player_toggle_container .toggle_button_" + to_toggle).addClass("active"); 5806 $(".player_container .player_list_container_" + to_toggle).addClass("active"); 5807 $(".player_container .sub_toggle_container .sub_toggle_" + to_toggle).addClass("active"); 5808 $(".player_container .player_list_container_" + to_toggle + " .list_wrapper:first-child .list").addClass("active"); 5809 $(".sub_toggle_container .sub_toggle_" + to_toggle + " a:first-child").addClass("active"); 5810 if (to_toggle == "stations") $(".player_container .list_" + to_toggle).addClass("active"); 5811 5812 if ($(".player_container .action_toggle.hide_on_desktop").is(":visible")) { 5813 $("html,body").animate({"scrollTop": scroll_position}, 600); 5814 } 5815 if (to_toggle === 'stations') { 5816 $("#radioLeft").attr('style', 'color: white !important;'); 5817 $("#podcastLeft").attr('style', 'color: black !important;'); 5818 $("#favoritesLeft").attr('style', 'color: black !important;'); 5819 $('#favoritesLeftDisplayId').attr('style', 'display: none !important;'); 5820 } else if (to_toggle === 'shows') { 5821 $("#radioLeft").attr('style', 'color: black !important;'); 5822 $("#podcastLeft").attr('style', 'color: white !important;'); 5823 $("#favoritesLeft").attr('style', 'color: black !important;'); 5824 $('#favoritesLeftDisplayId').attr('style', 'display: none !important;'); 5825 } else if (to_toggle === 'playlists') { 5826 $("#radioLeft").attr('style', 'color: black !important;'); 5827 $("#podcastLeft").attr('style', 'color: black !important;'); 5828 $("#favoritesLeft").attr('style', 'color: white !important;'); 5829 let loggedInStyle = logged_in_member ? 'padding-left: 9px' : 'align-items: center !important;'; 5830 $('#favoritesLeftDisplayId').attr('style', 'display: flex !important; flex-direction: column !important; ' + loggedInStyle); 5831 } 5832 track_event("Karnaval v6 Player", "Toggle Player List", "List:" + to_toggle + " - Active Station:" + active_station.mount); 5833} 5834 5835function toggle_player_sub_lists(type, to_toggle) { 5836 5837 $(".sub_toggle_container .sub_toggle_" + type + " .toggle_button_" + type + "_items").removeClass("active"); 5838 $(".player_container .player_list_container_" + type + " .list_wrapper .list_" + type).removeClass("active"); 5839 $(".sub_toggle_container .sub_toggle_" + type + " .toggle_button_" + type + "_items.sub_item_" + to_toggle).addClass("active"); 5840 $(".player_container .player_list_container_" + type + " .list_wrapper ." + type + "_" + to_toggle).addClass("active"); 5841 5842 track_event("Karnaval v6 Player", "Toggle Player Sub List", "List:" + type + " " + to_toggle + " - Active Station:" + active_station.mount); 5843} 5844 5845function scroll_player_to_top() { 5846 if (!has_active_ldr_show) { 5847 var scroll_container = $(".player_container .scroll_container"); 5848 scroll_container.animate({"scrollTop": 0}, 600);
5849 if ($(".player_container .action_toggle.hide_on_desktop").is(":visible")) { 5850 $("html,body").animate({"scrollTop": 0}, 600); 5851 } 5852 } else { 5853 debug("no scroll!"); 5854 } 5855} 5856 5857/*tab check*/ 5858function check_tabs() { 5859 if (player_tab_check_timeout != null) 5860 clearTimeout(player_tab_check_timeout); 5861 5862 5863 if (player_status == "PLAYING" && active_player == "RADIO") { 5864 try { 5865 if (localStorage.getItem("active_player_tab") != random_tab_player_key) { 5866 debug("Player active on another tab! Calling stop!"); 5867 player_stop(); 5868 } 5869 player_tab_check_timeout = setTimeout(function () { 5870 check_tabs(); 5871 }, 5000); 5872 } catch (exception) { 5873 debug("Localstorage not supported!", true); 5874 return false; 5875 } 5876 } 5877 5878 player_tab_check_timeout = setTimeout(function () { 5879 check_tabs(); 5880 }, 5000); 5881} 5882 5883function set_player_status() { 5884 if (player_status == "PLAYING") { 5885 try { 5886 localStorage.setItem("active_player_tab", random_tab_player_key); 5887 check_tabs(); 5888 } catch (exception) { 5889 debug("Localstorage not supported!"); 5890 if (player_tab_check_timeout != null) 5891 clearTimeout(player_tab_check_timeout); 5892 } 5893 } else { 5894 if (player_tab_check_timeout != null) 5895 clearTimeout(player_tab_check_timeout); 5896 } 5897} 5898 5899/*tab check*/ 5900function player_select_station_from_notification(to_select) { 5901 var station_to_select = "station_" + to_select; 5902 if (stations[station_to_select] !== "undefined" && stations[station_to_select] != "") { 5903 player_select_station(to_select); 5904 } 5905 hide_notification(); 5906} 5907 5908function change_frequency_station(station_id) { 5909 var count = 0; 5910 $('.site_menu select.city_list').find('option').remove(); 5911 $(".site_menu .station_frequency_container .content span").remove(); 5912 $.each(stations, function (index, station) { 5913 if (station["frequencies"] != "" && station.id == station_id) { 5914 5915 $.each(station["frequencies"], function (index, freq) { 5916 $('.site_menu select.city_list').append("<option value='" + freq.city_code + "' data-frequency='" + freq.frequency + "'>" + freq.city_name + "</option>"); 5917 $("<span class='' data-city_code='" + freq.city_code + "'>" + freq.frequency + " FM</span>").insertBefore(".site_menu .station_frequency_container .content .clear"); 5918 count++; 5919 }); 5920 } 5921 }); 5922 $('.site_menu select.city_list').trigger("change"); 5923} 5924 5925function show_temp_interstitial_ad() { 5926 if (!shouldShowAds()) { 5927 return; 5928 } 5929 if (!is_mobile() && !$(".temp_interstitial_ad").is(":visible")) { 5930 if ($('#div-gpt-ad-1680678340942-0 > div').html() != "" && $('#div-gpt-ad-1680678340942-0 > div').html() != null) { 5931 $(".temp_interstitial_ad").show(); 5932 $('#div-gpt-ad-1680678340942-0').show(); 5933 } 5934 5935 if ($('#div-gpt-ad-1692096286258-0 > div').html() != "" && $('#div-gpt-ad-1692096286258-0 > div').html() != null) { 5936 $(".temp_interstitial_ad").show(); 5937 $('#div-gpt-ad-1692096286258-0').show(); 5938 } 5939 } 5940} 5941 5942function show_temp_interstitial_ad_old() { 5943 5944 if (!is_mobile() && !$(".temp_interstitial_ad").is(":visible")) { 5945 $.ajax({ 5946 url: "/functions/v6/api.functions.php" 5947 , data: "command=check_interstitial_cookie" 5948 , type: "POST" 5949 , dataType: "json" 5950 , success: function (response) { 5951 if (response.result == true && response.data.key != "" && response.data.url != "") { 5952 track_event("Karnaval v6 800x600", "Loaded", response.data.key); 5953 $(".temp_interstitial_ad .temp_inner").html(response.data.url); 5954 $(".temp_interstitial_ad").show(); 5955 k_ajax("/functions/v6/api.functions.php" 5956 , {"command": "set_interstitial_cookie", "key": response.data.key} 5957 ); 5958 } 5959 } 5960 , error: function (error) { 5961 console.log(error); 5962 } 5963 }); 5964 } 5965} 5966 5967async function player_download_podcast_episode(show_id, episode_id) { 5968 track_event("Karnaval v6", "Podcast Download", "Show ID:" + show_id + " Episode ID:" + episode_id); 5969 window.open("https://karnaval.com/download.php?is_podcast=true&show_id=" + show_id + "&episode_id=" + episode_id) 5970 const eventTitle = "DownloadedPodcast"; 5971 const contentType = "Podcast"; 5972 let sanitized_url = (current_show && current_show.id === show_id) ? current_show.sanitizedUrl : ''; 5973 if (sanitized_url === '') { 5974 const foundShow = await podcastService.getPodcastById(show_id); 5975 if (foundShow && foundShow.data) { 5976 const showData = Show.from(foundShow.data); 5977 sanitized_url = showData.sanitizedUrl; 5978 } 5979 } 5980 const contentDetail = {show_id, sanitized_url, episode_id}; 5981 pushEventToDataLayer(eventTitle, contentType, contentDetail); 5982} 5983 5984/*EOF PLAYER*/ 5985function select_region(region) { 5986 if (region == "turkey") 5987 window.location.href = "https://karnaval.com?bypass_autoredirect=true"; 5988 else if (region == "europe") 5989 window.location.href = "https://de.karnaval.com?bypass_autoredirect=true"; 5990} 5991 5992function check_cookie_message() { 5993} 5994 5995function close_cookie_message() { 5996 $(".cookie_message_container").slideUp(function () { 5997 $(".cookie_message_container").remove() 5998 });
5999 k_ajax("/functions/v6/api.functions.php", {"command": "close_cookie_message"}, function (response) { 6000 6001 }, function (messages) { 6002 }); 6003} 6004 6005function initialize_lazyload_images() { 6006 var lazyImages = document.querySelectorAll(".lazy"); 6007 lazyImages.forEach(function (img) { 6008 if (img.getBoundingClientRect().top < window.innerHeight && img.getAttribute("data-src")) { 6009 if (img.tagName != "IMG"/* && img.style.backgroundImage == "" */) { 6010 img.style.backgroundImage = 'url("' + img.getAttribute("data-src") + '")'; 6011 } else { 6012 img.src = img.getAttribute("data-src"); 6013 } 6014 img.removeAttribute("data-src"); 6015 img.style.opacity = 1; 6016 } 6017 }); 6018} 6019 6020function getActivePageName() { 6021 let activePage = $("#main_section").data("page_url"); 6022 6023 if (activePage.includes('ilber-ortayli')) { 6024 activePage = activePage.replace('programlar/', ''); 6025 } 6026 6027 return activePage; 6028} 6029 6030function safePlayPodcastPlayer(options = {}) { 6031 if (!podcast_player) return false; 6032 if (typeof podcast_player.play === "function") { 6033 podcast_player.play(options); 6034 return true; 6035 } 6036 console.error("An error occurred while playing the podcast player", podcast_player); 6037 return false; 6038} 6039 6040function shouldShowAds() { 6041 let activePage = getActivePageName(); 6042 6043 let pagesWithoutAds = [ 6044 'ilber-ortayli', 6045 'literalradio', 6046 'odearadyo', 6047 'yatirim-odakli-podcast', 6048 'nabiz-tavan' 6049 6050 ]; 6051 6052 if (pagesWithoutAds.some(page => activePage.includes(page))) { 6053 return false; 6054 } 6055 6056 return true; 6057} 6058 6059const initPlayer = () => { 6060 if (active_player == "RADIO") { 6061 $(".footer-player .player-content .player-center #podcastSection").css("display", "none"); 6062 $("#podcastSection").css("display", "none"); 6063 $('#pauseButton').css('display', 'none'); 6064 $(".footer-player .player-content .player-center #radioSection").css("display", "flex"); 6065 } else { 6066 $(".footer-player .player-content .player-center #podcastSection").css("display", "flex"); 6067 $('#radioSection').css('display', 'none'); 6068 $(".footer-player .player-content .player-center #radioSection").css("display", "none"); 6069 if (player_status === "PLAYING") { 6070 $('#playButton').css('display', 'none'); 6071 $('#podcastSection #stopButton').css('display', 'flex'); 6072 $('#podcastSection').css('display', 'flex'); 6073 $('#pauseButton').css('display', 'flex'); 6074 } else { 6075 $('#playButton').css('display', 'flex'); 6076 $('#podcastSection #stopButton').css('display', 'none'); 6077 $('#pauseButton').css('display', 'none'); 6078 } 6079 } 6080} 6081 6082async function homepageLeftSectionFavoritesRenderer() { 6083 let myFavDiv = document.getElementsByClassName("userLoggedInFav")[0] 6084 const logged_in_member_in_fav = logged_in_member; 6085 if (typeof logged_in_member_in_fav === 'undefined' || logged_in_member_in_fav === null || (typeof logged_in_member_in_fav.favorite_stations == 'undefined' || !logged_in_member_in_fav.favorite_stations.length) && (typeof logged_in_member_in_fav.favorite_shows == 'undefined' || !logged_in_member_in_fav.favorite_shows.length)) { 6086 myFavDiv.innerHTML = ` 6087 <div> 6088 <div style="margin-top: 26px;margin-bottom: 26px;"> 6089 <!-- SVG icons go here --> 6090 </div> 6091 <div style="display: flex;flex-direction: column;justify-content: center;align-items: center"> 6092 <div> 6093 <svg xmlns="http://www.w3.org/2000/svg" width="23" height="22" viewBox="0 0 23 22" fill="none"> 6094 <path d="M4.81055 21.4414C4.60872 21.2917 4.48503 21.0898 4.43945 20.8359C4.40039 20.582 4.44271 20.2793 4.56641 19.9277L6.60742 13.8535L1.39258 10.1035C1.08659 9.88867 0.875 9.66732 0.757812 9.43945C0.640625 9.21159 0.621094 8.97721 0.699219 8.73633C0.777344 8.50195 0.930339 8.32617 1.1582 8.20898C1.38607 8.0918 1.6888 8.03646 2.06641 8.04297L8.46289 8.08203L10.4062 1.97852C10.5234 1.62044 10.6699 1.35026 10.8457 1.16797C11.028 0.985677 11.2428 0.894531 11.4902 0.894531C11.7441 0.894531 11.959 0.985677 12.1348 1.16797C12.3171 1.35026 12.4668 1.62044 12.584 1.97852L14.5273 8.08203L20.9238 8.04297C21.3014 8.03646 21.6042 8.0918 21.832 8.20898C22.0599 8.32617 22.2129 8.50195 22.291 8.73633C22.3691 8.97721 22.3496 9.21159 22.2324 9.43945C22.1152 9.66732 21.9036 9.88867 21.5977 10.
60941035L16.3828 13.8535L18.4238 19.9277C18.5475 20.2793 18.5866 20.582 18.541 20.8359C18.502 21.0898 18.3815 21.2917 18.1797 21.4414C17.9779 21.5977 17.75 21.6497 17.4961 21.5977C17.2422 21.5521 16.9655 21.4219 16.666 21.207L11.4902 17.4082L6.32422 21.207C6.02474 21.4219 5.74805 21.5521 5.49414 21.5977C5.24023 21.6497 5.01237 21.5977 4.81055 21.4414Z" fill="url(#paint0_linear_1653_13951)"/> 6095 <defs> 6096 <linearGradient id="paint0_linear_1653_13951" x1="17.4015" y1="-30.1212" x2="49.0808" y2="6.22398" gradientUnits="userSpaceOnUse"> 6097 <stop stop-color="#FF0000"/> 6098 <stop offset="1" stop-color="#B10000"/> 6099 </linearGradient> 6100 </defs> 6101 </svg> 6102 </div> 6103 <div style="margin-bottom: 16px;margin-top: 16px;"> 6104 <span class="favTextClass">Favori içerikler burada görünür.</span> 6105 </div> 6106 <div style="width: 283px;display: flex"> 6107 <span class="favBottomTextClass"> En sevdiÄin radyo ve podcastlere daha hızlı ulaÅmak için <span class="lastFavBottomTextClass"> hemen favorilerine ekle.</span></span> 6108 </div> 6109 </div> 6110 </div> 6111 `; 6112 return myFavDiv 6113 } 6114 6115 let loggedIn = ` 6116 <div> 6117 <div style="color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; margin-top: 12px; font-style: normal; font-weight: 400; line-height: normal; display: flex; 6118 justify-content: space-between;"> 6119 <div>Favori Radyolar</div> 6120 <a href="/favorilerim" style=" color: red; margin-right: 16px;" > Düzenle</a> 6121 </div> 6122 </div> 6123 `; 6124 if (!logged_in_member_in_fav?.favorite_stations?.length) { 6125 loggedIn += ` 6126 <div class="notRadioPodcastFavText" style="margin-bottom: 74px;margin-top: 8px;"> 6127 Henüz hiçbir radyoyu favorilemedin. 6128 </div> 6129 `; 6130 } else { 6131 let radioCount = 0; 6132 /** @var {StationMinified} favoriteStation **/ 6133 for (let favoriteStation of logged_in_member_in_fav.favorite_stations) { 6134 const thumbnailUrlFileAssociation = favoriteStation.FileAssociations.find(item => item.category === 'android_default_logo'); 6135 let favoriteStationImage = thumbnailUrlFileAssociation?.file.url || defaultPlaceHolderImage; 6136 favoriteStationImage = buildVersionedMediaImageUrl(favoriteStationImage); 6137 let subTitleValue = favoriteStation.slogan || ''; 6138 let superTitleValue = favoriteStation.title || ''; 6139 let artistName = subTitleValue || superTitleValue; 6140 let title = favoriteStation.shortDescription || ''; 6141 let formattedTitle = title.replace(/_/g, ' ') // Replace underscores with spaces 6142 .toLowerCase() // Convert the string to lower case 6143 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6144 return letter.toUpperCase(); 6145 }); 6146 let titleElement = ''; 6147 6148 if (title) { 6149 let tag = 'span'; 6150 let titleContent = formattedTitle.length > 17 ? `${formattedTitle.substring(0, 17)}...` : formattedTitle; 6151 titleElement = formattedTitle.length > 17 6152 ? `<div class='title tooltipLeft' style='font-size: 12px;font-weight: 510; color: #474747;'>${titleContent}<${tag} class='tooltiptext'>${formattedTitle}</${tag}></div>` 6153 : `<${tag} class='title' style='font-size: 12px;font-weight: 510; color: #474747;'>${titleContent}</${tag}>`; 6154 } 6155 6156 let subTitleElement = ''; 6157 if (artistName) { 6158 let tag = 'span'; 6159 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6160 subTitleElement = artistName.length > 17 6161 ? `<div class='sub_title tooltipLeft' style='font-size: 12px;font-weight: 400; color: #949494;'>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` 6162 : `<${tag} class='sub_title' style='font-size: 12px;font-weight: 400; color: #949494;'>${subTitleContent}</${tag}>`; 6163 } 6164 6165 loggedIn += ` 6166 <li class='list_item leftSideSectionLiFavoritesRadio' id='leftSideSectionLiFavoritesRadio' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-bottom: -10px;margin-top: 4px' onClick="player_select_station(${favoriteStation.id}, '', ${radioCount})"> 6167 <figure class='thumb_container' style='border-radius:10px; z-index:99999;'> 6168 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoriteStationImage}' alt='${formattedTitle}'> 6169 </figure> 6170 <div class='title_container' style='padding: 0px; z-index:99999; display: flex; flex-direction: column;position: relative; left: -32px;flex: 1;'>
6171 <span class='super_title' style='color: var(--Grayscale-Black, #0A0A0A); leading-trim: both; text-edge: cap; font-size: 16px; font-style: normal; font-weight: 510; line-height: normal; width: 120%'>${superTitleValue}</span> 6172 ${titleElement} 6173 ${subTitleElement} 6174 </div> 6175 <div class='action_bar outside_section_play_fav_radio' style='padding-right: 16px;'> 6176 <a class="action action_play" id="fav_play_radio_${radioCount}" href="javascript:;" onClick="player_select_station(${favoriteStation.id}, '', ${radioCount})"> 6177 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none"> 6178 <path id="player_play_fav_radio_${radioCount}"d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="white"/> 6179 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6180 <defs> 6181 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6182 <stop stop-color="#FF0000"/> 6183 <stop offset="1" stop-color="#B10000"/> 6184 </linearGradient> 6185 </defs> 6186 </svg> 6187 </a> 6188 </div> 6189 </li> 6190 `; 6191 radioCount++; 6192 } 6193 } 6194 6195 loggedIn += ` 6196 <div> 6197 <div style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal; margin-top: 20px;'> 6198 Favori Podcastlar 6199 </div> 6200 </div> 6201 `; 6202 6203 if (!logged_in_member_in_fav?.favorite_shows?.length) { 6204 loggedIn += ` 6205 <div class="notRadioPodcastFavText" style="margin-top: 8px"> 6206 Henüz hiçbir podcasti favorilemedin. 6207 </div> 6208 `; 6209 } else { 6210 let podcastCount = 0; 6211 /** @var {ShowMinified} favoriteShow **/ 6212 for (const favoriteShow of logged_in_member_in_fav.favorite_shows) { 6213 let found = false; 6214 6215 const thumbnailUrlFileAssociation = favoriteShow.FileAssociations.find(item => item.category === 'thumb_1000x1000'); 6216 let favoritesPodcastImage = thumbnailUrlFileAssociation?.file.url || defaultPlaceHolderImage; 6217 favoritesPodcastImage = buildVersionedMediaImageUrl(favoritesPodcastImage); 6218 let subTitleValue = favoriteShow.subtitle || ''; 6219 let superTitleValue = (favoriteShow.Podcast.length > 0) ? releaseDateFormatter(favoriteShow.Podcast[0].releaseDate) : ''; 6220 let artistName = subTitleValue || superTitleValue; 6221 let title = favoriteShow.title || ''; 6222 let formatted_title = title.replace(/_/g, ' ') // Replace underscores with spaces 6223 .toLowerCase() // Convert the string to lower case 6224 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6225 return letter.toUpperCase(); 6226 }); 6227 let titleEle = ''; 6228 let fontStyle1 = " style=''text-wrap:nowrap''"; 6229 6230 if (title) { 6231 let tag = 'span'; 6232 let formattedTitleSub = formatted_title.length > 17 ? `${formatted_title.substring(0, 17)}...` : formatted_title; 6233 let titleClass = ' super_title superTitlePodcast'; 6234 titleEle = formatted_title.length > 20 6235 ? `<div class='tooltipLeft ${titleClass}' ${fontStyle1}>${formattedTitleSub}<${tag} class='tooltiptext'>${formatted_title}</${tag}></div>` 6236 : `<${tag} class='${titleClass}'${fontStyle1}>${formatted_title}</${tag}>`; 6237 } 6238 6239 let subTitleElement = ''; 6240 if (artistName) { 6241 let tag = 'span'; 6242 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6243 subTitleElement = artistName.length > 17 6244 ? `<div class='sub_title titlePodcast tooltipLeft' ${fontStyle1}>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` 6245 : `<${tag} class='sub_title titlePodcast'${fontStyle1}>${subTitleContent}</${tag}>`; 6246 } 6247 6248 loggedIn += ` 6249 <li class='list_item leftSideSectionLiFavoritesPodcast' id='leftSideSectionLiFavoritesPodcast' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-top: 4px;' onClick="player_play_podcast_episode(${favoriteShow.Podcast[0].id})"> 6250 <figure class='thumb_container' style='border-radius:10px; z-index:99999;'> 6251 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoritesPodcastImage}' alt='${formatted_title}'> 6252 </figure> 6253 <div class='title_container' style='padding: 0px; z-index:99999; display: flex; flex-direction: column;position: relative; left: -32px;flex: 1;margin-right: -20px;'> 6254 ${titleEle} 6255 ${subTitleElement}
6256 <span class='sub_title' style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal;'>${superTitleValue}</span> 6257 </div> 6258 <div class='action_bar' style='display: block !important'> 6259 <a class="action action_play outside_section_play_podcast_fav" style="padding-right: 16px;" id="fav_play_podcast" href="javascript:;" onClick="player_play_podcast_episode(${favoriteShow.Podcast[0].id})"> 6260 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none"> 6261 <path id="player_play_podcast_fav_${podcastCount}" d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="white"/> 6262 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6263 <defs> 6264 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6265 <stop stop-color="#FF0000"/> 6266 <stop offset="1" stop-color="#B10000"/> 6267 </linearGradient> 6268 </defs> 6269 </svg> 6270 </a> 6271 </div> 6272 </li> 6273 `; 6274 found = true; 6275 podcastCount += 1; 6276 } 6277 } 6278 6279 loggedIn += ` 6280 <div> 6281 <div style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal; margin-top: 20px;'> 6282 Favori Episodelar 6283 </div> 6284 </div> 6285 `; 6286 6287 if (!logged_in_member_in_fav?.favorite_show_episodes?.length) { 6288 loggedIn += ` 6289 <div class="notRadioPodcastFavText" style="margin-top: 8px"> 6290 Henüz hiçbir podcast bölümü favorilemedin. 6291 </div> 6292 `; 6293 } else { 6294 let podcastEpisodeCount = 0; 6295 /** @var {PodcastMinified} favoriteEpisode **/ 6296 for (const favoriteEpisode of logged_in_member_in_fav.favorite_show_episodes) { 6297 let found = false; 6298 6299 let favoritesPodcastImage = favoriteEpisode.thumbnailImageUrl; 6300 if (!favoritesPodcastImage) { 6301 favoritesPodcastImage = favoriteEpisode.Show && favoriteEpisode.Show.FileAssociations.find(item => item.category === 'thumb_1000x1000'); 6302 favoritesPodcastImage = favoritesPodcastImage?.file.url || defaultPlaceHolderImage; 6303 } 6304 favoritesPodcastImage = buildVersionedMediaImageUrl(favoritesPodcastImage); 6305 6306 let superTitleValue = favoriteEpisode?.Show?.subtitle; 6307 let artistName = favoriteEpisode?.Show?.title; 6308 let title = favoriteEpisode.title; 6309 let formatted_title = title.replace(/_/g, ' ') // Replace underscores with spaces 6310 .toLowerCase() // Convert the string to lower case 6311 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6312 return letter.toUpperCase(); 6313 }); 6314 let titleEle = ''; 6315 let fontStyle1 = " style=''text-wrap:nowrap''"; 6316 6317 if (title) { 6318 let tag = 'span'; 6319 let formattedTitleSub = formatted_title.length > 17 ? `${formatted_title.substring(0, 17)}...` : formatted_title; 6320 let titleClass = ' super_title superTitlePodcast'; 6321 titleEle = formatted_title.length > 20 6322 ? `<div class='tooltipLeft ${titleClass}' ${fontStyle1}>${formattedTitleSub}<${tag} class='tooltiptext'>${formatted_title}</${tag}></div>` 6323 : `<${tag} class='${titleClass}'${fontStyle1}>${formatted_title}</${tag}>`; 6324 } 6325 6326 let subTitleElement = ''; 6327 if (artistName) { 6328 let tag = 'span'; 6329 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6330 subTitleElement = artistName.length > 17 6331 ? `<div class='sub_title titlePodcast tooltipLeft' ${fontStyle1}>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` 6332 : `<${tag} class='sub_title titlePodcast'${fontStyle1}>${subTitleContent}</${tag}>`; 6333 } 6334 6335 loggedIn += ` 6336 <li class='list_item leftSideSectionLiFavoritesPodcastEpisode' id='leftSideSectionLiFavoritesPodcastEpisode' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-top: 4px;' onClick="player_play_podcast_episode(${favoriteEpisode.id})"> 6337 <figure class='thumb_container' style='border-radius:10px; z-index:99999;'> 6338 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoritesPodcastImage}' alt='${formatted_title}'> 6339 </figure> 6340 <div class='title_container' style='padding: 0px; z-index:99999; display: flex; flex-direction: column;position: relative; left: -32px;flex: 1;margin-right: -20px;'> 6341 ${titleEle} 6342 ${subTitleElement}
6343 <span class='sub_title' style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal;'>${superTitleValue}</span> 6344 </div> 6345 <div class='action_bar' style='display: block !important'> 6346 <a class="action action_play outside_section_play_podcast_episode_fav" style="padding-right: 16px;" id="fav_play_podcast" href="javascript:;" onClick="player_play_podcast_episode(${favoriteEpisode.id})"> 6347 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none"> 6348 <path id="player_play_podcast_episode_fav_${podcastEpisodeCount}" d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="white"/> 6349 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6350 <defs> 6351 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6352 <stop stop-color="#FF0000"/> 6353 <stop offset="1" stop-color="#B10000"/> 6354 </linearGradient> 6355 </defs> 6356 </svg> 6357 </a> 6358 </div> 6359 </li> 6360 `; 6361 found = true; 6362 podcastEpisodeCount += 1; 6363 } 6364 } 6365 6366 setTimeout(() => { 6367 initFavStyles(); 6368 }, 1000) 6369 myFavDiv.innerHTML = loggedIn; 6370} 6371 6372function initFavStyles() { 6373 //fav podcast 6374 var leftSideLiSectionFavPodcast = document.querySelectorAll('.leftSideSectionLiFavoritesPodcast'); 6375 leftSideLiSectionFavPodcast.forEach(function (link, element) { 6376 link.addEventListener('mouseover', function () { 6377 document.getElementById('player_play_podcast_fav_' + element).style.setProperty('fill', '#C3C3C3', 'important'); 6378 }); 6379 6380 link.addEventListener('mouseout', function () { 6381 document.getElementById('player_play_podcast_fav_' + element).style.setProperty('fill', 'white', 'important'); 6382 }); 6383 }) 6384 6385 var linksFavPodcast = document.querySelectorAll('.outside_section_play_podcast_fav'); 6386 linksFavPodcast.forEach(function (link, element) { 6387 link.addEventListener('mouseover', function (event) { 6388 event.stopPropagation(); 6389 document.getElementById('player_play_podcast_fav_' + element).style.setProperty('fill', '#FF0000', 'important'); 6390 }); 6391 }); 6392 //fav Episodes 6393 var leftSideLiSectionFavPodcastEpisode = document.querySelectorAll('.leftSideSectionLiFavoritesPodcastEpisode'); 6394 leftSideLiSectionFavPodcastEpisode.forEach(function (link, element) { 6395 link.addEventListener('mouseover', function () { 6396 document.getElementById('player_play_podcast_episode_fav_' + element).style.setProperty('fill', '#C3C3C3', 'important'); 6397 }); 6398 6399 link.addEventListener('mouseout', function () { 6400 document.getElementById('player_play_podcast_episode_fav_' + element).style.setProperty('fill', 'white', 'important'); 6401 }); 6402 }) 6403 6404 var linksFavEpisode = document.querySelectorAll('.outside_section_play_podcast_episode_fav'); 6405 linksFavEpisode.forEach(function (link, element) { 6406 link.addEventListener('mouseover', function (event) { 6407 event.stopPropagation(); 6408 document.getElementById('player_play_podcast_episode_fav_' + element).style.setProperty('fill', '#FF0000', 'important'); 6409 }); 6410 }); 6411 //fav radio 6412 var leftSideLiSectionFavRadio = document.querySelectorAll('.leftSideSectionLiFavoritesRadio');
6413 leftSideLiSectionFavRadio.forEach(function (link, element) { 6414 link.addEventListener('mouseover', function () { 6415 document.getElementById('player_play_fav_radio_' + element).style.setProperty('fill', '#C3C3C3', 'important'); 6416 }); 6417 6418 link.addEventListener('mouseout', function () { 6419 document.getElementById('player_play_fav_radio_' + element).style.setProperty('fill', 'white', 'important'); 6420 }); 6421 }) 6422 6423 var linksFavRadio = document.querySelectorAll('.outside_section_play_fav_radio'); 6424 linksFavRadio.forEach(function (link, element) { 6425 link.addEventListener('mouseover', function (event) { 6426 event.stopPropagation(); 6427 document.getElementById('player_play_fav_radio_' + element).style.setProperty('fill', '#FF0000', 'important'); 6428 }); 6429 }); 6430} 6431 6432function checkIsStationFavorite() { 6433 let favoriteContents = (active_player === "RADIO" ? logged_in_member?.favorite_stations : logged_in_member?.favorite_shows) ?? []; 6434 let activePlayerId = active_player === "RADIO" ? active_station.id : active_show.id; 6435 return favoriteContents.some(favorite => Number(favorite.id) === Number(activePlayerId)); 6436} 6437 6438function isActiveFavorite() { 6439 let activeStationId = active_station.id; 6440 let activeShowId = active_show.id; 6441 is_active_player_favorite = checkIsStationFavorite(); 6442 6443 const podcastSection = document.getElementById('podcast-section-favorite-container'); 6444 const podcastSectionFull = document.getElementById('podcast-section-favorite-container-full'); 6445 const podcastSectionMobile = document.getElementById('radioFavoriteMobile'); 6446 6447 const radioSection = document.getElementById('radio-section-favorite-container'); 6448 const radioSectionFull = document.getElementById('radio-section-favorite-container-full'); 6449 6450 // PODCAST 6451 if (active_player === "PODCAST") { 6452 const podcastFavorite = document.getElementById('podcastFavorite'); 6453 const podcastFavoriteFull = document.getElementById('podcastFavoriteFull'); 6454 const podcastFavoriteMobile = document.getElementById('podcastFavoriteMobile'); 6455 6456 if (podcastSection) { 6457 podcastSection.classList.remove('hidden-button'); 6458 podcastSectionFull.classList.remove('hidden-button'); 6459 podcastSectionMobile.classList.remove('hidden-button-visibility'); 6460 6461 radioSection.classList.add('hidden-button'); 6462 radioSectionFull.classList.add('hidden-button'); 6463 podcastSectionMobile.classList.add('hidden-button-visibility'); 6464 } 6465 6466 if (is_active_player_favorite) { 6467 // Reduced 6468 $('#podcastFavorite').attr("onClick", "remove_from_favorite_shows_mvp(this," + activeShowId + ")"); 6469 podcastFavorite.innerHTML = ` 6470 <svg id="setFavoritePodcast" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6471 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#0A0A0A"/> 6472 </svg> 6473 `; 6474 6475 // Expanded 6476 if (isPlayerExpanded) { 6477 // Desktop 6478 $('#podcastFavoriteFull').attr("onClick", "remove_from_favorite_shows_mvp(this," + activeShowId + ")"); 6479 podcastFavoriteFull.innerHTML = ` 6480 <svg class="full-button" id="setFavoritePodcastFull" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6481 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7
6481739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#FCFCFC"/> 6482 </svg> 6483 `; 6484 // Mobile 6485 $('#podcastFavoriteMobile').attr("onClick", "remove_from_favorite_shows_mvp(this," + activeShowId + ")"); 6486 podcastFavoriteMobile.innerHTML = ` 6487 <svg id="setFavoritePodcastMobile" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6488 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#FCFCFC"/> 6489 </svg> 6490 `; 6491 } 6492 6493 6494 } else { 6495 // Reduced 6496 $('#podcastFavorite').attr("onClick", "add_to_favorite_shows_mvp(this," + activeShowId + ")"); 6497 podcastFavorite.innerHTML = ` 6498 <svg id="setFavoritePodcast" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6499 <path d="M16.4215 26.9975L20.5 24.5375L24.5784 27.0298L23.5102 22.3688L27.1031 19.2614L22.3773 18.8406L20.5 14.4385L18.6226 18.8082L13.8968 19.229L17.4897 22.3688L16.4215 26.9975ZM20.5 26.8207L15.4631 29.8582C15.2754 29.9678 15.0873 30.0139 14.8989 29.9964C14.7106 29.9789 14.5401 29.9155 14.3875 29.8061C14.2347 29.6964 14.1168 29.5533 14.0337 29.3765C13.9509 29.1998 13.9376 29.0043 13.9939 28.79L15.3311 23.0708L10.8843 19.2216C10.7181 19.0772 10.6123 18.91 10.5667 18.7199C10.521 18.5298 10.533 18.345 10.6027 18.1657C10.6724 17.9866 10.7728 17.8402 10.904 17.7265C11.0352 17.6128 11.2145 17.5384 11.442 17.5035L17.3104 16.9908L19.5888 11.5901C19.6717 11.3892 19.7974 11.2406 19.9659 11.1444C20.1344 11.0481 20.3125 11 20.5 11C20.6875 11 20.8655 11.0481 21.0341 11.1444C21.2026 11.2406 21.3283 11.3892 21.4111 11.5901L23.6896 16.9908L29.558 17.5035C29.7854 17.5384 29.9647 17.6128 30.0959 17.7265C30.2271 17.8402 30.3276 17.9866 30.3973 18.1657C30.467 18.345 30.479 18.5298 30.4332 18.7199C30.3877 18.91 30.2818 19.0772 30.1157 19.2216L25.6689 23.0708L27.006 28.79C27.0624 29.0043 27.0491 29.1998 26.9662 29.3765C26.8831 29.5533 26.7652 29.6964 26.6124 29.8061C26.4599 29.9155 26.2894 29.9789 26.101 29.9964C25.9126 30.0139 25.7246 29.9678 25.5368 29.8582L20.5 26.8207Z" fill="#636363"/> 6500 </svg> 6501 `; 6502 6503 // Expanded 6504 if (isPlayerExpanded) { 6505 // Desktop 6506 $('#podcastFavoriteFull').attr("onClick", "add_to_favorite_shows_mvp(this," + activeShowId + ")"); 6507 if (podcastFavoriteFull) { 6508 6509 podcastFavoriteFull.innerHTML = ` 6510 <svg class="full-button" id="setFavoritePodcastFull" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6511 <path id="" d="M16.422 26.9975L20.5005 24.5375L24.5789 27.0298L23.5107 22.3688L27.1036 19.2614L22.3778 18.8406L20.5005 14.4385L18.6231 18.8082L13.8973 19.229L17.4902 22.3688L16.422 26.9975ZM20.5005 26.8207L15.4636 29.8582C15.2759 29.9678 15.0878 30.0139 14.8994 29.9964C14.711 29.9789 14.5406 29.9155 14.388 29.8061C14.2352 29.6964 14.1173 29.5533 14.0342 29.3765C13.9514 29.1998 13.9381 29.0043 13.9944 28.79L15.3315 23.0708L10.8848 19.2216C10.7186 19.0772 10.6128 18.91 10.5672 18.7199C10.5215 18.5298 10.5335 18.345 10.6032 18.1657C10.6729 17.9866 10.7733 17.8402 10.9045 17.7265C11.0357 17.6128 11.215 17.5384 11.4425 17.5035L17.3109 16.9908L19.5893 11.5901C19.6722 11.3892 19.7978 11.2406 19.9664 11.1444C20.1349 11.0481 20.3129 11 20.5005 11C20.688 11 20.866 11.0481 21.0345 11.1444C21.2031 11.2406 21.3288 11.3892 21.4116 11.5901L23.69 16.9908L29.5584 17.5035C29.7859 17.5384 29.9652 17.6128 30.0964 17.7265C30.2276 17.8402 30.3281 17.9866 30.3978 18.1657C30.4675 18.345 30.4794 18.5298 30.4337 18.7199C30.3882 18.91 30.2823 19.0772 30.1162 19.2216L25.6694 23.0708L27.0065 28.79C27.0628 29.0043 27.0496 29.1998 26.9667 29.3765C26.8836 29.5533 26.7657 29.6964 26.6129 29.8061C26.4604 29.9155 26.2899 29.9789 26.1015 29.9964C25.9131 30.0139 25.7251 29.9678 25.5373 29.8582L20.5005 26.8207Z" fill="#949494"></path> 6512 </svg> 6513 `; 6514 } 6515 // Mobile 6516 $('#podcastFavoriteMobile').attr("onClick", "add_to_favorite_shows_mvp(this," + activeShowId + ")"); 6517 podcastFavoriteMobile.innerHTML = ` 6518 <svg id="setFavoritePodcastMobile" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6519 <path id="" d="M16.422 26.9975L20.5005 24.5375L24.5789 27.0298L23.5107 22.3688L27.1036 19.2614L22.3778 18.8406L20.5005 14.4385L18.6231 18.8082L13.8973 19.229L17.4902 22.3688L16.422 26.9975ZM20.5005 26.8207L15.4636 29.8582C15.2759 29.9678 15.0878 30.0139 14.8994 29.9964C14.711 29.9789 14.5406 29.9155 14.388 29.8061C14.2352 29.6964 14.1173 29.5533 14.0342 29.3765C13.9514 29.1998 13.9381 29.0043 13.9944 28.79L15.3315 23.0708L10.8848 19.2216C10.7186 19.0772 10.6128 18.91 10.5672 18.7199C10.5215 18.5298 10.5335 18.345 10.6032 18.1657C10.6729 17.9866 10.7733 17.8402 10.9045 17.7265C11.0357 17.6128 11.215 17.5384 11.4425 17.5035L17.3109 16.9908L19.5893 11.5901C19.6722 11.3892 19.7978 11.2406 19.9664 11.1444C20.1349 11.0481 20.3129 11 20.5005 11C20.688 11 20.866 11.0481 21.0345 11.1444C21.2031 11.2406 21.3288 11.3892 21.4116 11.5901L23.69 16.9908L29.5584 17.5035C29.7859 17.5384 29.9652 17.6128 30.0964 17.7265C30.2276 17.8402 30.3281 17.9866 30.3978 18.1657C30.4675 18.345 30.4794 18.5298 30.4337 18.7199C30.3882 18.91 30.2823 19.0772 30.1162 19.2216L25.6694 23.0708L27.0065 28.79C27.0628 29.0043 27.0496 29.1998 26.9667 29.3765C26.8836 29.5533 26.7657 29.6964 26.6129 29.8061C26.4604 29.9155 26.2899 29.9789 26.1015 29.9964C25.9131 30.0139 25.7251 29.9678 25.5373 29.8582L20.5005 26.8207Z" fill="#949494"></path> 6520 </svg> 6521 `; 6522 } 6523 } 6524 } 6525 6526 // RADIO 6527 else if (active_player === "RADIO") { 6528 const radioFavorite = document.getElementById('radioFavorite'); 6529 const radioFavoriteFull = document.getElementById('radioFavoriteFull'); 6530 const radioFavoriteMobile = document.getElementById('radioFavoriteMobile'); 6531 6532 if (radioSection) { 6533 podcastSection.classList.add('hidden-button'); 6534 podcastSectionFull.classList.add('hidden-button'); 6535 podcastSectionMobile.classList.add('hidden-button-visibility'); 6536 6537 radioSection.classList.remove('hidden-button'); 6538 radioSectionFull.classList.remove('hidden-button'); 6539 podcastSectionMobile.classList.remove('hidden-button-visibility'); 6540 } 6541 6542 if (is_active_player_favorite) { 6543 // Reduced 6544 $('#radioFavorite').attr("onClick", "remove_from_favorite_stations_mvp(this," + activeStationId + ")"); 6545 radioFavorite.innerHTML = ` 6546 <svg id="setFavoriteRadio" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6547 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7
6547739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#0A0A0A"/> 6548 </svg> 6549 `; 6550 6551 // Expanded 6552 if (isPlayerExpanded) { 6553 // Desktop 6554 $('#radioFavoriteFull').attr("onClick", "remove_from_favorite_stations_mvp(this," + activeStationId + ")"); 6555 radioFavoriteFull.innerHTML = ` 6556 <svg id="setFavoriteRadioFull" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6557 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#FCFCFC"/> 6558 </svg> 6559 `; 6560 // Mobile 6561 $('#radioFavoriteMobile').attr("onClick", "remove_from_favorite_stations_mvp(this," + activeStationId + ")"); 6562 radioFavoriteMobile.innerHTML = ` 6563 <svg id="setFavoriteRadioMobile" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6564 <path d="M20.4999 26.5797L15.932 29.3315C15.7302 29.4599 15.5192 29.5149 15.2991 29.4966C15.0789 29.4782 14.8863 29.4048 14.7212 29.2764C14.5561 29.148 14.4277 28.9875 14.336 28.7949C14.2442 28.6022 14.2259 28.3867 14.2809 28.1482L15.4917 22.9474L11.4466 19.4526C11.2632 19.2875 11.1485 19.0995 11.1026 18.8885C11.0568 18.6775 11.0705 18.4711 11.1439 18.2693C11.2173 18.0676 11.3274 17.9024 11.4741 17.774C11.6209 17.6456 11.8227 17.5631 12.0795 17.5264L17.4179 17.0586L19.4818 12.1604C19.5735 11.9403 19.7157 11.7752 19.9083 11.6651C20.1009 11.555 20.2981 11.5 20.4999 11.5C20.7017 11.5 20.8989 11.555 21.0915 11.6651C21.2842 11.7752 21.4263 11.9403 21.5181 12.1604L23.5819 17.0586L28.9203 17.5264C29.1772 17.5631 29.379 17.6456 29.5257 17.774C29.6725 17.9024 29.7825 18.0676 29.8559 18.2693C29.9293 18.4711 29.9431 18.6775 29.8972 18.8885C29.8513 19.0995 29.7367 19.2875 29.5532 19.4526L25.5081 22.9474L26.7189 28.1482C26.7739 28.3867 26.7556 28.6022 26.6639 28.7949C26.5722 28.9875 26.4437 29.148 26.2786 29.2764C26.1135 29.4048 25.9209 29.4782 25.7008 29.4966C25.4806 29.5149 25.2696 29.4599 25.0679 29.3315L20.4999 26.5797Z" fill="#FCFCFC"/> 6565 </svg> 6566 `; 6567 } 6568 6569 6570 } else { 6571 // Reduced 6572 $('#radioFavorite').attr("onClick", "add_to_favorite_stations_mvp(this," + activeStationId + ")"); 6573 radioFavorite.innerHTML = ` 6574 <svg id="setFavoriteRadio" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6575 <path d="M16.4215 26.9975L20.5 24.5375L24.5784 27.0298L23.5102 22.3688L27.1031 19.2614L22.3773 18.8406L20.5 14.4385L18.6226 18.8082L13.8968 19.229L17.4897 22.3688L16.4215 26.9975ZM20.5 26.8207L15.4631 29.8582C15.2754 29.9678 15.0873 30.0139 14.8989 29.9964C14.7106 29.9789 14.5401 29.9155 14.3875 29.8061C14.2347 29.6964 14.1168 29.5533 14.0337 29.3765C13.9509 29.1998 13.9376 29.0043 13.9939 28.79L15.3311 23.0708L10.8843 19.2216C10.7181 19.0772 10.6123 18.91 10.5667 18.7199C10.521 18.5298 10.533 18.345 10.6027 18.1657C10.6724 17.9866 10.7728 17.8402 10.904 17.7265C11.0352 17.6128 11.2145 17.5384 11.442 17.5035L17.3104 16.9908L19.5888 11.5901C19.6717 11.3892 19.7974 11.2406 19.9659 11.1444C20.1344 11.0481 20.3125 11 20.5 11C20.6875 11 20.8655 11.0481 21.0341 11.1444C21.2026 11.2406 21.3283 11.3892 21.4111 11.5901L23.6896 16.9908L29.558 17.5035C29.7854 17.5384 29.9647 17.6128 30.0959 17.7265C30.2271 17.8402 30.3276 17.9866 30.3973 18.1657C30.467 18.345 30.479 18.5298 30.4332 18.7199C30.3877 18.91 30.2818 19.0772 30.1157 19.2216L25.6689 23.0708L27.006 28.79C27.0624 29.0043 27.0491 29.1998 26.9662 29.3765C26.8831 29.5533 26.7652 29.6964 26.6124 29.8061C26.4599 29.9155 26.2894 29.9789 26.101 29.9964C25.9126 30.0139 25.7246 29.9678 25.5368 29.8582L20.5 26.8207Z" fill="#636363"/> 6576 </svg> 6577 `; 6578 6579 // Expanded 6580 if (isPlayerExpanded) { 6581 // Desktop 6582 $('#radioFavoriteFull').attr("onClick", "add_to_favorite_stations_mvp(this," + activeStationId + ")"); 6583 radioFavoriteFull.innerHTML = ` 6584 <svg id="setFavoriteRadioFull" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6585 <path id="setFavoriteRadioFull" d="M16.422 26.9975L20.5005 24.5375L24.5789 27.0298L23.5107 22.3688L27.1036 19.2614L22.3778 18.8406L20.5005 14.4385L18.6231 18.8082L13.8973 19.229L17.4902 22.3688L16.422 26.9975ZM20.5005 26.8207L15.4636 29.8582C15.2759 29.9678 15.0878 30.0139 14.8994 29.9964C14.711 29.9789 14.5406 29.9155 14.388 29.8061C14.2352 29.6964 14.1173 29.5533 14.0342 29.3765C13.9514 29.1998 13.9381 29.0043 13.9944 28.79L15.3315 23.0708L10.8848 19.2216C10.7186 19.0772 10.6128 18.91 10.5672 18.7199C10.5215 18.5298 10.5335 18.345 10.6032 18.1657C10.6729 17.9866 10.7733 17.8402 10.9045 17.7265C11.0357 17.6128 11.215 17.5384 11.4425 17.5035L17.3109 16.9908L19.5893 11.5901C19.6722 11.3892 19.7978 11.2406 19.9664 11.1444C20.1349 11.0481 20.3129 11 20.5005 11C20.688 11 20.866 11.0481 21.0345 11.1444C21.2031 11.2406 21.3288 11.3892 21.4116 11.5901L23.69 16.9908L29.5584 17.5035C29.7859 17.5384 29.9652 17.6128 30.0964 17.7265C30.2276 17.8402 30.3281 17.9866 30.3978 18.1657C30.4675 18.345 30.4794 18.5298 30.4337 18.7199C30.3882 18.91 30.2823 19.0772 30.1162 19.2216L25.6694 23.0708L27.0065 28.79C27.0628 29.0043 27.0496 29.1998 26.9667 29.3765C26.8836 29.5533 26.7657 29.6964 26.6129 29.8061C26.4604 29.9155 26.2899 29.9789 26.1015 29.9964C25.9131 30.0139 25.7251 29.9678 25.5373 29.8582L20.5005 26.8207Z" fill="#949494"></path> 6586 </svg> 6587 `; 6588 // Mobile 6589 $('#radioFavoriteMobile').attr("onClick", "add_to_favorite_stations_mvp(this," + activeStationId + ")"); 6590 radioFavoriteMobile.innerHTML = ` 6591 <svg id="setFavoriteRadioMobile" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 6592 <path id="setFavoriteRadioMobile" d="M16.422 26.9975L20.5005 24.5375L24.5789 27.0298L23.5107 22.3688L27.1036 19.2614L22.3778 18.8406L20.5005 14.4385L18.6231 18.8082L13.8973 19.229L17.4902 22.3688L16.422 26.9975ZM20.5005 26.8207L15.4636 29.8582C15.2759 29.9678 15.0878 30.0139 14.8994 29.9964C14.711 29.9789 14.5406 29.9155 14.388 29.8061C14.2352 29.6964 14.1173 29.5533 14.0342 29.3765C13.9514 29.1998 13.9381 29.0043 13.9944 28.79L15.3315 23.0708L10.8848 19.2216C10.7186 19.0772 10.6128 18.91 10.5672 18.7199C10.5215 18.5298 10.5335 18.345 10.6032 18.1657C10.6729 17.9866 10.7733 17.8402 10.9045 17.7265C11.0357 17.6128 11.215 17.5384 11.4425 17.5035L17.3109 16.9908L19.5893 11.5901C19.6722 11.3892 19.7978 11.2406 19.9664 11.1444C20.1349 11.0481 20.3129 11 20.5005 11C20.688 11 20.866 11.0481 21.0345 11.1444C21.2031 11.2406 21.3288 11.3892 21.4116 11.5901L23.69 16.9908L29.5584 17.5035C29.7859 17.5384 29.9652 17.6128 30.0964 17.7265C30.2276 17.8402 30.3281 17.9866 30.3978 18.1657C30.4675 18.345 30.4794 18.5298 30.4337 18.7199C30.3882 18.91 30.2823 19.0772 30.1162 19.2216L25.6694 23.0708L27.0065 28.79C27.0628 29.0043 27.0496 29.1998 26.9667 29.3765C26.8836 29.5533 26.7657 29.6964 26.6129 29.8061C26.4604 29.9155 26.2899 29.9789 26.1015 29.9964C25.9131 30.0139 25.7251 29.9678 25.5373 29.8582L20.5005 26.8207Z" fill="#949494"></path> 6593 </svg> 6594 `; 6595 } 6596 } 6597 } 6598} 6599 6600async function homepageLeftSectionFavoritesRendererMobile() { 6601 // Fixed this area and filled from new api' data 6602 let myFavDiv = document.getElementsByClassName("userLoggedInFavMobile")[0] 6603 const logged_in_member_in_fav = logged_in_member; 6604 6605 if (logged_in_member_in_fav?.favorite_stations && 6606 !logged_in_member_in_fav?.favorite_stations?.length && 6607 logged_in_member_in_fav?.favorite_shows && 6608 !logged_in_member_in_fav?.favorite_shows?.length) { 6609 myFavDiv.innerHTML = ` 6610 <div> 6611 <div style="margin-top: 26px;margin-bottom: 26px;"> 6612 <!-- SVG icons go here --> 6613 </div> 6614 <div style="display: flex;flex-direction: column;justify-content: center;align-items: center"> 6615 <div> 6616 <svg xmlns="http://www.w3.org/2000/svg" width="23" height="22" viewBox="0 0 23 22" fill="none"> 6617 <path d="M4.81055 21.4414C4.60872 21.2917 4.48503 21.0898 4.43945 20.8359C4.40039 20.582 4.44271 20.2793 4.56641 19.9277L6.60742 13.8535L1.39258 10.1035C1.08659 9.88867 0.875 9.66732 0.757812 9.43945C0.640625 9.21159 0.62
66171094 8.97721 0.699219 8.73633C0.777344 8.50195 0.930339 8.32617 1.1582 8.20898C1.38607 8.0918 1.6888 8.03646 2.06641 8.04297L8.46289 8.08203L10.4062 1.97852C10.5234 1.62044 10.6699 1.35026 10.8457 1.16797C11.028 0.985677 11.2428 0.894531 11.4902 0.894531C11.7441 0.894531 11.959 0.985677 12.1348 1.16797C12.3171 1.35026 12.4668 1.62044 12.584 1.97852L14.5273 8.08203L20.9238 8.04297C21.3014 8.03646 21.6042 8.0918 21.832 8.20898C22.0599 8.32617 22.2129 8.50195 22.291 8.73633C22.3691 8.97721 22.3496 9.21159 22.2324 9.43945C22.1152 9.66732 21.9036 9.88867 21.5977 10.1035L16.3828 13.8535L18.4238 19.9277C18.5475 20.2793 18.5866 20.582 18.541 20.8359C18.502 21.0898 18.3815 21.2917 18.1797 21.4414C17.9779 21.5977 17.75 21.6497 17.4961 21.5977C17.2422 21.5521 16.9655 21.4219 16.666 21.207L11.4902 17.4082L6.32422 21.207C6.02474 21.4219 5.74805 21.5521 5.49414 21.5977C5.24023 21.6497 5.01237 21.5977 4.81055 21.4414Z" fill="url(#paint0_linear_1653_13951)"/> 6618 <defs> 6619 <linearGradient id="paint0_linear_1653_13951" x1="17.4015" y1="-30.1212" x2="49.0808" y2="6.22398" gradientUnits="userSpaceOnUse"> 6620 <stop stop-color="#FF0000"/> 6621 <stop offset="1" stop-color="#B10000"/> 6622 </linearGradient> 6623 </defs> 6624 </svg> 6625 </div> 6626 <div style="margin-bottom: 16px;margin-top: 16px;"> 6627 <span class="favTextClass">Favori içerikler burada görünür.</span> 6628 </div> 6629 <div style="width: 283px;display: flex"> 6630 <span class="favBottomTextClass"> En sevdiÄin radyo ve podcastlere daha hızlı ulaÅmak için <span class="lastFavBottomTextClass"> hemen favorilerine ekle.</span></span> 6631 </div> 6632 </div> 6633 </div> 6634 `; 6635 } 6636 6637 let loggedIn = ` 6638 <div> 6639 <div style="color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; margin-top: 12px; font-style: normal; font-weight: 400; line-height: normal; display: flex; 6640 justify-content: space-between;"> 6641 <div>Favori Radyolar</div> 6642 <a href="/favorilerim" style=" color: red; margin-right: 16px;" > Düzenle</a> 6643 </div> 6644 </div> 6645 `; 6646 if (!logged_in_member_in_fav?.favorite_stations && 6647 !logged_in_member_in_fav?.favorite_stations?.length) { 6648 loggedIn += ` 6649 <div class="notRadioPodcastFavText" style="margin-bottom: 74px;margin-top: 8px;"> 6650 Henüz hiçbir radyoyu favorilemedin. 6651 </div> 6652 `; 6653 } else { 6654 let radioCount = 0; 6655 /** @var {StationMinified} favoriteStation **/ 6656 for (let favoriteStation of logged_in_member_in_fav?.favorite_stations) { 6657 const thumbnailUrlFileAssociation = favoriteStation.FileAssociations.find(item => item.category === 'android_default_logo'); 6658 let favoritesStationImage = thumbnailUrlFileAssociation?.file.url || defaultPlaceHolderImage; 6659 favoritesStationImage = buildVersionedMediaImageUrl(favoritesStationImage); 6660 let subTitleValue = favoriteStation.slogan || ''; 6661 let superTitleValue = favoriteStation.title || ''; 6662 let artistName = subTitleValue || superTitleValue; 6663 let title = favoriteStation.shortDescription || ''; 6664 6665 let formatted_title = title.replace(/_/g, ' ') // Replace underscores with spaces 6666 .toLowerCase() // Convert the string to lower case 6667 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6668 return letter.toUpperCase(); 6669 }); 6670 let titleElement = ''; 6671 6672 if (title) { 6673 let tag = 'span'; 6674 let titleContent = formatted_title.length > 17 ? `${formatted_title.substring(0, 17)}...` : formatted_title; 6675 titleElement = formatted_title.length > 17 ? `<div class='title tooltipLeft' style='font-size: 12px;font-weight: 510; color: #474747;'>${titleContent}<${tag} class='tooltiptext'>${formatted_title}</${tag}></div>` : `<${tag} class='title' style='font-size: 12px;font-weight: 510; color: #474747;'>${titleContent}</${tag}>`; 6676 } 6677 6678 let subTitleElement = ''; 6679 if (artistName) { 6680 let tag = 'span'; 6681 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6682 subTitleElement = artistName.length > 17 ? `<div class='sub_title tooltipLeft' style='font-size: 12px;font-weight: 400; color: #949494;'>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` : `<${tag} class='sub_title' style='font-size: 12px;font-weight: 400; color: #949494;'>${subTitleContent}</${tag}>`; 6683 } 6684 6685 loggedIn += ` 6686 <li class='list_item leftSideSectionLiFavoritesRadio' id='leftSideSectionLiFavoritesRadio' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-top: 4px; margin-bottom: -10px;' onClick="player_select_station(${favoriteStation.id}, '', ${radioCount})"> 6687 <figure class='thumb_container' style='border-radius:10px;'> 6688 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoritesStationImage}' alt='${formatted_title}'> 6689 </figure> 6690 <div class='title_container' style='padding: 0px; display: flex; flex-direction: column;position: relative; left: -32px;flex: 1;'>
6691 <span class='super_title' style='color: var(--Grayscale-Black, #0A0A0A); leading-trim: both; text-edge: cap; font-size: 16px; font-style: normal; font-weight: 510; line-height: normal; width: 120%'>${superTitleValue}</span> 6692 ${titleElement} 6693 ${subTitleElement} 6694 </div> 6695 <div class='action_bar outside_section_play_fav_radio' style='padding-right: 16px;'> 6696 <a class="action action_play" id="fav_play_radio_mobile_${radioCount}" href="javascript:;" onClick="player_select_station(${favoriteStation.id}, '', ${radioCount})"> 6697 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none">x 6698 <path id="player_play_fav_radio_${radioCount}"d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5
6698502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="#C3C3C3"/> 6699 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6700 <defs> 6701 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6702 <stop stop-color="#FF0000"/> 6703 <stop offset="1" stop-color="#B10000"/> 6704 </linearGradient> 6705 </defs> 6706 </svg> 6707 </a> 6708 </div> 6709 </li> 6710 `; 6711 radioCount++; 6712 } 6713 } 6714 6715 loggedIn += ` 6716 <div> 6717 <div style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal; margin-top: 20px;'> 6718 Favori Podcastlar 6719 </div> 6720 </div> 6721 `; 6722 6723 if (!logged_in_member_in_fav?.favorite_shows && 6724 !logged_in_member_in_fav?.favorite_shows?.length) { 6725 loggedIn += ` 6726 <div class="notRadioPodcastFavText" style="margin-top: 8px"> 6727 Henüz hiçbir podcasti favorilemedin. 6728 </div> 6729 `; 6730 } else { 6731 let podcastCount = 0; 6732 /** @var {ShowMinified} favoriteShow **/ 6733 for (const favoriteShow of logged_in_member_in_fav.favorite_shows) { 6734 let found = false; 6735 6736 const thumbnailUrlFileAssociation = favoriteShow.FileAssociations.find(item => item.category === 'thumb_1000x1000'); 6737 let favoritesPodcastImage = thumbnailUrlFileAssociation?.file.url || defaultPlaceHolderImage; 6738 favoritesPodcastImage = buildVersionedMediaImageUrl(favoritesPodcastImage); 6739 let subTitleValue = favoriteShow.subtitle || ''; 6740 let superTitleValue = (favoriteShow.Podcast.length > 0) ? favoriteShow.Podcast[0].releaseDate : ''; 6741 let artistName = subTitleValue || superTitleValue; 6742 let title = favoriteShow.title || ''; 6743 let formatted_title = title.replace(/_/g, ' ') // Replace underscores with spaces 6744 .toLowerCase() // Convert the string to lower case 6745 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6746 return letter.toUpperCase(); 6747 }); 6748 let titleEle = ''; 6749 let fontStyle1 = " style=''text-wrap:nowrap''"; 6750 6751 if (title) { 6752 let tag = 'span'; 6753 let formattedTitleSub = formatted_title.length > 17 ? `${formatted_title.substring(0, 17)}...` : formatted_title; 6754 let titleClass = ' super_title superTitlePodcast'; 6755 titleEle = formatted_title.length > 20 ? `<div class='tooltipLeft ${titleClass}' ${fontStyle1}>${formattedTitleSub}<${tag} class='tooltiptext'>${formatted_title}</${tag}></div>` : `<${tag} class='${titleClass}'${fontStyle1}>${formatted_title}</${tag}>`; 6756 } 6757 6758 let subTitleElement = ''; 6759 if (artistName) { 6760 let tag = 'span'; 6761 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6762 subTitleElement = artistName.length > 17 ? `<div class='sub_title titlePodcast tooltipLeft' ${fontStyle1}>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` : `<${tag} class='sub_title titlePodcast'${fontStyle1}>${subTitleContent}</${tag}>`; 6763 } 6764 6765 loggedIn += ` 6766 <li class='list_item leftSideSectionLiFavoritesPodcast' id='leftSideSectionLiFavoritesPodcast' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-top: 4px;' onClick="player_play_podcast_episode(${favoriteShow.Podcast[0].id})"> 6767 <figure class='thumb_container' style='border-radius:10px;'> 6768 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoritesPodcastImage}' alt='${formatted_title}'> 6769 </figure> 6770 <div class='title_container' style='padding: 0;display: flex; flex-direction: column; position: relative; left: -32px; flex: 1'> 6771 ${titleEle} 6772 ${subTitleElement}
6773 <span class='sub_title' style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal;'>${superTitleValue}</span> 6774 </div> 6775 <div class='action_bar' style='display: block !important'> 6776 <a class="action action_play outside_section_play_podcast_fav" style="padding-right: 16px;" id="fav_play_podcast" href="javascript:;" onClick="player_play_podcast_episode(${favoriteShow.Podcast[0].id})"> 6777 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none"> 6778 <path id="player_play_podcast_fav_${podcastCount}" d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="#C3C3C3"/> 6779 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6780 <defs> 6781 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6782 <stop stop-color="#FF0000"/> 6783 <stop offset="1" stop-color="#B10000"/> 6784 </linearGradient> 6785 </defs> 6786 </svg> 6787 </a> 6788 </div> 6789 </li> 6790 `; 6791 found = true; 6792 podcastCount += 1; 6793 } 6794 } 6795 6796 6797 loggedIn += ` 6798 <div> 6799 <div style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal; margin-top: 20px;'> 6800 Favori Podcastlar 6801 </div> 6802 </div> 6803 `; 6804 6805 if (!logged_in_member_in_fav?.favorite_show_episodes && 6806 !logged_in_member_in_fav?.favorite_show_episodes?.length) { 6807 loggedIn += ` 6808 <div class="notRadioPodcastFavText" style="margin-top: 8px"> 6809 Henüz hiçbir podcast bölümü favorilemedin. 6810 </div> 6811 `; 6812 } else { 6813 let podcastEpisodeCount = 0; 6814 /** @var {PodcastMinified} favoriteEpisode **/ 6815 for (const favoriteEpisode of logged_in_member_in_fav.favorite_show_episodes) { 6816 6817 let favoritesPodcastImage = favoriteEpisode.thumbnailImageUrl; 6818 if (!favoritesPodcastImage) { 6819 favoritesPodcastImage = favoriteEpisode.Show && favoriteEpisode.Show.FileAssociations.find(item => item.category === 'thumb_1000x1000'); 6820 favoritesPodcastImage = favoritesPodcastImage?.file.url || defaultPlaceHolderImage; 6821 } 6822 favoritesPodcastImage = buildVersionedMediaImageUrl(favoritesPodcastImage); 6823 let superTitleValue = favoriteEpisode?.Show?.subtitle; 6824 let artistName = favoriteEpisode?.Show?.title; 6825 let title = favoriteEpisode.title; 6826 let formatted_title = title.replace(/_/g, ' ') // Replace underscores with spaces 6827 .toLowerCase() // Convert the string to lower case 6828 .replace(/(^|\s)\S/g, function (letter) { // Capitalize the first letter of each word 6829 return letter.toUpperCase(); 6830 }); 6831 let titleEle = ''; 6832 let fontStyle1 = " style=''text-wrap:nowrap''"; 6833 6834 if (title) { 6835 let tag = 'span'; 6836 let formattedTitleSub = formatted_title.length > 17 ? `${formatted_title.substring(0, 17)}...` : formatted_title; 6837 let titleClass = ' super_title superTitlePodcast'; 6838 titleEle = formatted_title.length > 20 ? `<div class='tooltipLeft ${titleClass}' ${fontStyle1}>${formattedTitleSub}<${tag} class='tooltiptext'>${formatted_title}</${tag}></div>` : `<${tag} class='${titleClass}'${fontStyle1}>${formatted_title}</${tag}>`; 6839 } 6840 6841 let subTitleElement = ''; 6842 if (artistName) { 6843 let tag = 'span'; 6844 let subTitleContent = artistName.length > 17 ? `${artistName.substring(0, 17)}...` : artistName; 6845 subTitleElement = artistName.length > 17 ? `<div class='sub_title titlePodcast tooltipLeft' ${fontStyle1}>${subTitleContent}<${tag} class='tooltiptext'>${artistName}</${tag}></div>` : `<${tag} class='sub_title titlePodcast'${fontStyle1}>${subTitleContent}</${tag}>`; 6846 } 6847 6848 loggedIn += ` 6849 <li class='list_item leftSideSectionLiFavoritesPodcast' id='leftSideSectionLiFavoritesPodcast' style=' margin-left: -40px; display: flex; flex-direction: row; align-items: center; height: 80px; margin-top: 4px;' onClick="player_play_podcast_episode(${favoriteEpisode.id})"> 6850 <figure class='thumb_container' style='border-radius:10px;'> 6851 <img style='width: 66px; height: 66px; border-radius: 4px;' src='${favoritesPodcastImage}' alt='${formatted_title}'> 6852 </figure> 6853 <div class='title_container' style='padding: 0;display: flex; flex-direction: column; position: relative; left: -32px; flex: 1'> 6854 ${titleEle} 6855 ${subTitleElement}
6856 <span class='sub_title' style='color: var(--Grayscale-5, #949494); leading-trim: both; text-edge: cap; font-size: 12px; font-style: normal; font-weight: 400; line-height: normal;'>${superTitleValue}</span> 6857 </div> 6858 <div class='action_bar' style='display: block !important'> 6859 <a class="action action_play outside_section_play_podcast_episode_fav" style="padding-right: 16px;" id="fav_play_podcast" href="javascript:;" onClick="player_play_podcast_episode(${favoriteEpisode.id})"> 6860 <svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 72 72" fill="none"> 6861 <path id="player_play_podcast_episode_fav_${podcastEpisodeCount}" d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.4167 24.5502V47.4908C26.4167 49.1674 28.2966 49.9852 29.9313 48.963L48.8119 37.8811C50.2828 37.0633 50.2422 35.0186 48.8119 34.1599L29.9313 23.0781C28.46 22.1785 26.4167 22.8736 26.4167 24.5502Z" fill="#C3C3C3"/> 6862 <path d="M26.4167 47.4908V24.5502C26.4167 22.8736 28.46 22.1785 29.9313 23.0781L48.8119 34.1599C50.2422 35.0186 50.2828 37.0633 48.8119 37.8811L29.9313 48.963C28.2966 49.9852 26.4167 49.1674 26.4167 47.4908Z" fill="#FCFCFC"/> 6863 <defs> 6864 <linearGradient id="paint0_linear_167_2444" x1="45.5" y1="-31" x2="96.4959" y2="27.5069" gradientUnits="userSpaceOnUse"> 6865 <stop stop-color="#FF0000"/> 6866 <stop offset="1" stop-color="#B10000"/> 6867 </linearGradient> 6868 </defs> 6869 </svg> 6870 </a> 6871 </div> 6872 </li> 6873 `; 6874 podcastEpisodeCount += 1; 6875 } 6876 } 6877 6878 setTimeout(() => { 6879 initFavStyles(); 6880 }, 1000) 6881 myFavDiv.innerHTML = loggedIn; 6882} 6883 6884function updatePlayButton(isPodcastPlaying) { 6885 const playButton = document.getElementById('playButton'); 6886 const playButtonSVG = document.getElementById('playButtonSVG'); 6887 6888 if (isPodcastPlaying) { 6889 // playButton.style.marginLeft = '10px'; 6890 playButton.setAttribute('data-playing', 'podcast'); 6891 6892 playButtonSVG.setAttribute('width', '54'); 6893 playButtonSVG.setAttribute('height', '54'); 6894 } else { 6895 // playButton.style.marginLeft = '15px'; 6896 playButton.setAttribute('data-playing', 'radio'); 6897 6898 playButtonSVG.setAttribute('width', '54'); 6899 playButtonSVG.setAttribute('height', '54'); 6900 } 6901} 6902 6903function formatTime(milliseconds) { 6904 // Convert milliseconds to seconds 6905 let totalSeconds = Math.floor(milliseconds / 1000); 6906 6907 // Calculate minutes and seconds 6908 let minutes = Math.floor(totalSeconds / 60); 6909 let seconds = totalSeconds % 60; 6910 6911 // Format minutes and seconds to MM:SS 6912 return String(minutes).padStart(2, '0') + ":" + String(seconds).padStart(2, '0'); 6913} 6914 6915function podcastPlayerSetPosition(position) { 6916 if (podcast_player) { 6917 podcast_player.setPosition(position); 6918 } 6919} 6920 6921let isUpdating = false; 6922 6923function updatePodcastPositionFromSlider() { 6924 if (isUpdating) return; 6925 isUpdating = true; 6926 6927 requestAnimationFrame(() => { 6928 var progressInput = document.getElementById('podcastProgress'); 6929 if (progressInput) { 6930 6931 var percentage = parseFloat(progressInput.value); 6932 var positionMs = (percentage / 100) * totalMsPodcastTime; 6933 podcastPlayerSetPosition(positionMs); 6934 } else { 6935 console.error('Range input element not found.'); 6936 } 6937 isUpdating = false; 6938 }); 6939} 6940 6941function prerollPlayerMuteToggle() { 6942 const playerAudio = $("#player audio,#player video"); 6943 const playerVolume = playerAudio.prop("volume"); 6944 const playerMuteToggleButton = $(".preroll_container.active .preroll_content .preroll_controls .preroll_mute_toggle"); 6945 const muteButtonSvgPath = "static/assets/v6/styles/images/svgs/mute.svg"; 6946 const unMuteButtonSvgPath = "static/assets/v6/styles/images/svgs/unmute.svg"; 6947 const muteButtonSvg = playerMuteToggleButton.find("img"); 6948 6949 if (playerVolume === 0) { 6950 playerAudio.prop("volume", (player_volume ?? 0.6)); 6951 muteButtonSvg.attr("src", unMuteButtonSvgPath); 6952 } else { 6953 playerAudio.prop("volume", 0); 6954 muteButtonSvg.attr("src", muteButtonSvgPath); 6955 } 6956} 6957 6958// RADIO LYRICS 6959let isLyricsExist = player_current_track?.lyrics_html?.length > 0; 6960let isShowCurrentSongLyrics = false;
6961 6962function updateIfLyricsExist() { 6963 isLyricsExist = player_current_track?.lyrics_html?.length > 0; 6964 6965 const currentSongLyrics = document.getElementById("currentSongLyrics"); 6966 currentSongLyrics.innerHTML = player_current_track?.lyrics_html; 6967 6968 const currentSongLyricsMobile = document.getElementById("currentSongLyricsMobile"); 6969 currentSongLyricsMobile.innerHTML = player_current_track?.lyrics_html; 6970 6971} 6972 6973function toggleShowLyrics(withHiddenLyrics = null) { 6974 const songLyricsContainer = document.getElementById('songLyricsContainerFull'); 6975 const podcastEpisodeListContainer = document.getElementById('podcastEpisodeListContainerFull'); 6976 6977 // Mobile 6978 const songLyricsContainerMobile = document.getElementById('songLyricsContainerMobile'); 6979 const songAlbumBigContainerMobile = document.getElementById('songAlbumBigContainerMobile'); 6980 6981 // Hide Podcast episodes anyway 6982 podcastEpisodeListContainer.style.display = "none"; 6983 6984 isShowCurrentSongLyrics = !withHiddenLyrics; 6985 6986 playerUpdateUI(); 6987 6988 if (isLyricsExist) { 6989 enableLyricsButton(); 6990 if (player_status === "PLAYING" && active_player === "RADIO") { 6991 document.getElementById("currentSongLyrics").innerHTML = player_current_track?.lyrics_html; 6992 if (!isPlayerExpanded) { 6993 expandPlayer(); 6994 } 6995 6996 if (isMobile()) { 6997 // Toggle Mobile 6998 if (withHiddenLyrics) { 6999 songLyricsContainerMobile.style.display = 'none'; 7000 songAlbumBigContainerMobile.style.display = 'flex'; 7001 hideLyricsButton(); 7002 } else { 7003 songLyricsContainerMobile.style.display = withHiddenLyrics === null 7004 ? songLyricsContainerMobile.style.display === "flex" ? "none" : "flex" 7005 : (withHiddenLyrics ? "none" : "flex"); 7006 7007 songLyricsContainerMobile.style.display === "flex" ? enableLyricsButton() : hideLyricsButton(); 7008 songAlbumBigContainerMobile.style.display = songAlbumBigContainerMobile.style.display === "flex" ? "none" : "flex"; 7009 } 7010 } else { 7011 // Toggle Desktop 7012 songLyricsContainer.style.display = withHiddenLyrics === null 7013 ? songLyricsContainer.style.display === "flex" ? "none" : "flex" 7014 : (withHiddenLyrics ? "none" : "flex") 7015 ; 7016 7017 songLyricsContainer.style.display === "flex" ? enableLyricsButton() : hideLyricsButton(); 7018 } 7019 } 7020 } else { 7021 disableLyricsButton(); 7022 } 7023} 7024 7025function disableLyricsButton() { 7026//Desktop 7027 // -- Add class 7028 document.getElementById('radioLyricsButton').classList.add('hidden-button'); // Hiding the whole button - requested from the management. 7029 document.getElementById('radioLyricsButtonFull').classList.add('hidden-button'); // Hiding the whole button - requested from the management. 7030 7031 document.getElementById('radioLyricsIconPath').classList.add('disabled-button'); 7032 7033 document.getElementById('radioLyricsIconPathFull').classList.add('disabled-button-full-player'); 7034 7035 // -- Remove class 7036 document.getElementById('radioLyricsIconPathFull').classList.remove('enabled-button-full-player'); 7037 document.getElementById('radioLyricsIconPathFull').classList.remove('toggle-closed-enabled-button-full-player'); 7038 7039//Mobile 7040 // -- Add class 7041 document.getElementById('radioLyricsIconPathMobile').classList.add('disabled-button-full-player-mobile'); 7042 document.getElementById('mobileLyricsButton').classList.add('hidden-button-visibility'); // Hiding the whole button - requested from the management. 7043 7044 // -- Remove class 7045 document.getElementById('radioLyricsIconPathMobile').classList.remove('enabled-button-full-player-mobile'); 7046 document.getElementById('radioLyricsIconPathMobile').classList.remove('toggle-closed-enabled-button-full-player-mobile'); 7047} 7048 7049function enableLyricsButton() { 7050// Desktop 7051 // -- Add class 7052 document.getElementById('radioLyricsIconPathFull').classList.add('enabled-button-full-player'); 7053 7054 // -- Remove class 7055 document.getElementById('radioLyricsIconPath').classList.remove('disabled-button'); 7056 document.getElementById('radioLyricsIconPathFull').classList.remove('disabled-button-full-player'); 7057 7058 document.getElementById('radioLyricsButton').classList.remove('hidden-button'); // Delete hiding the whole button 7059 document.getElementById('radioLyricsButtonFull').classList.remove('hidden-button'); // Delete hiding the whole button 7060 7061// Mobile 7062 // -- Add class 7063 document.getElementById('radioLyricsIconPathMobile').classList.add('enabled-button-full-player
7063-mobile'); 7064 7065 // -- Remove class 7066 document.getElementById('radioLyricsIconPathMobile').classList.remove('toggle-closed-enabled-button-full-player-mobile') 7067 document.getElementById('radioLyricsIconPathMobile').classList.add('disabled-button-full-player-mobile'); 7068 7069 document.getElementById('mobileLyricsButton').classList.remove('hidden-button-visibility'); // Delete hiding the whole button 7070 7071} 7072 7073function hideLyricsButton() { 7074//Desktop 7075 // -- Add class 7076 document.getElementById('radioLyricsIconPathFull').classList.add('toggle-closed-enabled-button-full-player'); 7077 7078 // -- Remove class 7079 document.getElementById('radioLyricsIconPathFull').classList.remove('disabled-button-full-player'); 7080 document.getElementById('radioLyricsIconPath').classList.remove('disabled-button'); 7081 document.getElementById('radioLyricsIconPathFull').classList.remove('enabled-button-full-player'); 7082 7083 document.getElementById('radioLyricsButton').classList.remove('hidden-button'); // Delete hiding the whole button 7084 document.getElementById('radioLyricsButtonFull').classList.remove('hidden-button'); // Delete hiding the whole button 7085 7086//Mobile 7087 // -- Add class 7088 document.getElementById('radioLyricsIconPathMobile').classList.add('toggle-closed-enabled-button-full-player-mobile'); 7089 7090 // -- Remove class 7091 document.getElementById('radioLyricsIconPathMobile').classList.remove('enabled-button-full-player-mobile'); 7092 document.getElementById('radioLyricsIconPathMobile').classList.remove('disabled-button-full-player-mobile'); 7093 document.getElementById('radioLyricsIconPathMobile').classList.remove('disabled-button'); 7094 7095 document.getElementById('mobileLyricsButton').classList.remove('hidden-button-visibility'); // Delete hiding the whole button 7096} 7097 7098// PODCAST EPISODES 7099let episodesList = []; 7100let isEpisodesExist = episodesList.length > 0; 7101let isShowCurrentPodcastEpisodes = false; 7102 7103function toggleShowEpisodeList(withHiddenEpisodes = false) { 7104 const songLyricsContainer = document.getElementById('songLyricsContainerFull'); 7105 const podcastEpisodeListContainer = document.getElementById('podcastEpisodeListContainerFull'); 7106 7107 if (active_player === "PODCAST") { 7108 // Mobile 7109 const songAlbumBigContainerMobile = document.getElementById('songAlbumBigContainerMobile'); 7110 const podcastEpisodesContainerMobile = document.getElementById('podcastEpisodesContainerMobile'); 7111 7112 // renderFullPlayerPodcastList(); 7113 fillShowPodcastsForPlayer(); 7114 songAlbumBigContainerMobile.style.display = songAlbumBigContainerMobile.style.display === "flex" ? "none" : "flex"; 7115 podcastEpisodesContainerMobile.style.display = podcastEpisodesContainerMobile.style.display === "flex" ? "none" : "flex"; 7116 7117 document.getElementById('episodesIconPath').style.fill = podcastEpisodesContainerMobile.style.display === "flex" ? "white" : "#636363"; 7118 document.getElementById('podcastEpisodesListIconFull').style.fill = podcastEpisodesContainerMobile.style.display === "flex" ? "white" : "#636363"; 7119 7120 // Hide Radio lyrics anyway, 7121 songLyricsContainer.style.display = "none"; 7122 // podcastEpisodeListContainer.style.display = podcastEpisodeListContainer.style.display === "flex" ? "none" : "flex"; 7123 if (withHiddenEpisodes === true) { 7124 podcastEpisodeListContainer.style.display = "none"; 7125 isShowCurrentPodcastEpisodes = false; 7126 7127 if (isMobile()) { 7128 songAlbumBigContainerMobile.style.display = "flex"; 7129 podcastEpisodesContainerMobile.style.display = "none"; 7130 } 7131 7132 7133 } else { 7134 if (withHiddenEpisodes !== null) { 7135 podcastEpisodeListContainer.style.display = podcastEpisodeListContainer.style.display === "flex" ? "none" : "flex"; 7136 // isShowCurrentPodcastEpisodes = podcastEpisodeListContainer.style.display === "flex"; 7137 } 7138 // else { 7139 // isShowCurrentPodcastEpisodes = true; 7140 // podcastEpisodeListContainer.style.display = "flex"; 7141 // }
7142 isShowCurrentPodcastEpisodes = podcastEpisodeListContainer.style.display === "flex"; 7143 if (isMobile()) { 7144 isShowCurrentPodcastEpisodes = podcastEpisodesContainerMobile.style.display === "flex"; 7145 } 7146 } 7147 7148 if (!isPlayerExpanded) { 7149 podcastEpisodeListContainer.style.display = 'flex !important'; 7150 document.getElementById('listContainerFullMobile').style.display = 'flex !important'; 7151 7152 updateFullPlayerPodcastUIElements(player_status); 7153 expandPlayer(); 7154 } 7155 playerUpdateUI(); 7156 } 7157 if (active_player === "RADIO") { 7158 const songLyricsContainerMobile = document.getElementById('songLyricsContainerMobile'); 7159 const songAlbumBigContainerMobile = document.getElementById('songAlbumBigContainerMobile'); 7160 7161 if (isMobile() && withHiddenEpisodes) { 7162 if (songLyricsContainerMobile) { 7163 songLyricsContainerMobile.style.display = "none"; 7164 } 7165 if (songAlbumBigContainerMobile) { 7166 songAlbumBigContainerMobile.style.display = "flex"; 7167 } 7168 } else { 7169 console.log("FAIL!!!! show songAlbumBigContainerMobile & hide songLyricsContainerMobile ====>" + withHiddenEpisodes); 7170 } 7171 } 7172} 7173 7174function updateIfPodcastEpisodesExist() { 7175 isEpisodesExist = episodesList.length > 0; 7176 updateFullPlayerPodcastUIElements(); 7177} 7178 7179function updateFullPlayerPodcastUIElements(status = "STOPPED") { 7180 // renderFullPlayerPodcastList(); 7181 updateFullPlayerButtons(status); 7182} 7183 7184function renderFullPlayerPodcastList() { 7185 7186 let episodesList = []; 7187 episodesList.push(player_current_track); 7188 // Object.entries(player_current_track?.show?.episodes).forEach(function ([key, value]) { 7189 // episodesList.push(value) 7190 // }); 7191 7192 if (episodesList && episodesList.length > 0) { 7193 let listContainer = document.getElementById(isMobile() ? 'listContainerFullMobile' : 'listContainerFull'); 7194 //let listContainerMobile = document.getElementById('listContainerFullMobile'); 7195 7196 while (listContainer.firstChild) { 7197 listContainer.removeChild(listContainer.firstChild); 7198 } 7199 7200 let ul = document.createElement('ul'); 7201 let episodeTitle = ""; 7202 7203 7204 episodesList.forEach(function (item) { 7205 episodeTitle = item.title; 7206 let li = document.createElement('li'); 7207 li.textContent = item.title; 7208 li.classList.add("episode-info-container"); 7209 7210 let currentEpisode = Number(player_current_podcast?.id) === Number(item.id); 7211 let isPausedCurrentEpisode = currentEpisode && player_status === "PAUSED"; 7212 7213 li.innerHTML = ` 7214 <div class="left-container"> 7215 <div class="episode-title">${item.title}</div> 7216 <div class="episode-release-date">${releaseDateFormatter(item.releaseDate)}</div> 7217 <div class="podcast-episode-item-subtitle" id="toggleSubtitle-${item.id}"> 7218 ${item.subtitle} 7219 </div> 7220 </div> 7221 <div class="right-container" id="episodeItemRightContainer"> 7222 <div class="durantion" style="display: ${isMobile() ? 'none' : 'block'}">${item.duration}</div> 7223 <div class="play-button-container" 7224 id="episode-play-button" 7225 style="display: ${currentEpisode ? 'none' : 'flex'};" 7226 onclick="player_play_podcast_episode(${Number(item.id)});" 7227 > 7228 <svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg"> 7229 <path d="M14.975 22.625L22.2875 17.9375C22.6375 17.7125 22.8125 17.4 22.8125 17C22.8125 16.6 22.6375 16.2875 22.2875 16.0625L14.975 11.375C14.6 11.125 14.2188 11.1063 13.8313 11.3188C13.4438 11.5312 13.25 11.8625 13.25 12.3125V21.6875C13.25 22.1375 13.4438 22.4688 13.8313 22.6813C14.2188 22.8938 14.6 22.875 14.975 22.625ZM17 32C14.925 32 12.975 31.6063 11.15 30.8188C9.325 30.0313 7.7375 28.9625 6.3875 27.6125C5.0375 26.2625 3.96875 24.675 3.18125 22.85C2.39375 21.025 2 19.075 2 17C2 14.925 2.39375 12.975 3.18125 11.15C3.96875 9.325 5.0375 7.7375 6.3875 6.3875C7.7375 5.0375 9.325 3.96875 11.15 3.18125C12.975 2.39375 14.925 2 17 2C19.075 2 21.025 2.39375 22.85 3.18125C24.675 3.96875 26.2625 5.0375 27.6125 6.3875C28.9625 7.7375 30.0313 9.325 30.8188 11.15C31.6063 12.975 32 14.925 32 17C32 19.075 31.6063 21.025 30.8188 22.85C30.0313 24.675 28.9625 26.2625 27.6125 27.6125C26.2625 28.9625 24.675 30.0313 22.85 30.8188C21.025 31.6063 19.075 32 17 32Z" fill="#FCFCFC" fill-opacity="0.4"/> 7230 <path fill-rule="evenodd" clip-rule="evenodd" d="M22.2875 17.9376L14.975 22.6251C14.6 22.8751 14.2188 22.8938 13.8313 22.6813C13.4438 22.4688 13.25 22.1376 13.25 21.6876V12.3126C13.25 11.8626 13.4438 11.5313 13.8313
723011.3188C14.2188 11.1063 14.6 11.1251 14.975 11.3751L22.2875 16.0626C22.6375 16.2876 22.8125 16.6001 22.8125 17.0001C22.8125 17.4001 22.6375 17.7126 22.2875 17.9376Z" fill="#FCFCFC"/> 7231 </svg> 7232 </div> 7233 7234 <!-- Resume Button --> 7235 <div class="play-button-container" 7236 id="episode-play-button" 7237 style="display: ${(currentEpisode && isPausedCurrentEpisode) ? 'flex !important' : 'none'};" 7238 onclick="player_play();" 7239 > 7240 <svg width="34" height="34" viewBox="0 0 34 34" fill="none" xmlns="http://www.w3.org/2000/svg"> 7241 <path d="M14.975 22.625L22.2875 17.9375C22.6375 17.7125 22.8125 17.4 22.8125 17C22.8125 16.6 22.6375 16.2875 22.2875 16.0625L14.975 11.375C14.6 11.125 14.2188 11.1063 13.8313 11.3188C13.4438 11.5312 13.25 11.8625 13.25 12.3125V21.6875C13.25 22.1375 13.4438 22.4688 13.8313 22.6813C14.2188 22.8938 14.6 22.875 14.975 22.625ZM17 32C14.925 32 12.975 31.6063 11.15 30.8188C9.325 30.0313 7.7375 28.9625 6.3875 27.6125C5.0375 26.2625 3.96875 24.675 3.18125 22.85C2.39375 21.025 2 19.075 2 17C2 14.925 2.39375 12.975 3.18125 11.15C3.96875 9.325 5.0375 7.7375 6.3875 6.3875C7.7375 5.0375 9.325 3.96875 11.15 3.18125C12.975 2.39375 14.925 2 17 2C19.075 2 21.025 2.39375 22.85 3.18125C24.675 3.96875 26.2625 5.0375 27.6125 6.3875C28.9625 7.7375 30.0313 9.325 30.8188 11.15C31.6063 12.975 32 14.925 32 17C32 19.075 31.6063 21.025 30.8188 22.85C30.0313 24.675 28.9625 26.2625 27.6125 27.6125C26.2625 28.9625 24.675 30.0313 22.85 30.8188C21.025 31.6063 19.075 32 17 32Z" fill="green" fill-opacity="1"/> 7242 <path fill-rule="evenodd" clip-rule="evenodd" d="M22.2875 17.9376L14.975 22.6251C14.6 22.8751 14.2188 22.8938 13.8313 22.6813C13.4438 22.4688 13.25 22.1376 13.25 21.6876V12.3126C13.25 11.8626 13.4438 11.5313 13.8313 11.3188C14.2188 11.1063 14.6 11.1251 14.975 11.3751L22.2875 16.0626C22.6375 16.2876 22.8125 16.6001 22.8125 17.0001C22.8125 17.4001 22.6375 17.7126 22.2875 17.9376Z" fill="#FCFCFC"/> 7243 </svg> 7244 </div> 7245 7246 7247 7248 <div class="play-button-container" id="selected-episode-pause-button" 7249 style="display: ${currentEpisode && !isPausedCurrentEpisode ? 'flex !important' : 'none'}" 7250 onclick="player_pause();" 7251 > 7252 <svg id="pause-button-svg-mobile" xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="mobile-pause-button"
7253 viewBox="0 0 72 72" fill="none"> 7254 <path d="M69 36C69 54.0335 54.0018 69 35.9795 69C17.9981 69 3 54.0335 3 36C3 17.9666 17.9573 3 35.9387 3C53.9608 3 69 17.9666 69 36ZM26.5393 22.9145C24.782 22.9145 24.0055 23.8141 24.0055 25.1636V46.7957C24.0055 48.1448 24.782 49.0447 26.5393 49.0447H29.7678C31.4842 49.0447 32.2607 48.1448 32.2607 46.7957V25.1636C32.2607 23.8141 31.4842 22.9145 29.7678 22.9145H26.5393ZM42.3139 22.9145C40.5975 22.9145 39.7801 23.8141 39.7801 25.1636V46.7957C39.7801 48.1448 40.5975 49.0447 42.3139 49.0447H45.5423C47.2179 49.0447 47.9946 48.1448 47.9946 46.7957V25.1636C47.9946 23.8141 47.2179 22.9145 45.5423 22.9145H42.3139Z" 7255 fill="url(#paint0_linear_167_2458)"/> 7256 <path d="M24.0055 25.1636C24.0055 23.8141 24.782 22.9145 26.5393 22.9145H29.7678C31.4842 22.9145 32.2607 23.8141 32.2607 25.1636V46.7957C32.2607 48.1448 31.4842 49.0447 29.7678 49.0447H26.5393C24.782 49.0447 24.0055 48.1448 24.0055 46.7957V25.1636Z" 7257 fill="#FCFCFC"/> 7258 <path d="M39.7801 25.1636C39.7801 23.8141 40.5975 22.9145 42.3139 22.9145H45.5423C47.2179 22.9145 47.9946 23.8141 47.9946 25.1636V46.7957C47.9946 48.1448 47.2179 49.0447 45.5423 49.0447H42.3139C40.5975 49.0447 39.7801 48.1448 39.7801 46.7957V25.1636Z" 7259 fill="#FCFCFC"/> 7260 <defs> 7261 <linearGradient id="paint0_linear_167_2458" x1="45.5" y1="-31" x2="96.4959" 7262 y2="27.5069" gradientUnits="userSpaceOnUse"> 7263 <stop stop-color="#FF0000"/> 7264 <stop offset="1" stop-color="#B10000"/> 7265 </linearGradient> 7266 </defs> 7267 </svg> 7268 </div> 7269 7270 7271 </div> 7272 `; 7273 ul.appendChild(li); 7274 }); 7275 7276 listContainer.appendChild(ul); 7277 7278 } else { 7279 console.log("empty list") 7280 } 7281} 7282 7283function disablePodcastEpisodesButton() { 7284 //Desktop 7285 // -- Add class 7286 document.getElementById('podcastEpisodesListIconPathFull').classList.add('disabled-button'); 7287 7288 // -- Remove class 7289 document.getElementById('podcastEpisodesListIconPathFull').classList.remove('enabled-button-full-player'); 7290} 7291 7292function enablePodcastEpisodesButton() { 7293 //Desktop 7294 // -- Add class 7295 document.getElementById('podcastEpisodesListIconPathFull').classList.add('enabled-button-full-player'); 7296 7297 // -- Remove class 7298 document.getElementById('podcastEpisodesListIconPathFull').classList.remove('disabled-button'); 7299 7300} 7301 7302function hidePodcastEpisodesButton() { 7303 //Desktop 7304 // -- Add class 7305 document.getElementById('podcastEpisodesListIconPathFull').classList.add('toggle-closed-enabled-button-full-player'); 7306 7307 // -- Remove class 7308 document.getElementById('podcastEpisodesListIconPathFull').classList.remove('disabled-button'); 7309 document.getElementById('podcastEpisodesListIconPathFull').classList.remove('enabled-button-full-player'); 7310} 7311 7312function updatePodcastPositionFromSliderFullPlayer() { 7313 if (isUpdating) return; 7314 isUpdating = true; 7315 7316 requestAnimationFrame(() => { 7317 let progressInputFullPlayer = document.getElementById('podcastProgressFullPlayer'); 7318 if (progressInputFullPlayer) { 7319 let percentageFullPlayer = parseFloat(progressInputFullPlayer.value); 7320 let positionMsFullPlayer = (percentageFullPlayer / 100) * totalMsPodcastTime; 7321 podcastPlayerSetPosition(positionMsFullPlayer); 7322 } else { 7323 console.error('input element not found.'); 7324 } 7325 isUpdating = false; 7326 }); 7327} 7328 7329function updatePodcastPositionFromSliderFullPlayerMobile() { 7330 if (isUpdating) return; 7331 isUpdating = true; 7332 7333 requestAnimationFrame(() => { 7334 let progressInputFullPlayer = document.getElementById('podcastProgressFullPlayerMobile'); 7335 if (progressInputFullPlayer) { 7336 let percentageFullPlayer = parseFloat(progressInputFullPlayer.value); 7337 let positionMsFullPlayer = (percentageFullPlayer / 100) * totalMsPodcastTime; 7338 podcastPlayerSetPosition(positionMsFullPlayer); 7339 } else { 7340 console.error('input element not found.'); 7341 } 7342 isUpdating = false;
7343 }); 7344} 7345 7346function updatePlayerButtonsStyling(isFullPlayer) { 7347 // Right Buttons 7348 // Volume 7349 updatePlayerRadioVolumeButtonUI(isFullPlayer); 7350 // Radio Lyrics 7351 updatePlayerRadioLyricsButtonUI(isFullPlayer); 7352 // Expand Button 7353 updatePlayerExpandButtonUI(isFullPlayer); 7354 // Play Button 7355 // updatePlayerPlayButtonUI(isFullPlayer); 7356} 7357 7358 7359// PLAYER UI Reduced/Full 7360$(document).ready(function () { 7361 if (isMobile()) { 7362 document.getElementById('podcastProgress').classList.add('podcast-progress-bar-mobile'); 7363 document.getElementById('podcastProgress').classList.remove('podcast-progress-bar'); 7364 generateMobilePlayerUI(); 7365 } else { 7366 document.getElementById('podcastProgress').classList.remove('podcast-progress-bar-mobile'); 7367 document.getElementById('podcastProgress').classList.add('podcast-progress-bar'); 7368 generateDesktopPlayerUI(); 7369 } 7370 7371 // Handle phone input with +90 prefix 7372 $(document).on('focusin', '#profile_phone_number, #signup_phone_number', function () { 7373 var $input = $(this); 7374 var value = $input.val(); 7375 7376 // If empty or just +90, set to +90 7377 if (!value || value === '+90') { 7378 $input.val('+90'); 7379 } 7380 }); 7381 7382 $(document).on('focusout', '#profile_phone_number, #signup_phone_number', function () { 7383 var $input = $(this); 7384 var value = $input.val(); 7385 7386 // If only +90 or less, clear it 7387 if (value === '+90' || value.length <= 3) { 7388 $input.val(''); 7389 } 7390 }); 7391}); 7392 7393// Generate the Mobile Player UI 7394function mobileTapPlayerHandler() { 7395 // document.getElementById('playerContentMobile').style.visibility = 'visible';
7396 // document.getElementById('songBackgroundContainer').style.visibility = 'hidden'; 7397 //document.getElementById('player-content').style.visibility = 'hidden'; 7398 // document.getElementById('player-content').style.display = 'none'; 7399 // document.getElementById('player-content').removeEventListener("click", mobileTapPlayerHandler); 7400 // toggleExpandPlayer(active_player); 7401} 7402 7403function generateMobilePlayerUI() { 7404 const expandMobilePlayerDiv = document.getElementById('expandMobilePlayer'); 7405 if (expandMobilePlayerDiv) { 7406 expandMobilePlayerDiv.addEventListener("click", mobileTapPlayerHandler); 7407 } 7408} 7409 7410// Generate the Desktop Player UI 7411function generateDesktopPlayerUI() { 7412 document.getElementById('footer-player').removeEventListener("click", mobileTapPlayerHandler); 7413} 7414 7415function updatePlayerExpandButtonUI(isFullPlayer) { 7416 // Expand Button 7417 const expandPlayerButtonContainer = document.getElementById('expandPlayerFull'); 7418 const expandChild = document.getElementById("expandIcon"); 7419 7420 if (expandPlayerButtonContainer && expandChild) { 7421 expandPlayerButtonContainer.removeChild(expandChild); 7422 } 7423 7424 if (expandPlayerButtonContainer) { 7425 expandPlayerButtonContainer.innerHTML = 7426 isFullPlayer ? 7427 ` 7428 <svg id="expandIcon" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 7429 <path d="M18.6201 23.6958L13.0744 29.2415C12.9021 29.4138 12.6828 29.5 12.4164 29.5C12.1501 29.5 11.9308 29.4138 11.7585 29.2415C11.5862 29.0692 11.5 28.8499 11.5 28.5836C11.5 28.3172 11.5862 28.0979 11.7585 27.9256L17.3042 22.3799H13.9204C13.654 22.3799 13.4308 22.2898 13.2507 22.1097C13.0705 21.9295 12.9804 21.7063 12.9804 21.4399C12.9804 21.1736 13.0705 20.9504 13.2507 20.7702C13.4308 20.5901 13.654 20.5 13.9204 20.5H19.5601C19.8264 20.5 20.0496 20.5901 20.2298 20.7702C20.4099 20.9504 20.5 21.1736 20.5 21.4399V27.0796C20.5 27.346 20.4099 27.5692 20.2298 27.7493C20.0496 27.9295 19.8264 28.0196 19.5601 28.0196C19.2937 28.0196 19.0705 27.9295 18.8903 27.7493C18.7102 27.5692 18.6201 27.346 18.6201 27.0796V23.6958ZM23.6958 18.6201H27.0796C27.346 18.6201 27.5692 18.7102 27.7493 18.8903C27.9295 19.0705 28.0196 19.2937 28.0196 19.5601C28.0196 19.8264 27.9295 20.0496 27.7493 20.2298C27.5692 20.4099 27.346 20.5 27.0796 20.5H21.4399C21.1736 20.5 20.9504 20.4099 20.7702 20.2298C20.5901 20.0496 20.5 19.8264 20.5 19.5601V13.9204C20.5 13.654 20.5901 13.4308 20.7702 13.2507C20.9504 13.0705 21.1736 12.9804 21.4399 12.9804C21.7063 12.9804 21.9295 13.0705 22.1097 13.2507C22.2898 13.4308 22.3799 13.654 22.3799 13.9204V17.3042L27.9256 11.7585C28.0979 11.5862 28.3172 11.5 28.5836 11.5C28.8499 11.5 29.0692 11.5862 29.2415 11.7585C29.4138 11.9308 29.5 12.1501 29.5 12.4164C29.5 12.6828 29.4138 12.9021 29.2415 13.0744L23.6958 18.6201Z" fill="#949494"/> 7430 </svg> 7431 ` : 7432 ` 7433 <svg id="expandIcon" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 7434 <path d="M13.5524 29.5C13.2848 29.5 13.0605 29.4095 12.8794 29.2285C12.6984 29.0475 12.6079 28.8231 12.6079 28.5556V22.8889C12.6079 22.6213 12.6984 22.397 12.8794 22.216C13.0605 22.035 13.2848 21.9444 13.5524 21.9444C13.8199 21.9444 14.0443 22.035 14.2253 22.216C14.4063 22.397 14.4968 22.6213 14.4968 22.8889V26.2889L26.3968 14.3889H22.9968C22.7292 14.3889 22.5049 14.2984 22.3239 14.1174C22.1429 13.9363 22.0524 13.712 22.0524 13.4444C22.0524 13.1769 22.1429 12.9525 22.3239 12.7715C22.5049 12.5905 22.7292 12.5 22.9968 12.5H28.6635C28.9311 12.5 29.1554 12.5905 29.3364 12.7715C29.5174 12.9525 29.6079 13.1769 29.6079 13.4444V19.1111C29.6079 19.3787 29.5174 19.603 29.3364 19.784C29.1554 19.965 28.9311 20.0556 28.6635 20.0556C28.3959 20.0556 28.1716 19.965 27.9905 19.784C27.8095 19.603 27.719 19.3787 27.719 19.1111V15.7111L15.819 27.6111H19.219C19.4866 27.6111 19.7109 27.7016 19.8919 27.8826C20.073 28.0637 20.1635 28.288 20.1635 28.5556C20.1635 28.8231 20.073 29.0475 19.8919 29.2285C19.7109 29.4095 19.4866 29.5 19.219 29.5H13.5524Z" fill="#0A0A0A"/> 7435 </svg> 7436 ` 7437 ; 7438 } 7439} 7440 7441function updatePlayerRadioLyricsButtonUI(isFullPlayer) { 7442 const radioLyricsButtonContainer = document.getElementById('radioLyricsButtonFull');
7443 const lyricsChild = document.getElementById("radioLyricsIcon"); 7444 // volumeButtonContainer.removeChild(lyricsChild); 7445 7446 radioLyricsButtonContainer.innerHTML = 7447 isFullPlayer ? 7448 ` 7449 <svg id="radioLyricsIcon" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 7450 <path d="M14.9898 23.4388H16.8265C17.0867 23.4388 17.3048 23.3508 17.4809 23.1747C17.6569 22.9987 17.7449 22.7806 17.7449 22.5204C17.7449 22.2602 17.6569 22.0421 17.4809 21.8661C17.3048 21.6901 17.0867 21.602 16.8265 21.602H14.9898C14.7296 21.602 14.5115 21.6901 14.3355 21.8661C14.1594 22.0421 14.0714 22.2602 14.0714 22.5204C14.0714 22.7806 14.1594 22.9987 14.3355 23.1747C14.5115 23.3508 14.7296 23.4388 14.9898 23.4388ZM26.0102 21.602C25.2449 21.602 24.5944 21.3342 24.0587 20.7985C23.523 20.2628 23.2551 19.6122 23.2551 18.8469C23.2551 18.0816 23.523 17.4311 24.0587 16.8954C24.5944 16.3597 25.2449 16.0918 26.0102 16.0918C26.1786 16.0918 26.3393 16.1071 26.4923 16.1378C26.6454 16.1684 26.7908 16.2066 26.9286 16.2526V12.4184C26.9286 12.1582 27.0166 11.9401 27.1926 11.764C27.3686 11.588 27.5867 11.5 27.8469 11.5H29.6837C29.9439 11.5 30.162 11.588 30.338 11.764C30.514 11.9401 30.602 12.1582 30.602 12.4184C30.602 12.6786 30.514 12.8967 30.338 13.0727C30.162 13.2487 29.9439 13.3367 29.6837 13.3367H28.7653V18.8469C28.7653 19.6122 28.4974 20.2628 27.9617 20.7985C27.426 21.3342 26.7755 21.602 26.0102 21.602ZM14.9898 20.6837H19.5816C19.8418 20.6837 20.0599 20.5957 20.236 20.4196C20.412 20.2436 20.5 20.0255 20.5 19.7653C20.5 19.5051 20.412 19.287 20.236 19.111C20.0599 18.9349 19.8418 18.8469 19.5816 18.8469H14.9898C14.7296 18.8469 14.5115 18.9349 14.3355 19.111C14.1594 19.287 14.0714 19.5051 14.0714 19.7653C14.0714 20.0255 14.1594 20.2436 14.3355 20.4196C14.5115 20.5957 14.7296 20.6837 14.9898 20.6837ZM14.9898 17.9286H19.5816C19.8418 17.9286 20.0599 17.8406 20.236 17.6645C20.412 17.4885 20.5 17.2704 20.5 17.0102C20.5 16.75 20.412 16.5319 20.236 16.3559C20.0599 16.1798 19.8418 16.0918 19.5816 16.0918H14.9898C14.7296 16.0918 14.5115 16.1798 14.3355 16.3559C14.1594 16.5319 14.0714 16.75 14.0714 17.0102C14.0714 17.2704 14.1594 17.4885 14.3355 17.6645C14.5115 17.8406 14.7296 17.9286 14.9898 17.9286ZM22.3367 27.1122H14.0714L11.9592 29.2245C11.8673 29.3163 11.7679 29.3852 11.6607 29.4311C11.5536 29.477 11.4388 29.5 11.3163 29.5C11.0714 29.5 10.8571 29.412 10.6735 29.236C10.4898 29.0599 10.398 28.8342 10.398 28.5587V14.2551C10.398 13.75 10.5778 13.3176 10.9375 12.9579C11.2972 12.5982 11.7296 12.4184 12.2347 12.4184H22.3367C22.8418 12.4184 23.2742 12.5982 23.6339 12.9579C23.9936 13.3176 24.1735 13.75 24.1735 14.2551V14.6454C23.8061 14.8138 23.4694 15.0204 23.1633 15.2653C22.8571 15.5102 22.5816 15.7857 22.3367 16.0918V14.2551H12.2347V26.3546L13.3138 25.2755H22.3367V21.602C22.5816 21.9082 22.8571 22.1837 23.1633 22.4286C23.4694 22.6735 23.8061 22.8801 24.1735 23.0485V25.2755C24.1735 25.7806 23.9936 26.213 23.6339 26.5727C23.2742 26.9324 22.8418 27.1122 22.3367 27.1122Z" fill="#949494"/> 7451 </svg> 7452 7453 ` : 7454 ` 7455 <svg id="radioLyricsIcon" width="42" height="42" viewBox="0 0 42 42" fill="none" xmlns="http://www.w3.org/2000/svg"> 7456 <path d="M15.5977 23.9388H17.4344C17.6946 23.9388 17.9127 23.8508 18.0888 23.6747C18.2648 23.4987 18.3528 23.2806 18.3528 23.0204C18.3528 22.7602 18.2648 22.5421 18.0888 22.3661C17.9127 22.1901 17.6946 22.102 17.4344 22.102H15.5977C15.3375 22.102 15.1194 22.1901 14.9434 22.3661C14.7673 22.5421 14.6793 22.7602 14.6793 23.0204C14.6793 23.2806 14.7673 23.4987 14.9434 23.6747C15.1194 23.8508 15.3375 23.9388 15.5977 23.9388ZM26.6181 22.102C25.8528 22.102 25.2023 21.8342 24.6666 21.2985C24.1309 20.7628 23.863 20.1122 23.863 19.3469C23.863 18.5816 24.1309 17.9311 24.6666 17.3954C25.2023 16.8597 25.8528 16.5918 26.6181 16.5918C26.7865 16.5918 26.9472 16.6071 27.1002 16.6378C27.2533 16.6684 27.3987 16.7066 27.5365 16.7526V12.9184C27.5365 12.6582 27.6245 12.4401 27.8005 12.264C27.9765 12.088 28.1946 12 28.4548 12H30.2916C30.5518 12 30.7699 12.088 30.9459 12.264C31.1219 12.4401 31.2099 12.6582 31.2099 12.9184C31.2099 13.1786 31.1219 13.3967 30.9459 13.5727C30.7699 13.7487 30.5518 13.8367 30.2916 13.8367H29.3732V19.3469C29.3732 20.1122 29.1053 20.7628 28.5696 21.2985C28.0339 21.8342 27.3834 22.102 26.6181 22.102ZM15.5977 21.1837H20.1895C20.4497 21.1837 20.6678 21.0957 20.8439 20.9196C21.0199 20.7436 21.1079 20.5255 21.1079 20.2653C21.1079 20.0051 21.0199 19.787 20.8439 19.611C20.6678 19.4349 20.4497 19.3469 20.1895 19.3469H15.5977C1
74565.3375 19.3469 15.1194 19.4349 14.9434 19.611C14.7673 19.787 14.6793 20.0051 14.6793 20.2653C14.6793 20.5255 14.7673 20.7436 14.9434 20.9196C15.1194 21.0957 15.3375 21.1837 15.5977 21.1837ZM15.5977 18.4286H20.1895C20.4497 18.4286 20.6678 18.3406 20.8439 18.1645C21.0199 17.9885 21.1079 17.7704 21.1079 17.5102C21.1079 17.25 21.0199 17.0319 20.8439 16.8559C20.6678 16.6798 20.4497 16.5918 20.1895 16.5918H15.5977C15.3375 16.5918 15.1194 16.6798 14.9434 16.8559C14.7673 17.0319 14.6793 17.25 14.6793 17.5102C14.6793 17.7704 14.7673 17.9885 14.9434 18.1645C15.1194 18.3406 15.3375 18.4286 15.5977 18.4286ZM22.9446 27.6122H14.6793L12.5671 29.7245C12.4752 29.8163 12.3758 29.8852 12.2686 29.9311C12.1615 29.977 12.0467 30 11.9242 30C11.6793 30 11.465 29.912 11.2814 29.736C11.0977 29.5599 11.0059 29.3342 11.0059 29.0587V14.7551C11.0059 14.25 11.1857 13.8176 11.5454 13.4579C11.9051 13.0982 12.3375 12.9184 12.8426 12.9184H22.9446C23.4497 12.9184 23.8821 13.0982 24.2418 13.4579C24.6015 13.8176 24.7814 14.25 24.7814 14.7551V15.1454C24.414 15.3138 24.0773 15.5204 23.7712 15.7653C23.465 16.0102 23.1895 16.2857 22.9446 16.5918V14.7551H12.8426V26.8546L13.9217 25.7755H22.9446V22.102C23.1895 22.4082 23.465 22.6837 23.7712 22.9286C24.0773 23.1735 24.414 23.3801 24.7814 23.5485V25.7755C24.7814 26.2806 24.6015 26.713 24.2418 27.0727C23.8821 27.4324 23.4497 27.6122 22.9446 27.6122Z" fill="#0A0A0A"/> 7457 </svg> 7458 ` 7459 ; 7460} 7461 7462function updatePlayerRadioVolumeButtonUI(isFullPlayer) { 7463 const volumeButtonContainer = document.getElementById('onMute'); 7464 const volumeChild = document.getElementById("onMuteSVG"); 7465 volumeButtonContainer.removeChild(volumeChild); 7466 7467 volumeButtonContainer.innerHTML = ` 7468 <svg id="onMuteSVG" width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg"> 7469 <path d="M26.3974 28.7512C26.1133 28.9468 25.8197 29.1268 25.5167 29.291C25.2136 29.455 24.8979 29.6033 24.5695 29.7359C24.3233 29.8433 24.0723 29.8433 23.8166 29.7359C23.5609 29.6287 23.3826 29.4488 23.2816 29.1961C23.1807 28.9626 23.1885 28.7305 23.3052 28.5C23.4221 28.2697 23.6036 28.1009 23.8498 27.9935C24.1087 27.8988 24.3613 27.7867 24.6075 27.6574C24.8538 27.5278 25.0842 27.3683 25.2988 27.1789L20.6488 22.9838V27.1602C20.6488 27.5831 20.4546 27.8751 20.0664 28.0361C19.6781 28.1971 19.3356 28.1292 19.039 27.8324L14.9666 23.7602H11.3681C11.0965 23.7602 10.8707 23.6703 10.6908 23.4903C10.5108 23.3104 10.4209 23.0847 10.4209 22.8133V17.8886C10.4209 17.6172 10.5108 17.3915 10.6908 17.2115C10.8707 17.0316 11.0965 16.9416 11.3681 16.9416H14.5879L9.26567 11.6194C9.08251 11.4363 8.99406 11.2121 9.00031 10.9469C9.00675 10.6818 9.10145 10.4576 9.28442 10.2745C9.46757 10.0915 9.69174 10 9.9569 10C10.2221 10 10.4462 10.0915 10.6294 10.2745L30.7253 30.3706C30.9084 30.5536 31 30.7776 31 31.0428C31 31.308 30.9084 31.5321 30.7253 31.7153C30.5421 31.8985 30.3148 31.99 30.0434 31.99C29.772 31.99 29.5447 31.8985 29.3615 31.7153L26.3974 28.7512ZM28.9828 20.3225C28.9828 18.6241 28.5124 17.0821 27.5717 15.6964C26.6309 14.3105 25.3903 13.2956 23.8498 12.6516C23.6036 12.5442 23.4268 12.3753 23.3194 12.145C23.2122 11.9145 23.2059 11.6825 23.3006 11.449C23.4016 11.1963 23.5799 11.0195 23.8356 10.9185C24.0913 10.8176 24.3518 10.8207 24.6169 10.9279C26.5047 11.7172 28.02 12.9546 29.1627 14.6404C30.3054 16.3261 30.8767 18.2201 30.8767 20.3225C30.8767 21.0106 30.8104 21.6909 30.6778 22.3633C30.5452 23.0357 30.3432 23.6876 30.0718 24.3191C29.9203 24.6725 29.7198 24.8887 29.4704 24.9677C29.2211 25.0467 28.9828 25.0388 28.7555 24.9441C28.5283 24.8494 28.3531 24.701 28.2299 24.4989C28.1068 24.2968 28.1083 24.0727 28.2345 23.8264C28.4934 23.2836 28.6828 22.7201 28.8027 22.136C28.9228 21.5521 28.9828 20.9476 28.9828 20.3225ZM23.651 16.1936C24.3391 16.6165 24.8631 17.2163 25.2229 17.9928C25.5828 18.7694 25.7627 19.5554 25.7627 20.3509V20.7297C25.7627 20.8497 25.747 20.9761 25.7156 21.1087C25.6777 21.317 25.564 21.4527 25.3746 21.5158C25.1852 21.5789 25.0084 21.5284 24.8442 21.3644L23.2058 19.7259C23.1048 19.6249 23.0323 19.5192 22.9881 19.4086C22.9438 19.2981 22.9216 19.1797 22.9216 19.0534V16.6007C22.9216 16.4113 23.0021 16.2709 23.1631 16.1794C23.3241 16.0877 23.48
746967 16.0924 23.651 16.1936ZM18.035 14.5551C17.934 14.4542 17.8835 14.3405 17.8835 14.2142C17.8835 14.0879 17.934 13.9742 18.035 13.8733L19.039 12.8695C19.3356 12.5727 19.6781 12.5048 20.0664 12.6658C20.4546 12.8268 20.6488 13.1188 20.6488 13.5417V16.0325C20.6488 16.2471 20.5509 16.3923 20.3553 16.468C20.1596 16.5438 19.986 16.5059 19.8345 16.3544L18.035 14.5551ZM18.7549 24.8399V21.1087L16.482 18.8358H12.315V21.8661H15.7811L18.7549 24.8399Z" fill="#636363"/> 7470 </svg> 7471 `; 7472} 7473 7474// Full Player ( Mobile + Desktop ) 7475function reducePlayer(showMidiPlayer = null) { 7476 7477 const shouldReturnToMidi = showMidiPlayer === true 7478 || (showMidiPlayer === null && previousPlayerViewStatus === playerViewTypeEnum.PLAYER_MIDI); 7479 7480 if (shouldReturnToMidi) { 7481 minimizePlayer(); 7482 } 7483 7484 7485 const fullPlayerContainer = document.getElementById('fullPlayerContainer'); 7486 fullPlayerContainer.style.display = "none"; 7487 7488 // MOBILE Back to the first status ( no lyrics or episodes ) 7489 document.getElementById('songAlbumBigContainerMobile').style.display = "flex"; 7490 document.getElementById('songLyricsContainerMobile').style.display = "none"; 7491 document.getElementById('podcastEpisodesContainerMobile').style.display = "none"; 7492 7493 const songLyricsContainer = document.getElementById('songLyricsContainerFull'); 7494 if (songLyricsContainer) { 7495 songLyricsContainer.style.display = "none"; 7496 } 7497 const podcastEpisodeListContainer = document.getElementById('podcastEpisodeListContainerFull'); 7498 if (podcastEpisodeListContainer) { 7499 podcastEpisodeListContainer.style.display = "none"; 7500 } 7501 isPlayerExpanded = false; 7502 playerViewStatus = shouldReturnToMidi ? playerViewTypeEnum.PLAYER_MIDI : playerViewTypeEnum.PLAYER_REDUCED; 7503 lastNonExpandedPlayerViewStatus = playerViewStatus; 7504 updateFullPlayerButtons(player_status); 7505 playerUpdateUI(); 7506 7507 // After reducing, reinstall the event handlers 7508 setupPlayerControls(); 7509 7510 adjustPlayerElementsByPlayerView(playerViewStatus); 7511} 7512 7513function removeMinimizePlayerEffect() { 7514 document.getElementById("volumeControl").style.display = "flex"; 7515 document.getElementById("radioFavorite").style.display = "flex"; 7516 document.getElementById("minimizePLayer").style.display = "flex"; 7517 document.getElementById("playerFooterImage").classList.remove("album-art-midi"); 7518 document.getElementById("podcast-slider-container").classList.remove("hidden"); 7519 document.getElementById("podcastSectionForward").classList.remove("hidden"); 7520 7521 7522 let isLyricsExist = player_current_track?.lyrics_html?.length > 0; 7523 if (isRadioPlaying && isLyricsExist) { 7524 document.getElementById("radioLyricsButton").style.display = "flex"; 7525 } 7526 7527 document.getElementById("podcast-section-favorite-container").style.display = "flex"; 7528 document.getElementById("podcastEpisodesButton").classList.remove("hidden"); 7529 7530 const shouldHideMobilePodcastControls = isMobile() && playerViewStatus === playerViewTypeEnum.PLAYER_REDUCED; 7531 const shouldShowPodcastControls = active_player === playerTypeEnum.PODCAST 7532 && (player_status === playerStatusEnum.PLAYING || player_status === playerStatusEnum.PAUSED); 7533 const shouldHidePodcastControls = shouldHideMobilePodcastControls || !shouldShowPodcastControls; 7534 7535 setTimeout(() => { 7536 document.getElementById("podcastSectionForward").style.display = shouldHidePodcastControls ? "none" : "flex"; 7537 }, 300); 7538 7539 document.getElementById("podcastSectionRewind").style.display = shouldHidePodcastControls ? "none" : "flex"; 7540 document.getElementById("mobileFifteenSecond").style.display = shouldHidePodcastControls ? "none" : "flex"; 7541 document.getElementsByClassName("podcastSectionForwardContainer")[0].style.display = shouldHidePodcastControls ? "none" : "flex"; 7542 7543 setTimeout(() => { 7544 document.getElementById("footer-player")?.classList.remove("footer-player-midi"); 7545 document.getElementById("player-right-container").classList.remove("player-right-midi"); 7546 document.getElementById("player-center-container").classList.remove("player-right-midi"); 7547 document.querySelectorAll("#player-center-container button").forEach((button) => { 7548 button.classList.remove("player-button-midi"); 7549 }); 7550 7551 // reduce buttons size 7552 document.querySelectorAll("#player-center-container button").forEach((button) => { 7553 button.classList.remove("player-button-midi"); 7554 }); 7555 }, 0); 7556} 7557 7558function minimizePlayer() { 7559 if (isMobile()) { 7560 return; 7561 } 7562 7563 console.warn("minimize player here & hide other player toggle"); 7564 // Save MIDI state immediately so quick expand/ESC restores correctly. 7565 playerViewStatus = playerViewTypeEnum.PLAYER_MIDI; 7566 lastNonExpandedPlayerViewStatus = playerViewStatus; 7567 setTimeout(() => { 7568 adjustPlayerElementsByPlayerView(playerViewTypeEnum.PLAYER_MIDI
7568); 7569 }, 100); 7570} 7571 7572 7573function adjustPlayerElementsByPlayerView(playerType = playerViewTypeEnum.PLAYER_REDUCED) { 7574 const playerContent = document.getElementById('player-content'); 7575 switch (playerType) { 7576 case playerViewTypeEnum.PLAYER_REDUCED: 7577 case playerViewTypeEnum.PLAYER_EXPANDED: 7578 if (playerContent) { 7579 playerContent.setAttribute("onclick", "expandPlayer(false);"); 7580 } 7581 removeMinimizePlayerEffect(); 7582 break; 7583 7584 7585 case playerViewTypeEnum.PLAYER_MIDI: 7586 if (playerContent) { 7587 playerContent.setAttribute("onclick", "reducePlayer(false);"); 7588 } 7589 const footerPlayer = document.getElementById("footer-player"); 7590 const centerContainer = document.getElementById("player-center-container"); 7591 const rightContainer = document.getElementById("player-right-container"); 7592 const podcastForward = document.getElementById("podcastSectionForward"); 7593 const podcastSliderContainer = document.getElementById("podcast-slider-container"); 7594 const podcastEpisodesButtonContainer = document.getElementById("podcastEpisodesButton"); 7595 const podcastForwardContainer = document.getElementsByClassName("podcastSectionForwardContainer")[0]; 7596 7597 footerPlayer?.classList.add("footer-player-midi"); 7598 podcastSliderContainer?.classList.add("hidden"); 7599 podcastEpisodesButtonContainer?.classList.add("hidden"); 7600 podcastEpisodesButtonContainer?.classList.add("hidden"); 7601 7602 // reduce buttons size 7603 centerContainer?.querySelectorAll("button").forEach((button) => { 7604 button.classList.add("player-button-midi"); 7605 }); 7606 7607 [ 7608 "volumeControl", 7609 "radioFavorite", 7610 "minimizePLayer", 7611 "radioLyricsButton", 7612 "podcast-section-favorite-container", 7613 "podcastSectionForward", 7614 "podcastSectionRewind", 7615 "mobileFifteenSecond", 7616 ].forEach((id) => { 7617 const element = document.getElementById(id); 7618 if (element) { 7619 element.style.display = "none"; 7620 } 7621 }); 7622 7623 podcastForward?.classList.add("hidden"); 7624 if (podcastForwardContainer) { 7625 podcastForwardContainer.style.display = "none"; 7626 } 7627 7628 // reduce image size:gkj 7629 document.getElementById("playerFooterImage")?.classList.add("album-art-midi"); 7630 rightContainer?.classList.add("player-right-midi"); 7631 centerContainer?.classList.add("player-right-midi"); 7632 7633 break; 7634 7635 default: 7636 document.getElementById("playerFooterImage").classList.remove("album-art-midi"); 7637 removeMinimizePlayerEffect(); 7638 break; 7639 } 7640 try { localStorage.setItem("karnaval_player_view", playerViewStatus); } catch (e) {} 7641} 7642 7643function expandPlayer(withHiddenLyricsEpisodes = true) { 7644 const fullPlayerContainer = document.getElementById('fullPlayerContainer'); 7645 fullPlayerContainer.style.display = "flex"; 7646 isPlayerExpanded = true; 7647 previousPlayerViewStatus = lastNonExpandedPlayerViewStatus; 7648 playerViewStatus = playerViewTypeEnum.PLAYER_EXPANDED; 7649 updateFullPlayerButtons(player_status); 7650 if (active_player === playerTypeEnum.RADIO) { 7651 withHiddenLyricsEpisodes = false; // Force showing lyrics while expanding 7652 isRadioPlaying && toggleShowLyrics(withHiddenLyricsEpisodes); 7653 } else if (active_player === playerTypeEnum.PODCAST) { 7654 toggleShowEpisodeList(isMobile() ? true : null); 7655 //playerUpdateUI(); 7656 } 7657 7658 // After expanding, reinstall the event handlers 7659 setupPlayerControls(); 7660 adjustPlayerElementsByPlayerView(playerViewTypeEnum.PLAYER_EXPANDED); 7661 7662} 7663 7664function isRadioPlaying() { 7665 return active_player === playerTypeEnum.RADIO && player_status === "PLAYING"; 7666} 7667 7668function updateLyricsContent() { 7669 const currentSongLyrics = document.getElementById('currentSongLyrics'); 7670 // Updating lyrics when song changes 7671 if (currentSongLyrics) { 7672 currentSongLyrics.innerHTML = player_current_track?.lyrics_html; 7673 } 7674 7675 const currentSongLyricsMobile = document.getElementById('currentSongLyricsMobile'); 7676 // Updating lyrics when song changes 7677 if (currentSongLyricsMobile) { 7678 currentSongLyricsMobile.innerHTML = player_current_track?.lyrics_html; 7679 //todo: change song info also ( header of lyrics ). 7680 document.getElementById('songAlbumSmallContainerMobilePictureFullLyrics').src = player_current_track?.biography_image_16_9 ?? defaultPlaceHolderImage; 7681 document.getElementById('ArtistPodcasterNameMobileLyricsFullLyrics').textContent = player_current_track.artist; 7682 document.getElementById('SongEpisodeNameMobileLyricsFullLyrics').textContent = player_current_track.title; 7683 } 7684} 7685 7686function playerUpdateUI() { 7687 setupPlayerControls(); 7688 //Desktop 7689 document.getElementById('playerLoaderFull').style.display = "none" 7690 7691 const fullPlayerCurrentListenedRadioPodcast = document.getElementById("currentListenedRadioPodcastFull"); 7692 const fullPlayerYouAreListeningTo = document.getElementById("youAreListeningTo"); 7693 7694 7695 //DESKTOP - MOVING TEXT 7696 const songEpisodeNameFull = document.getElementById('song-episode-name-full'); 7697 7698 if (songEpisodeNameFull.scrollWidth > songEpisodeNameFull.clientWidth) { 7699 songEpisodeNameFull.classList.add('moving-text') 7700 } else { 7701 songEpisodeNameFull.classList.remove('moving-text') 7702 } 7703 7704 //MOBILE - MOVING TEXT 7705 const ArtistPodcasterNameMobileFull = document.getElementById('ArtistPodcasterNameMobileFull'); 7706 if (ArtistPodcasterNameMobileFull.scrollWidth > ArtistPodcasterNameMobileFull.clientWidth) { 7707 ArtistPodcasterNameMobileFull.classList.add('moving-text') 7708 } else { 7709 ArtistPodcasterNameMobileFull.classList.remove('moving-text') 7710 } 7711 7712 //MOBILE - MOVING TEXT - RADIO
7713 const ArtistPodcasterNameMobileMini = document.getElementById('footer-artist-song-name-section'); 7714 if (ArtistPodcasterNameMobileMini.scrollWidth > ArtistPodcasterNameMobileMini.clientWidth) { 7715 ArtistPodcasterNameMobileMini.classList.add('moving-text') 7716 } else { 7717 ArtistPodcasterNameMobileMini.classList.remove('moving-text') 7718 } 7719 7720 //MOBILE - MOVING TEXT - PODCAST 7721 const PodcasterEpisodeMobileMini = document.getElementById('footer-podcaster-episode-name-section'); 7722 if (PodcasterEpisodeMobileMini.scrollWidth > PodcasterEpisodeMobileMini.clientWidth) { 7723 PodcasterEpisodeMobileMini.classList.add('moving-text') 7724 } else { 7725 PodcasterEpisodeMobileMini.classList.remove('moving-text') 7726 } 7727 7728 if (active_player === "RADIO") { 7729 isActiveFavorite(); 7730 7731 // Lyrics 7732 updateIfLyricsExist(); 7733 updateLyricsContent(); 7734 if (!isLyricsExist) { 7735 disableLyricsButton(); 7736 if (isMobile()) { 7737 toggleShowEpisodeList(true); 7738 } 7739 } else { 7740 isShowCurrentSongLyrics ? enableLyricsButton() : hideLyricsButton(); 7741 } 7742 let albumArtFullImage = player_current_track.album_cover_art ? player_current_track.album_cover_art : player_current_track?.biography_image_16_9; 7743 if (!albumArtFullImage) { 7744 albumArtFullImage = active_station?.androidDefaultLogo || defaultPlaceHolderImage; 7745 } 7746 document.getElementById('albumArtFull').src = buildVersionedMediaImageUrl(albumArtFullImage); 7747 document.getElementById('artist-podcaster-name-full').textContent = player_current_track.artist; 7748 document.getElementById('song-episode-name-full').textContent = player_current_track.title; 7749 7750 document.getElementById('podcastProgressFullPlayer').style.display = 'none'; 7751 7752 // Mini Player 7753 // document.getElementById('radioSection').style.display = 'flex'; 7754 // document.getElementById('podcastSection').style.display = 'none'; 7755 7756 // hide list button for Podcast 7757 document.getElementById('podcastEpisodesButtonFull').style.display = 'none'; 7758 document.getElementById('radioLyricsButtonFull').style.display = 'block'; 7759 7760 // Hide rewind/forward buttons ( Podcast ) 7761 document.getElementById('playerRewindFull').style.display = "none"; 7762 document.getElementById('playerForwardFull').style.display = "none"; 7763 7764 document.getElementById('playerForwardFullMobile').style.display = "none"; 7765 document.getElementById('playerRewindFullMobile').style.display = "none"; 7766 7767 // Show slider 7768 document.getElementById('podcastSectionFullPlayer').style.display = "none !important"; 7769 document.getElementById('podcastSectionFullPlayerMobile').style.display = "none !important"; 7770 7771 7772 fullPlayerCurrentListenedRadioPodcast.textContent = active_station.title 7773 7774 // Player setting favorite button if station or show added to favorite 7775 //document.getElementById('setFavoriteRadio').style.fill = HERE_IS_FAVORITE ? '#ffffff' : '#636363'; 7776
7777 const songBackgroundContainer = document.getElementById('songBackgroundContainerFull'); 7778 songBackgroundContainer.style.display = "block"; 7779 songBackgroundContainer.classList.add("full-player-background-image") 7780 songBackgroundContainer.style.backgroundImage = "url(" + buildVersionedMediaImageUrl( player_current_track?.biography_image_16_9 ? player_current_track.biography_image_16_9 : active_station.backgroundImage ) + ")"; 7781 songBackgroundContainer.style.backgroundRepeat = "no-repeat"; 7782 songBackgroundContainer.style.backgroundSize = "cover"; 7783 songBackgroundContainer.style.backgroundPosition = "center"; 7784 7785 7786 ArtistPodcasterNameMobileFull.textContent = player_current_track.artist; 7787 7788 7789 document.getElementById('SongEpisodeNameMobileFull').textContent = player_current_track.title; 7790 7791 7792 // Picture Mobile 7793 // Without Lyrics 7794 const songAlbumBigContainerMobilePicture = document.getElementById('songAlbumBigContainerMobilePicture'); 7795 songAlbumBigContainerMobilePicture.style.backgroundImage = "url(" + buildVersionedMediaImageUrl(player_current_track?.biography_image_16_9 ?? defaultPlaceHolderImage) + ")"; 7796 7797 // Hide Podcast Episodes anyway 7798 document.getElementById('podcastEpisodeListContainerFull').style.display = 'none !important'; 7799 7800 document.getElementById('currentPlayingRadioPodcastMobileFull').textContent = active_station.title; 7801 7802 // BUTTONS Episodes/Lyrics 7803 document.getElementById('mobileLyricsButton').style.display = 'flex'; 7804 document.getElementById('mobileEpisodesButton').style.display = 'none'; 7805 7806 //Favorite 7807 document.getElementById('radioFavoriteMobile').style.display = 'flex'; 7808 document.getElementById('podcastFavoriteMobile').style.display = 'none'; 7809 7810 } else if (active_player === "PODCAST") { 7811 isActiveFavorite(); 7812 7813 // Episodes 7814 updateIfPodcastEpisodesExist(); 7815 if (!isEpisodesExist) { 7816 disablePodcastEpisodesButton(); 7817 } else { 7818 isShowCurrentPodcastEpisodes ? enablePodcastEpisodesButton() : hidePodcastEpisodesButton(); 7819 } 7820 isShowCurrentPodcastEpisodes ? enablePodcastEpisodesButton() : hidePodcastEpisodesButton(); 7821 7822 7823 //MOBILE 7824 const ArtistPodcasterNameMobileFull = document.getElementById('ArtistPodcasterNameMobileFull'); 7825 ArtistPodcasterNameMobileFull.textContent = player_current_track.artist; 7826 7827 document.getElementById('fullPlayerMobileRadioButtonIconStop').style.display = 'none'; 7828 document.getElementById('albumArtFull').src = buildVersionedMediaImageUrl(player_current_track.show?.thumbnailImageUrl ?? defaultPlaceHolderImage); 7829 document.getElementById('artist-podcaster-name-full').textContent = player_current_track.show?.subtitle; 7830 document.getElementById('song-episode-name-full').textContent = player_current_track.title; 7831 document.getElementById('podcast-name').textContent = player_current_track?.show.title; 7832 7833 // Show rewind/forward buttons 7834 document.getElementById('playerRewindFull').style.display = "block"; 7835 document.getElementById('playerForwardFull').style.display = "block"; 7836 7837 document.getElementById('songAlbumSmallContainerMobilePictureFullLyrics').src = player_current_track?.biography_image_16_9 ?? defaultPlaceHolderImage; 7838 document.getElementById('ArtistPodcasterNameMobileLyricsFullLyrics').textContent = player_current_track.artist; 7839 document.getElementById('SongEpisodeNameMobileLyricsFullLyrics').textContent = player_current_track.title; 7840 7841 // Show slider 7842 document.getElementById('podcastSectionFullPlayer').style.display = "block"; 7843 document.getElementById('podcastSectionFullPlayerMobile').style.display = "block"; 7844 7845 document.getElementById('podcastProgressFullPlayer').style.display = isPlayerExpanded ? 'flex' : 'none'; 7846 document.getElementById('podcastProgressFullPlayerMobile').style.display = isPlayerExpanded ? 'flex' : 'none'; 7847 7848 // hide lyrics button for Radio 7849 document.getElementById('radioLyricsButtonFull').style.display = 'none'; 7850 document.getElementById('podcastEpisodesButtonFull').style.display = 'flex'; 7851
7852 // Background Image 7853 const songBackgroundContainer = document.getElementById('songBackgroundContainerFull'); 7854 songBackgroundContainer.style.display = "block"; 7855 songBackgroundContainer.classList.add("full-player-background-image") 7856 songBackgroundContainer.style.backgroundImage = "url(" + buildVersionedMediaImageUrl(player_current_track?.biography_image_16_9 ?? active_station.backgroundImage ?? defaultPlaceHolderImage) + ")"; 7857 songBackgroundContainer.style.backgroundRepeat = "no-repeat"; 7858 songBackgroundContainer.style.backgroundSize = "cover"; 7859 songBackgroundContainer.style.backgroundPosition = "center"; 7860 7861 // Top Right 7862 document.getElementById('currentListenedRadioPodcastFull').textContent = player_current_track.show.title; 7863 fullPlayerYouAreListeningTo.innerHTML = `<svg style="margin-right: 5px;" width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg"> 7864 <path d="M9.5 19.5V12.225C9.2 12.0417 8.95833 11.8042 8.775 11.5125C8.59167 11.2208 8.5 10.8833 8.5 10.5C8.5 9.95 8.69583 9.47917 9.0875 9.0875C9.47917 8.69583 9.95 8.5 10.5 8.5C11.05 8.5 11.5208 8.69583 11.9125 9.0875C12.3042 9.47917 12.5 9.95 12.5 10.5C12.5 10.8833 12.4083 11.225 12.225 11.525C12.0417 11.825 11.8 12.0583 11.5 12.225V19.5C11.5 19.7833 11.4042 20.0208 11.2125 20.2125C11.0208 20.4042 10.7833 20.5 10.5 20.5C10.2167 20.5 9.97917 20.4042 9.7875 20.2125C9.59583 20.0208 9.5 19.7833 9.5 19.5ZM4.325 17.025C4.125 17.225 3.88333 17.325 3.6 17.325C3.31667 17.325 3.08333 17.2167 2.9 17C2.15 16.1167 1.5625 15.125 1.1375 14.025C0.7125 12.925 0.5 11.75 0.5 10.5C0.5 9.11667 0.7625 7.81667 1.2875 6.6C1.8125 5.38333 2.525 4.325 3.425 3.425C4.325 2.525 5.38333 1.8125 6.6 1.2875C7.81667 0.7625 9.11667 0.5 10.5 0.5C11.8833 0.5 13.1833 0.7625 14.4 1.2875C15.6167 1.8125 16.675 2.525 17.575 3.425C18.475 4.325 19.1875 5.38333 19.7125 6.6C20.2375 7.81667 20.5 9.11667 20.5 10.5C20.5 11.75 20.2875 12.925 19.8625 14.025C19.4375 15.125 18.85 16.1167 18.1 17C17.9167 17.2167 17.6875 17.3292 17.4125 17.3375C17.1375 17.3458 16.9 17.25 16.7 17.05C16.5167 16.8667 16.425 16.6333 16.425 16.35C16.425 16.0667 16.5167 15.8167 16.7 15.6C17.2667 14.9 17.7083 14.1167 18.025 13.25C18.3417 12.3833 18.5 11.4667 18.5 10.5C18.5 8.26667 17.725 6.375 16.175 4.825C14.625 3.275 12.7333 2.5 10.5 2.5C8.26667 2.5 6.375 3.275 4.825 4.825C3.275 6.375 2.5 8.26667 2.5 10.5C2.5 11.4667 2.65833 12.3792 2.975 13.2375C3.29167 14.0958 3.74167 14.875 4.325 15.575C4.50833 15.7917 4.60417 16.0375 4.6125 16.3125C4.62083 16.5875 4.525 16.825 4.325 17.025ZM7.15 14.2C6.95 14.4 6.70833 14.5042 6.425 14.5125C6.14167 14.5208 5.91667 14.4083 5.75 14.175C5.36667 13.6583 5.0625 13.0917 4.8375 12.475C4.6125 11.8583 4.5 11.2 4.5 10.5C4.5 8.83333 5.08333 7.41667 6.25 6.25C7.41667 5.08333 8.83333 4.5 10.5 4.5C12.1667 4.5 13.5833 5.08333 14.75 6.25C15.9167 7.41667 16.5 8.83333 16.5 10.5C16.5 11.2 16.3875 11.8625 16.1625 12.4875C15.9375 13.1125 15.6333 13.675 15.25 14.175C15.0833 14.3917 14.8583 14.5042 14.575 14.5125C14.2917 14.5208 14.05 14.425 13.85 14.225C13.6667 14.0417 13.5708 13.8083 13.5625 13.525C13.5542 13.2417 13.6333 12.9833 13.8 12.75C14.0167 12.4167 14.1875 12.0625 14.3125 11.6875C14.4375 11.3125 14.5 10.9167 14.5 10.5C14.5 9.4 14.1083 8.45833 13.325 7.675C12.5417 6.89167 11.6 6.5 10.5 6.5C9.4 6.5 8.45833 6.89167 7.675 7.675C6.89167 8.45833 6.5 9.4 6.5 10.5C6.5 10.9333 6.5625 11.3333 6.6875 11.7C6.8125 12.0667 6.98333 12.4167 7.2 12.75C7.36667 12.9833 7.44583 13.2375 7.4375 13.5125C7.42917 13.7875 7.33333 14.0167 7.15 14.2Z" fill="#636363"/> 7865 </svg> DinlediÄin podcast:`; 7866 7867 // MOBILE 7868 document.getElementById('currentPlayingRadioPodcastMobileFull').textContent = player_current_track.show.title; 7869 7870 // Background Image
7871 const songBackgroundContainerMobile = document.getElementById('songAlbumBigContainerMobilePicture'); 7872 songBackgroundContainerMobile.style.display = "block"; 7873 songBackgroundContainerMobile.classList.add("full-player-background-image") 7874 songBackgroundContainerMobile.style.backgroundImage = "url(" + buildVersionedMediaImageUrl(player_current_track?.biography_image_16_9 ?? defaultPlaceHolderImage) + ")"; 7875 songBackgroundContainerMobile.style.backgroundRepeat = "no-repeat"; 7876 songBackgroundContainerMobile.style.backgroundSize = "cover"; 7877 songBackgroundContainerMobile.style.backgroundPosition = "center"; 7878 7879 document.getElementById('ArtistPodcasterNameMobileFull').textContent = player_current_track.title; 7880 document.getElementById('SongEpisodeNameMobileFull').textContent = player_current_track.artist; 7881 7882 // With Episodes 7883 document.getElementById('songAlbumSmallContainerMobilePictureFullEpisodes').src = player_current_track?.biography_image_16_9 ?? defaultPlaceHolderImage; 7884 document.getElementById('ArtistPodcasterNameMobileLyricsFullEpisodes').textContent = player_current_track.artist; 7885 document.getElementById('SongEpisodeNameMobileLyricsFullEpisodes').textContent = player_current_track.title; 7886 7887 7888 // BUTTONS 7889 // Episodes/Lyrics 7890 document.getElementById('mobileLyricsButton').style.display = 'none'; 7891 document.getElementById('mobileEpisodesButton').style.display = 'flex'; 7892 7893 document.getElementById('playerForwardFullMobile').style.display = "block"; 7894 document.getElementById('playerRewindFullMobile').style.display = "block"; 7895 7896 //Favorite 7897 document.getElementById('radioFavoriteMobile').style.display = 'none'; 7898 document.getElementById('podcastFavoriteMobile').style.display = 'flex'; 7899 } 7900 updateFullPlayerButtons(player_status); 7901} 7902 7903function updateMiniPlayerPlayingButtons() { 7904 erasePreviousMiniVisibilityClass(); 7905 if (active_player === "RADIO") { 7906 updateFifteenSecondsVisibilityButtons("hidden"); 7907 switch (player_status) { 7908 case "PLAYING": 7909 document.getElementById('playButton').classList.add('hidden'); 7910 document.getElementById('playButton').classList.remove('visible'); 7911 document.getElementById('playButton').style.display = 'none'; 7912 7913 document.getElementById('stopButton').classList.add('visible'); 7914 document.getElementById('stopButton').classList.remove('hidden'); 7915 document.getElementById('stopButton').style.display = 'flex'; 7916 7917 document.getElementById('mvp_loader').classList.add('hidden'); 7918 document.getElementById('mvp_loader').classList.remove('visible'); 7919 document.getElementById('mvp_loader').style.display = 'none'; 7920 break; 7921 7922 case "PAUSED": 7923 document.getElementById('playButton').classList.add('visible'); 7924 document.getElementById('playButton').classList.remove('hidden'); 7925 document.getElementById('playButton').style.display = 'flex'; 7926 7927 document.getElementById('stopButton').classList.add('hidden'); 7928 document.getElementById('stopButton').classList.remove('visible'); 7929 document.getElementById('stopButton').style.display = 'none'; 7930 7931 document.getElementById('mvp_loader').classList.add('hidden'); 7932 document.getElementById('mvp_loader').classList.remove('visible'); 7933 document.getElementById('mvp_loader').style.display = 'none'; 7934 break; 7935 7936 case "STOPPED": 7937 document.getElementById('playButton').classList.add('visible'); 7938 document.getElementById('playButton').classList.remove('hidden'); 7939 document.getElementById('playButton').style.display = 'flex'; 7940 7941 document.getElementById('stopButton').classList.add('hidden'); 7942 document.getElementById('stopButton').classList.remove('visible'); 7943 document.getElementById('stopButton').style.display = 'none'; 7944 7945 document.getElementById('mvp_loader').classList.add('hidden'); 7946 document.getElementById('mvp_loader').classList.remove('visible'); 7947 document.getElementById('mvp_loader').style.display = 'none'; 7948 break; 7949 7950 case "LOADING": 7951 document.getElementById('playButton').classList.add('hidden'); 7952 document.getElementById('playButton').classList.remove('visible'); 7953 document.getElementById('playButton').style.display = 'none'; 7954 7955 document.getElementById('stopButton').classList.add('hidden'); 7956 document.getElementById('stopButton').classList.remove('visible'); 7957 document.getElementById('stopButton').style.display = 'none'; 7958 7959 document.getElementById('mvp_loader').classList.add('visible'); 7960 document.getElementById('mvp_loader').classList.remove('hidden'); 7961 document.getElementById('mvp_loader').style.display = 'flex'; 7962 break; 7963 7964 default: 7965 erasePreviousMiniVisibilityClass(); 7966 break; 7967 } 7968 } else if (active_player == "PODCAST") { 7969 updateFifteenSecondsVisibilityButtons("visible"); 7970 switch (player_status) { 7971 case "PLAYING": 7972 document.getElementById('playButton').classList.add('hidden'); 7973 document.getElementById('playButton').classList.remove('visible'); 7974 document.getElementById('playButton').style.display = 'none'; 7975 7976 document.getElementById('pauseButton').classList.add('visible'); 7977 document.getElementById('pauseButton').classList.remove('hidden'); 7978 document.getElementById('pauseButton').style.display = 'flex'; 7979 7980 document.getElementById('stopButton').classList.add('hidden'); 7981 document.getElementById('stopButton').classList.remove('visible'); 7982 document.getElementById('stopButton').style.display = 'none'; 7983 7984 document.getElementById('mvp_loader').classList.add('hidden'); 7985 document.getElementById('mvp_loader').classList.remove('visible'); 7986 document.getElementById('mvp_loader').style.display = 'none'; 7987 7988 document.getElementById('podcastSectionForward').classList.add('visible'); 7989 document.getElementById('podcastSectionRewind').classList.add('visible'); 7990 break; 7991 7992 case "PAUSED": 7993 document.getElementById('playButton').classList.add('visible'); 7994 document.getElementById('playButton').classList.remove('hidden'); 7995 document.getElementById('playButton').style.display = 'flex'; 7996 7997 7998 document.getElementById('pauseButton').classList.add('hidden'); 7999 document.getElementById('pauseButton').classList.remove('visible'); 8000 document.getElementById('pauseButton').style.display = 'none'; 8001 8002 document.getElementById('stopButton').classList.add('hidden'); 8003 document.getElementById('stopButton').classList.remove('visible'); 8004 document.getElementById('stopButton').style.display = 'none'; 8005 8006 document.getElementById('mvp_loader').classList.add('hidden'); 8007 document.getElementById('mvp_loader').classList.remove('visible'); 8008 document.getElementById('mvp_loader').style.display = 'none'; 8009 8010 document.getElementById('podcastSectionForward').classList.add('visible'); 8011 document.getElementById('podcastSectionRewind').classList.add('visible'); 8012 break; 8013 8014 case "STOPPED": 8015 document.getElementById('playButton').classList.add('visible'); 8016 document.getElementById('playButton').classList.remove('hidden'); 8017 document.getElementById('playButton').style.display = 'flex'; 8018 8019 document.getElementById('pauseButton').classList.add('hidden'); 8020 document.getElementById('pauseButton').classList.remove('visible'); 8021 document.getElementById('pauseButton').style.display = 'none'; 8022 8023 document.getElementById('stopButton').classList.add('hidden'); 8024 document.getElementById('stopButton').classList.remove('visible'); 8025 document.getElementById('stopButton').style.display = 'none'; 8026 8027 document.getElementById('mvp_loader').classList.add('hidden'); 8028 document.getElementById('mvp_loader').classList.remove('visible'); 8029 document.getElementById('mvp_loader').style.display = 'none'; 8030 break; 8031 8032 case "LOADING": 8033 document.getElementById('playButton').classList.add('hidden'); 8034 document.getElementById('playButton').classList.remove('visible'); 8035 document.getElementById('playButton').style.display = 'none'; 8036 8037 document.getElementById('stopButton').classList.add('hidden'); 8038 document.getElementById('stopButton').classList.remove('visible'); 8039 document.getElementById('stopButton').style.display = 'none'; 8040 8041 8042 document.getElementById('pauseButton').classList.add('hidden'); 8043 document.getElementById('pauseButton').classList.remove('visible'); 8044 document.getElementById('pauseButton').style.display = 'none'; 8045 8046 document.getElementById('mvp_loader').classList.add('visible'); 8047 document.getElementById('mvp_loader').classList.remove('hidden'); 8048 document.getElementById('mvp_loader').style.display = 'flex'; 8049 break; 8050 8051 default: 8052 // Initial refresh state for podcast: keep play control visible. 8053 document.getElementById('playButton').classList.add('visible'); 8054 document.getElementById('playButton').classList.remove('hidden'); 8055 document.getElementById('playButton').style.display = 'flex'; 8056 document.getElementById('pauseButton').classList.add('hidden'); 8057 document.getElementById('pauseButton').classList.remove('visible'); 8058 document.getElementById('pauseButton').style.display = 'none'; 8059 document.getElementById('stopButton').classList.add('hidden'); 8060 document.getElementById('stopButton').classList.remove('visible'); 8061 document.getElementById('stopButton').style.display = 'none'; 8062 document.getElementById('mvp_loader').classList.add('hidden'); 8063 document.getElementById('mvp_loader').classList.remove('visible'); 8064 document.getElementById('mvp_loader').style.display = 'none'; 8065 break; 8066 } 8067 } 8068} 8069 8070function updateFifteenSecondsVisibilityButtons(visibility) { 8071 const podcastForward = document.getElementById('podcastSectionForward'); 8072 const podcastRewind = document.getElementById('podcastSectionRewind'); 8073 const mobileFifteenSecond = document.getElementById('mobileFifteenSecond'); 8074 const podcastForwardContainer = document.getElementsByClassName("podcastSectionForwardContainer")[0]; 8075 8076 // Mobile reduced player: keep these controls hidden. 8077 if (isMobile() && playerViewStatus === playerViewTypeEnum.PLAYER_REDUCED) { 8078 podcastForward?.classList.remove('visible'); 8079 podcastRewind?.classList.remove('visible'); 8080 podcastForward?.classList.add('hidden'); 8081 podcastRewind?.classList.add('hidden'); 8082 document.getElementById('mobileFifteenSecond').style.display = "none"; 8083 document.getElementsByClassName("podcastSectionForwardContainer")[0].style.display = "none"; 8084 return; 8085 } 8086 8087 if ("visible" === visibility) { 8088 podcastForward?.classList.add('visible'); 8089 podcastRewind?.classList.add('visible'); 8090 podcastForward?.classList.remove('hidden'); 8091 podcastRewind?.classList.remove('hidden'); 8092 if (mobileFifteenSecond) { 8093 mobileFifteenSecond.style.display = "flex"; 8094 } 8095 if (podcastForwardContainer) { 8096 podcastForwardContainer.style.display = "flex"; 8097 } 8098 // Clear stale inline display:none from previous transitions. 8099 if (podcastForward) { 8100 podcastForward.style.display = "flex"; 8101 } 8102 if (podcastRewind) { 8103 podcastRewind.style.display = "flex"; 8104 } 8105 } else if ("hidden" === visibility) { 8106 podcastForward?.classList.remove('visible'); 8107 podcastRewind?.classList.remove('visible'); 8108 podcastForward?.classList.add('hidden'); 8109 podcastRewind?.classList.add('hidden'); 8110 } 8111} 8112 8113function updateFullPlayerButtons(status = playerStatusEnum.STOPPED) { 8114 if (active_player === playerTypeEnum.RADIO) { 8115 erasePreviousVisibilityClass(); 8116 8117 isLyricsExist = player_current_track?.lyrics_html?.length > 0; 8118 8119 // playerUpdateUI(); 8120 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.add('hidden'); 8121 document.getElementById('pauseButtonFull').classList.add('hidden'); 8122 8123 8124 // document.getElementById('radioLyricsIconPath').classList.add('disabled-button'); 8125 8126 switch (status) { 8127 case "PLAYING": 8128 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('hidden'); 8129 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.add('visible'); 8130 8131 document.getElementById('playButtonFull').classList.add('hidden'); 8132 document.getElementById('stopButtonFull').classList.add('visible'); 8133 break; 8134 case "STOPPED": 8135 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('visible'); 8136 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.add('hidden'); 8137 8138 document.getElementById('playButtonFull').classList.add('visible'); 8139 document.getElementById('stopButtonFull').classList.add('hidden'); 8140 break; 8141 case "PAUSED": 8142 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('hidden'); 8143 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.add('hidden'); 8144 8145 document.getElementById('playButtonFull').classList.add('hidden'); 8146 document.getElementById('stopButtonFull').classList.add('hidden'); 8147 break; 8148 } 8149 } else if (active_player === "PODCAST") { 8150 8151 erasePreviousVisibilityClass(); 8152 8153 // hide stop button - full desktop & mobile 8154 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.add('hidden'); 8155 document.getElementById('stopButtonFull').classList.add('hidden'); 8156 8157 switch (status) { 8158 case "PLAYING": 8159 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('hidden'); 8160 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.add('visible'); 8161 8162 document.getElementById('playButtonFull').classList.add('hidden'); 8163 document.getElementById('pauseButtonFull').classList.add('visible'); 8164 break; 8165 case "STOPPED": 8166 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('visible'); 8167 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.add('hidden'); 8168 8169 document.getElementById('playButtonFull').classList.add('visible'); 8170 document.getElementById('pauseButtonFull').classList.add('hidden'); 8171 break; 8172 case "PAUSED": 8173 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.add('visible'); 8174 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.add('hidden'); 8175 8176 document.getElementById('playButtonFull').classList.add('visible'); 8177 document.getElementById('pauseButtonFull').classList.add('hidden'); 8178 break; 8179 } 8180 } 8181} 8182 8183functi
8183on setupPlayerControls() { 8184 const playerContent = document.getElementById('player-content'); 8185 8186 // Function to disable parent onClick for a specific child element 8187 function disableParentOnClickForChild(childId) { 8188 const childElement = document.getElementById(childId); 8189 8190 if (childElement && playerContent) { 8191 // Remove any existing event listeners first to avoid duplicates 8192 const existingEnterListener = childElement._mouseenterListener; 8193 const existingLeaveListener = childElement._mouseleaveListener; 8194 const existingClickListener = childElement._clickStopPropagationListener; 8195 8196 if (existingEnterListener) { 8197 childElement.removeEventListener('mouseenter', existingEnterListener); 8198 } 8199 8200 if (existingLeaveListener) { 8201 childElement.removeEventListener('mouseleave', existingLeaveListener); 8202 } 8203 if (existingClickListener) { 8204 childElement.removeEventListener('click', existingClickListener); 8205 } 8206 8207 // Define new event listeners 8208 const mouseenterListener = function (e) { 8209 // Store the original onclick attribute of the parent 8210 playerContent.setAttribute('data-original-onclick', playerContent.getAttribute('onclick')); 8211 // Remove the onclick attribute from the parent 8212 playerContent.removeAttribute('onclick'); 8213 // Prevent event from bubbling up to parent 8214 e.stopPropagation(); 8215 }; 8216 8217 const mouseleaveListener = function () { 8218 // Restore the original onclick attribute, or use the default if not available 8219 // const originalOnclick = playerContent.getAttribute('data-original-onclick'); 8220 if (playerViewStatus === playerViewTypeEnum.PLAYER_MIDI) { 8221 playerContent.setAttribute("onclick", "reducePlayer(false);"); 8222 } else { 8223 playerContent.setAttribute("onclick", "expandPlayer(false);"); 8224 } 8225 }; 8226 const clickStopPropagationListener = function (e) { 8227 // Prevent click event from notifying the parent element 8228 e.stopPropagation(); 8229 }; 8230 8231 8232 // Store listeners for potential future removal 8233 childElement._mouseenterListener = mouseenterListener; 8234 childElement._mouseleaveListener = mouseleaveListener; 8235 childElement._clickStopPropagationListener = clickStopPropagationListener; 8236 8237 // Add the event listeners 8238 childElement.addEventListener('mouseenter', mouseenterListener); 8239 childElement.addEventListener('mouseleave', mouseleaveListener); 8240 childElement.addEventListener('click', clickStopPropagationListener); 8241 } 8242 } 8243 8244 // Array of child IDs to disable parent onClick when hovering 8245 const childIds = [ 8246 'playButton', 'stopButton', 'muteButton', 'pauseButton', 'onMute', 'mobileFifteenSecond', 'mvp_loader', 'volumeControl', 8247 'radio-section-favorite-container', 'podcast-section-favorite-container', 'podcastEpisodesButton', 'radioLyricsButton', 8248 'expandPlayerFull', 'minimizePLayer', 'minimizePLayerFull', 'radioSection', 'podcastSection', 'mutedVolume', 'podcastSectionForward', 'podcastSectionRewind', 'onMute', 'mutedVolume', 'volumeSlider' 8249 ]; // all relevant IDs 8250 8251 // Loop through each ID and apply the function 8252 childIds.forEach(function (childId) { 8253 disableParentOnClickForChild(childId); 8254 }); 8255 8256 // Handle full player container 8257 const fullPlayerContent = document.getElementById("playerContentHolderFull"); 8258 if (fullPlayerContent) { 8259 const fullPlayerChildIds = [ 8260 'radioFavoriteFull', 'playButtonFull', 'volumeControlFull', 'reducePlayerFull', 'radioSection', 'podcast-section-favorite-container-full', 'podcastEpisodesButtonFull', 'radioLyricsButtonFull', 8261 'playerRewindFull', 'playButtonFull', 'playerLoaderFull', 'stopButtonFull', 'pauseButtonFull', 'playerForwardFull', 'podcastSectionFullPlayer' 8262 ] 8263 fullPlayerChildIds.forEach(function (childId) { 8264 const childElement = document.getElementById(childId); 8265 if (childElement) { 8266 const mouseenterListener = function (e) { 8267 fullPlayerContent.setAttribute( 8268 "data-original-onclick", 8269 fullPlayerContent.getAttribute("onclick") 8270 ); 8271 fullPlayerContent.removeAttribute("onclick"); 8272 e.stopPropagation(); 8273 }; 8274 8275 const mouseleaveListener = function () { 8276 fullPlayerContent.setAttribute("onclick", "reducePlayer();"); 8277 }; 8278
8279 childElement.addEventListener("mouseenter", mouseenterListener); 8280 childElement.addEventListener("mouseleave", mouseleaveListener); 8281 } 8282 }); 8283 } 8284} 8285 8286// Initial setup when DOM is loaded 8287document.addEventListener('DOMContentLoaded', function () { 8288 setupPlayerControls(); 8289 try { 8290 const saved = localStorage.getItem("karnaval_player_view"); 8291 if (saved === playerViewTypeEnum.PLAYER_MIDI && !isMobile()) minimizePlayer(); 8292 else if (saved === playerViewTypeEnum.PLAYER_EXPANDED) expandPlayer(false); 8293 } catch (e) {} 8294}); 8295 8296function erasePreviousVisibilityClass() { 8297 // Mobile 8298 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.remove('visible'); 8299 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.remove('visible'); 8300 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.remove('visible'); 8301 8302 8303 document.getElementById('fullPlayerMobileRadioButtonIconPlay').classList.remove('hidden'); 8304 document.getElementById('fullPlayerMobileRadioButtonIconStop').classList.remove('hidden'); 8305 document.getElementById('fullPlayerMobileRadioButtonIconPause').classList.remove('hidden'); 8306 8307 // Desktop - full 8308 document.getElementById('playButtonFull').classList.remove('visible'); 8309 document.getElementById('pauseButtonFull').classList.remove('visible'); 8310 document.getElementById('stopButtonFull').classList.remove('visible'); 8311 8312 8313 document.getElementById('playButtonFull').classList.remove('hidden'); 8314 document.getElementById('pauseButtonFull').classList.remove('hidden'); 8315 document.getElementById('stopButtonFull').classList.remove('hidden'); 8316 8317} 8318 8319function erasePreviousMiniVisibilityClass() { 8320 document.getElementById('playButton').classList.remove('hidden'); 8321 document.getElementById('playButton').classList.add('visible'); 8322 8323 document.getElementById('stopButton').classList.remove('visible'); 8324 document.getElementById('stopButton').classList.add('hidden'); 8325 8326 8327 document.getElementById('pauseButton').classList.remove('visible'); 8328 document.getElementById('pauseButton').classList.add('hidden'); 8329 8330 document.getElementById('mvp_loader').classList.remove('visible'); 8331 document.getElementById('mvp_loader').classList.add('hidden'); 8332} 8333 8334// Player Volume Sync 8335const volumeSlider = document.getElementById('volumeSlider'); 8336const volumeSliderFull = document.getElementById('volumeSliderFull'); 8337 8338// Universal volume control function 8339function setVolumeNew(value, source) { 8340 // Update both sliders 8341 if (source !== volumeSlider) { 8342 volumeSlider.value = value; 8343 updateMuteUI(volumeSlider, value); // Update mini-player slider's UI 8344 } 8345 if (source !== volumeSliderFull) { 8346 volumeSliderFull.value = value; 8347 updateMuteUI(volumeSliderFull, value); // Update full-player slider's UI 8348 } 8349 8350 player_volume = Number(value) / 100; 8351} 8352 8353// Unified mute UI updater 8354function updateMuteUI(slider, value) { 8355 const isFull = slider.id === 'volumeSliderFull'; 8356 const muteElements = { 8357 onMute: document.getElementById(isFull ? 'onMuteFull' : 'onMute'), 8358 mutedVolume: document.getElementById(isFull ? 'mutedVolumeFull' : 'mutedVolume') 8359 }; 8360 8361 const numericValue = parseInt(value, 10); 8362 if (numericValue === 0 || numericValue === 1) { 8363 muteElements.onMute.classList.add('hidden'); 8364 muteElements.mutedVolume.classList.remove('hidden'); 8365 player_mute(1); 8366 } else { 8367 muteElements.onMute.classList.remove('hidden'); 8368 muteElements.mutedVolume.classList.add('hidden'); 8369 player_mute(numericValue); 8370 } 8371} 8372 8373// Event listeners for both sliders
8374[volumeSlider, volumeSliderFull].forEach(slider => { 8375 slider.addEventListener('input', (e) => { 8376 setVolumeNew(e.target.value, e.target); 8377 }); 8378}); 8379 8380// "ESC" Keyboard handler - Reduce Full player 8381document.addEventListener('keydown', (event) => { 8382 if (event.key === 'Escape' && isPlayerExpanded) { 8383 reducePlayer(); 8384 } 8385}); 8386 8387/* 8388 * Home Page Carousel Functionality 8389 * Handles the homepage carousel with main and side carousel items 8390 */ 8391function initHomeCarousel() { 8392 const mainCarousel = document.querySelector(".main-carousel"); 8393 const leftCarousel = document.querySelector(".left-carousel"); 8394 const rightCarousel = document.querySelector(".right-carousel"); 8395 const dots = document.querySelectorAll(".carousel-dots .dot"); 8396 8397 if (!mainCarousel) return; // Exit if carousel doesn't exist 8398 8399 const items = document.querySelectorAll(".main-carousel .carousel-item"); 8400 const totalItems = items.length; 8401 let currentIndex = 0; 8402 let autoplayInterval; 8403 8404 // Function to update carousel 8405 function updateCarousel(newIndex) { 8406 // Ensure newIndex is within bounds 8407 newIndex = (newIndex + totalItems) % totalItems; 8408 8409 // Update main carousel 8410 document 8411 .querySelector(".main-carousel .carousel-item.active") 8412 .classList.remove("active"); 8413 items[newIndex].classList.add("active"); 8414 8415 // Update dots 8416 document 8417 .querySelector(".carousel-dots .dot.active") 8418 .classList.remove("active"); 8419 dots[newIndex].classList.add("active"); 8420 8421 // Update side carousels 8422 const prevIndex = (newIndex - 1 + totalItems) % totalItems; 8423 const nextIndex = (newIndex + 1) % totalItems; 8424 8425 if (leftCarousel) { 8426 const prevItem = window.primary_carousel_items[prevIndex]; 8427 leftCarousel.querySelector( 8428 ".carousel-item" 8429 ).innerHTML = `<a href="${prevItem.url}"><img src="${prevItem.url_thumbnail}?${prevItem.thumbnail_qs}" alt="${prevItem.title}"></a>`; 8430 } 8431 8432 if (rightCarousel) { 8433 const nextItem = window.primary_carousel_items[nextIndex]; 8434 rightCarousel.querySelector( 8435 ".carousel-item" 8436 ).innerHTML = `<a href="${nextItem.url}"><img src="${nextItem.url_thumbnail}?${nextItem.thumbnail_qs}" alt="${nextItem.title}"></a>`; 8437 } 8438 8439 currentIndex = newIndex; 8440 } 8441 8442 // Initialize side carousel click events 8443 if (leftCarousel) { 8444 leftCarousel.addEventListener("click", function () { 8445 const newIndex = (currentIndex - 1 + totalItems) % totalItems; 8446 updateCarousel(newIndex); 8447 resetAutoplay(); 8448 }); 8449 } 8450 8451 if (rightCarousel) { 8452 rightCarousel.addEventListener("click", function () { 8453 const newIndex = (currentIndex + 1) % totalItems; 8454 updateCarousel(newIndex); 8455 resetAutoplay(); 8456 }); 8457 } 8458 8459 // Initialize dot navigation 8460 dots.forEach(function (dot, index) { 8461 dot.addEventListener("click", function () { 8462 updateCarousel(index); 8463 resetAutoplay(); 8464 }); 8465 }); 8466 8467 // Mobile swipe functionality 8468 let touchStartX = 0; 8469 let touchEndX = 0; 8470 8471 mainCarousel.addEventListener( 8472 "touchstart", 8473 function (e) { 8474 touchStartX = e.changedTouches[0].screenX; 8475 }, 8476 false 8477 ); 8478 8479 mainCarousel.addEventListener( 8480 "touchend", 8481 function (e) { 8482 touchEndX = e.changedTouches[0].screenX; 8483 handleSwipe(); 8484 }, 8485 false 8486 ); 8487 8488 function handleSwipe() { 8489 if (touchEndX < touchStartX) { 8490 // Swipe left - go to next 8491 const newIndex = (currentIndex + 1) % totalItems; 8492 updateCarousel(newIndex); 8493 } else if (touchEndX > touchStartX) { 8494 // Swipe right - go to previous 8495 const newIndex = (currentIndex - 1 + totalItems) % totalItems; 8496 updateCarousel(newIndex); 8497 } 8498 resetAutoplay(); 8499 } 8500 8501 // Autoplay functionality 8502 function startAutoplay() { 8503 autoplayInterval = setInterval(function () { 8504 const newIndex = (currentIndex + 1) % totalItems; 8505 updateCarousel(newIndex); 8506 }, 10000); 8507 } 8508 8509 function resetAutoplay() { 8510 clearInterval(autoplayInterval); 8511 startAutoplay(); 8512 } 8513 8514 // Initialize autoplay 8515 startAutoplay(); 8516} 8517 8518// For testing 8519function toggleCarouselGradient(show) { 8520 const carouselWrapper = document.querySelector(".carousel-wrapper"); 8521 if (!carouselWrapper) return; 8522 8523 if (show) { 8524 carouselWrapper.style.setProperty("--gradient-opacity", "1"); 8525 } else { 8526 carouselWrapper.style.setProperty("--gradient-opacity", "0"); 8527 } 8528} 8529 8530// Initialize the carousel when DOM is loaded 8531document.addEventListener("DOMContentLoaded", function () { 8532 initHomeCarousel(); 8533}); 8534 8535function initializeCarousel() { 8536 // Check if Swiper is already initialized on this element 8537 if ( 8538 document.querySelector(".swiper") && 8539 !document.querySelector(".swiper").swiper 8540 ) { 8541 const swiper = new Swiper(".swiper", { 8542 slidesPerView: "auto", 8543 centeredSlides: true, 8544 loop: true, 8545 spaceBetween: 8, 8546 breakpoints: { 8547 768: { 8548 spaceBetween: 16, 8549 }, 8550 }, 8551 watchSlidesProgress: true, 8552 watchSlidesVisibility: true, 8553 autoplay: { 8554 delay: 10000, 8555 disableOnInteraction: false, 8556 waitForTransition: false, 8557 }, 8558 pagination: { 8559 el: ".swiper-pagination", 8560 clickable: true, 8561 renderBullet: function (index, className) { 8562 return ( 8563 '<span class="' + 8564 className + 8565 '" role="button" aria-label="Go to slide ' + 8566 (index + 1) + 8567 '"></span>' 8568 ); 8569 }, 8570 }, 8571 navigation: { 8572 nextEl: ".swiper-button-next", 8573 prevEl: ".swiper-button-prev", 8574 }, 8575 grabCursor: true,
8576 speed: 800, 8577 effect: "slide", 8578 on: { 8579 init: function () { 8580 // Add aria-label to each slide 8581 const slides = this.slides; 8582 slides.forEach((slide, index) => { 8583 slide.setAttribute( 8584 "aria-label", 8585 "Slide " + (index + 1) + " of " + slides.length 8586 ); 8587 slide.setAttribute("role", "group"); 8588 slide.setAttribute("aria-roledescription", "slide"); 8589 }); 8590 }, 8591 slideChangeTransitionEnd: function () { 8592 this.update(); 8593 this.updateSlides(); 8594 this.updateProgress(); 8595 this.updateSlidesClasses(); 8596 8597 // Update aria-label for active slide 8598 const activeSlide = this.slides[this.activeIndex]; 8599 if (activeSlide) { 8600 activeSlide.setAttribute("aria-hidden", "false"); 8601 this.slides.forEach((slide, index) => { 8602 if (index !== this.activeIndex) { 8603 slide.setAttribute("aria-hidden", "true"); 8604 } 8605 }); 8606 } 8607 }, 8608 }, 8609 }); 8610 8611 // Add autoplay control functionality 8612 const autoplayToggle = document.getElementById("swiperAutoplayToggle"); 8613 if (autoplayToggle) { 8614 let isAutoplayActive = true; 8615 autoplayToggle.addEventListener("click", function () { 8616 if (isAutoplayActive) { 8617 swiper.autoplay.stop(); 8618 this.textContent = "Play"; 8619 this.classList.add("paused"); 8620 } else { 8621 swiper.autoplay.start(); 8622 this.textContent = "Pause"; 8623 this.classList.remove("paused"); 8624 } 8625 isAutoplayActive = !isAutoplayActive; 8626 }); 8627 } 8628 } 8629} 8630 8631// Add autoplay control functionality 8632const autoplayToggle = document.getElementById("swiperAutoplayToggle"); 8633let isAutoplayActive = true; 8634 8635if (autoplayToggle) { 8636 autoplayToggle.addEventListener("click", function () { 8637 if (isAutoplayActive) { 8638 swiper.autoplay.stop(); 8639 this.textContent = "Play"; 8640 this.classList.add("paused"); 8641 } else { 8642 swiper.autoplay.start(); 8643 this.textContent = "Pause"; 8644 this.classList.remove("paused"); 8645 } 8646 isAutoplayActive = !isAutoplayActive; 8647 }); 8648} 8649 8650/** 8651 * Converts a time string formatted as "mm:ss" to total seconds. 8652 * 8653 * @param {string} timeString - The time string in "mm:ss" format. 8654 * @example 8655 * // Example usage: 8656 * const result = timeToSeconds("142:12"); // result will be 8532 8657 * @returns {number} The total number of seconds. 8658 */ 8659const timeToSeconds = (timeString) => { 8660 const parts = timeString.split(':'); 8661 if (parts.length === 2) { 8662 const minutes = parseInt(parts[0], 10); 8663 const seconds = parseInt(parts[1], 10); 8664 if (!isNaN(minutes) && !isNaN(seconds)) { 8665 return (minutes * 60) + seconds; 8666 } 8667 } 8668 return 0; // Return 0 or throw an error for invalid input 8669}; 8670 8671async function getCities(countryId) { 8672 const response = await fetchFromNewAPI(`/cities/country/${countryId}`, HTTP_METHODS.GET, false); 8673 return response.data.map(Cities.from); 8674} 8675 8676$('[data-key=country]').on('change', async function () { 8677 let selectedCity = 0; 8678 let cityBody = $('[data-key=city]').empty(); 8679 let countryId = $(this).val(); 8680 let cities = []; 8681 if (Number(countryId)) { 8682 cities = await getCities(countryId); 8683 } 8684 8685 if (logged_in_member) { 8686 if (logged_in_member.contactInfo && Number(logged_in_member.contactInfo.cityId)) { 8687 selectedCity = Number(logged_in_member.contactInfo.cityId); 8688 } else if (Number(logged_in_member.city)) { 8689 selectedCity = Number(logged_in_member.city); 8690 } 8691 }
8692 cities.forEach(city => { 8693 let option = $('<option/>', { 8694 value: city.id, 8695 html: city.name, 8696 }); 8697 if ((Number(city.plateNo) && Number(city.plateNo) === selectedCity) || city.id === selectedCity) { 8698 option.attr('selected', 'selected'); 8699 } 8700 option.appendTo(cityBody); 8701 }); 8702}); 8703 8704// Email Verification Functions 8705function verify_email() { 8706 if (typeof logged_in_member !== "undefined" && logged_in_member != null && logged_in_member.is_guest == "0") 8707 location.reload(); 8708 8709 var form_data = get_form_data("#email_verify_form"); 8710 if (form_data.result === true) { 8711 $(".site_overlay").fadeIn(function () { 8712 $("#email_verify_error").slideUp(); 8713 8714 var post_data = form_data.data; 8715 post_data.command = "verify_email"; 8716 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 8717 if (response.result === true) { 8718 $("#email_verify_success").slideDown(); 8719 $("#email_verify_form").slideUp(function () { 8720 $("#email_verify_form").remove(); 8721 }); 8722 8723 // Handle new API verify email response if available 8724 if (response.new_api_success && response.new_api_data) { 8725 // Store new API verify email data for future use 8726 if (typeof (Storage) !== "undefined") { 8727 localStorage.setItem('karnaval_new_api_verify_email', JSON.stringify(response.new_api_data)); 8728 } 8729 setLoggedInMember(response.new_api_member_data, response.new_api_data); 8730 $('.verify_success_container .button_login').addClass('hidden'); 8731 } 8732 } else { 8733 // Hide error first 8734 $("#email_verify_error").hide(); 8735 8736 // Reset styling to red for error messages 8737 resetErrorContainerStyling(); 8738 $("#email_verify_error .error_list").html(response.messages.join("<br>")); 8739 $("#email_verify_error").slideDown(); 8740 8741 // Show resend form for expired/invalid tokens 8742 if (response.messages.some(msg => msg.includes("Geçersiz") || msg.includes("süresi dolmuÅ"))) { 8743 disableVerifyButton(); 8744 setTimeout(function () { 8745 $("#email_verify_error").slideUp(); 8746 $("#email_verify_form").slideUp(); 8747 $(".resend_verification_container").slideDown(); // Show resend container after others are hidden 8748 }, 3000); 8749 } 8750 } 8751 $(".site_overlay").fadeOut(); 8752 }, function (messages) { 8753 // Hide error first 8754 $("#email_verify_error").hide(); 8755 8756 resetErrorContainerStyling(); 8757 $("#email_verify_error .error_list").html(messages.join("<br>")); 8758 $("#email_verify_error").slideDown(); 8759 8760 // Show resend form for expired/invalid tokens 8761 if (messages.some(msg => msg.includes("Geçersiz") || msg.includes("süresi dolmuÅ"))) { 8762 disableVerifyButton(); 8763 setTimeout(function () { 8764 $("#email_verify_error").slideUp(); 8765 $("#email_verify_form").slideUp(); 8766 $(".resend_verification_container").slideDown(); // Show resend container after others are hidden 8767 }, 3000); 8768 } 8769 8770 $(".site_overlay").fadeOut(); 8771 }); 8772 }); 8773 } 8774} 8775 8776function resendVerificationEmail() { 8777 var email = $("#resend_email").val().trim(); 8778 8779 // Validate email 8780 if (!email) { 8781 $("#resend_error_message").text("Lütfen e-posta adresinizi girin.").show(); 8782 return; 8783 } 8784 8785 if (!validate_email(email)) { 8786 $("#resend_error_message").text("Lütfen geçerli bir e-posta adresi girin.").show(); 8787 return; 8788 } 8789 8790 // Show loading state 8791 setResendButtonLoading(true); 8792 8793 // Make API call - Backend handles rate limiting 8794 var post_data = { 8795 command: "resend_verification_email", 8796 email: email 8797 }; 8798 8799 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 8800 setResendButtonLoading(false); 8801 8802 if (response.result === true) { 8803 var sentEmail = $("#resend_email").val(); 8804 $("#email_verify_error").hide(); 8805 $("#email_verify_form").slideUp(); 8806 $(".resend_verification_container").hide(); 8807 8808 var successBox = $("#resend_verification_success"); 8809 successBox.find("h2").text("DoÄrulama e-postası gönderildi."); 8810 successBox.contents().filter(function () { 8811 return this.nodeType === 3; 8812 }).remove(); 8813 successBox.find(".button_container").before("E-posta kayıtlıysa doÄrulama baÄlantısı " + (sentEmail ? ("<strong>" + sentEmail + "</strong> ") : "") + "adresine gönderildi."); 8814 successBox.slideDown(); 8815 8816 $("#resend_email").val(""); 8817 $("#resend_error_message").hide();
8818 enableVerifyButton(); 8819 } else { 8820 // Show error under the input instead of toast 8821 $("#resend_error_message").text(response.messages.join(" ")).show(); 8822 } 8823 }, function (messages) { 8824 setResendButtonLoading(false); 8825 // Show error under the input instead of toast 8826 $("#resend_error_message").text(messages.join(" ")).show(); 8827 }); 8828} 8829 8830function setResendButtonLoading(loading) { 8831 var btn = $("#resend_verification_btn"); 8832 var btnText = $("#resend_btn_text"); 8833 var btnLoading = $("#resend_btn_loading"); 8834 8835 if (loading) { 8836 btn.prop("disabled", true); 8837 btnText.hide(); 8838 btnLoading.show(); 8839 } else { 8840 btn.prop("disabled", false); 8841 btnText.show(); 8842 btnLoading.hide(); 8843 } 8844} 8845 8846// Function to disable the verify email button 8847function disableVerifyButton() { 8848 var verifyBtn = $("#email_verify_form a[onclick='verify_email();']"); 8849 if (verifyBtn.length) { 8850 verifyBtn.prop("disabled", true); 8851 verifyBtn.css({ 8852 'opacity': '0.6', 8853 'cursor': 'not-allowed', 8854 'pointer-events': 'none' 8855 }); 8856 verifyBtn.find("span").text("Yeni doÄrulama e-postası bekleniyor..."); 8857 } 8858} 8859 8860// Function to enable the verify email button 8861function enableVerifyButton() { 8862 var verifyBtn = $("#email_verify_form a[onclick='verify_email();']"); 8863 if (verifyBtn.length) { 8864 verifyBtn.prop("disabled", false); 8865 verifyBtn.css({ 8866 'opacity': '1', 8867 'cursor': 'pointer', 8868 'pointer-events': 'auto' 8869 }); 8870 verifyBtn.find("span").text("E-postamı DoÄrula"); 8871 } 8872} 8873 8874// Function to reset error container styling to red 8875function resetErrorContainerStyling() { 8876 $("#email_verify_error strong").show(); // Show "HATA!" text for errors 8877 $("#email_verify_error").css({ 8878 'background': '#f8d7da', 8879 'border': '1px solid #f5c6cb', 8880 'color': '#721c24' 8881 }); 8882} 8883 8884function showToast(message, type) { 8885 // Remove existing toasts 8886 $(".toast").remove(); 8887 8888 // Create new toast 8889 var toast = $("<div class='toast " + type + "'>" + message + "</div>"); 8890 $("body").append(toast); 8891 8892 // Show toast 8893 setTimeout(function () { 8894 toast.addClass("show"); 8895 }, 100); 8896 8897 // Hide toast after 5 seconds 8898 setTimeout(function () { 8899 toast.removeClass("show"); 8900 setTimeout(function () { 8901 toast.remove(); 8902 }, 300); 8903 }, 5000); 8904} 8905 8906// Email verification page initialization 8907function initEmailVerification() { 8908 // Check if there are any error messages that indicate expired/invalid token 8909 var errorText = $("#email_verify_error .error_list").text(); 8910 if (errorText && (errorText.includes("Geçersiz") || errorText.
8910includes("süresi dolmuÅ"))) { 8911 disableVerifyButton(); 8912 // Hide both the red error container and green verification section after 3 seconds 8913 setTimeout(function () { 8914 $("#email_verify_error").slideUp(); 8915 $("#email_verify_form").slideUp(); 8916 $(".resend_verification_container").slideDown(); // Show resend container after others are hidden 8917 }, 3000); 8918 } 8919 8920 // Also check if resend container is already visible (from server-side rendering) 8921 if ($(".resend_verification_container").is(":visible")) { 8922 disableVerifyButton(); 8923 // Hide both the red error container and green verification section after 3 seconds if they're visible 8924 if ($("#email_verify_error").is(":visible")) { 8925 setTimeout(function () { 8926 $("#email_verify_error").slideUp(); 8927 $("#email_verify_form").slideUp(); 8928 $(".resend_verification_container").slideDown(); // Show resend container after others are hidden 8929 }, 3000); 8930 } 8931 } 8932} 8933 8934// Extract password error message from validation error text 8935function extractPasswordErrorFromText(errorText) { 8936 try { 8937 var jsonMatch = errorText.match(/\{.*\}/); 8938 if (jsonMatch) { 8939 var validationErrors = JSON.parse(jsonMatch[0]); 8940 if (validationErrors.password) { 8941 return validationErrors.password; 8942 } 8943 } 8944 } catch (e) { 8945 // Parsing failed, return null to use original message 8946 } 8947 return null; 8948} 8949 8950// Parse backend validation error and extract password error message 8951// Extract and format error messages from new_api_error 8952function extractNewApiErrorMessages(newApiError) { 8953 if (!newApiError) { 8954 return []; 8955 } 8956 8957 var displayMessages = []; 8958 var errorMessage = newApiError; 8959 8960 // Try to parse JSON from the error message if it contains JSON 8961 try { 8962 var jsonMatch = errorMessage.match(/\{.*\}/); 8963 if (jsonMatch) { 8964 var errorObj = JSON.parse(jsonMatch[0]); 8965 if (errorObj.message) { 8966 // Check if the message is an object with multiple validation errors 8967 if (typeof errorObj.message === 'object' && !Array.isArray(errorObj.message)) { 8968 // Extract all validation errors from the message object 8969 for (var field in errorObj.message) { 8970 if (errorObj.message.hasOwnProperty(field)) { 8971 var fieldErrors = errorObj.message[field]; 8972 if (Array.isArray(fieldErrors)) { 8973 // Add each error for this field 8974 fieldErrors.forEach(function (err) { 8975 displayMessages.push(err); 8976 }); 8977 } else { 8978 displayMessages.push(fieldErrors); 8979 } 8980 } 8981 } 8982 } else if (Array.isArray(errorObj.message)) { 8983 // If the message is an array, use it directly 8984 displayMessages = errorObj.message; 8985 } else { 8986 // If the message is a string, use it 8987 displayMessages = [errorObj.message]; 8988 } 8989 } else { 8990 displayMessages = [errorMessage]; 8991 } 8992 } else { 8993 displayMessages = [errorMessage]; 8994 } 8995 } catch (e) { 8996 // If parsing fails, use the original error message 8997 displayMessages = [errorMessage]; 8998 } 8999 9000 return displayMessages; 9001} 9002 9003function parseBackendValidationError(response) { 9004 // Get messages array (handle both array and object with language keys) 9005 var errorMessages = response.messages; 9006 if (!Array.isArray(errorMessages)) { 9007 // If messages is an object with language keys, extract the array 9008 var language = response.language || 'tr'; 9009 errorMessages = errorMessages[language] || errorMessages[Object.keys(errorMessages)[0]] || []; 9010 } 9011 9012 // Check if it's a backend validation error (from new API) 9013 var isBackendValidationError = false;
9014 var validationErrorMessages = []; 9015 9016 if (response.new_api_error && response.new_api_error.indexOf('Validation failed') !== -1) { 9017 isBackendValidationError = true; 9018 9019 // Try to extract the password error from new_api_error 9020 var passwordError = extractPasswordErrorFromText(response.new_api_error); 9021 if (passwordError) { 9022 validationErrorMessages = [passwordError]; 9023 } else { 9024 // If parsing fails, try to extract from the messages array 9025 if (errorMessages.length > 0) { 9026 var msgText = errorMessages[0]; 9027 passwordError = extractPasswordErrorFromText(msgText); 9028 if (passwordError) { 9029 validationErrorMessages = [passwordError]; 9030 } else { 9031 validationErrorMessages = errorMessages; 9032 } 9033 } else { 9034 validationErrorMessages = [response.new_api_error]; 9035 } 9036 } 9037 } 9038 9039 return { 9040 errorMessages: errorMessages, 9041 isBackendValidationError: isBackendValidationError, 9042 validationErrorMessages: validationErrorMessages 9043 }; 9044} 9045 9046// Show password validation error in UI (reusable function) 9047function showPasswordValidationError(errorMessages) { 9048 // Ensure inputs are visible 9049 $('#password_reset_inputs').show(); 9050 9051 // Add an error class to both password fields 9052 $('#password, #password_re').addClass('error'); 9053 9054 // Move error container to bottom of password inputs and show error message 9055 var $errorContainer = movePasswordErrorContainer('toFields', 'reset'); 9056 if ($errorContainer && $errorContainer.length) { 9057 var messagesArray = Array.isArray(errorMessages) ? errorMessages : [errorMessages]; 9058 $errorContainer.find('.error_list').html(messagesArray.join('<br>')); 9059 9060 // Make error container visible 9061 $errorContainer.stop(true, true); // Stop any animations 9062 $errorContainer[0].style.setProperty('display', 'block', 'important'); 9063 $errorContainer.show(); 9064 } 9065} 9066 9067// Password Reset Functions 9068function reset_password_new_api() { 9069 if (typeof logged_in_member !== "undefined" && logged_in_member != null && logged_in_member.is_guest == "0") 9070 location.reload(); 9071 9072 // Validate password match before form submission 9073 var password = $('#password').val(); 9074 var passwordRe = $('#password_re').val(); 9075 9076 $('#password, #password_re').removeClass('error'); // Remove any previous error classes 9077 9078 // Validate password pattern first using reusable function (if validation is enabled) 9079 if (resetPasswordValidationEnabled) { 9080 var passwordValidation = validatePasswordPattern(password); 9081 if (!passwordValidation.isValid) { 9082 // Add error class to both password fields 9083 $('#password, #password_re').addClass('error'); 9084 // Move error container to bottom of password inputs and show error message 9085 var $errorContainer = movePasswordErrorContainer('toFields', 'reset'); 9086 if ($errorContainer && $errorContainer.length) { 9087 $errorContainer.find('.error_list').html(passwordValidation.errors.join('<br>')); 9088 $errorContainer.slideDown(); 9089 } 9090 return; 9091 } 9092 } 9093 9094 if (password !== passwordRe) { 9095 // Add error class to both password fields 9096 $('#password, #password_re').addClass('error'); 9097 // Move error container to bottom of password inputs and show error message 9098 var $errorContainer = movePasswordErrorContainer('toFields', 'reset'); 9099 if ($errorContainer && $errorContainer.length) { 9100 $errorContainer.find('.error_list').html("Yeni Åifren ile doÄrulama Åifren aynı olmalı."); 9101 $errorContainer.slideDown(); 9102 } 9103 return; 9104 } 9105 9106 var form_data = get_form_data("#password_reset_form"); 9107 if (form_data.result === true) { 9108 var captcha_token = get_captcha_token("#reset_password_captcha"); 9109 9110 if (is_captcha_enabled() && !captcha_token) { 9111 $("#password_reset_error .error_list").html(captcha_error_message); 9112 $("#resend_reset_button").hide(); 9113 $("#password_reset_error").slideDown(); 9114 return; 9115 } 9116 9117 $(".site_overlay").fadeIn(function () { 9118 $("#password_reset_error").slideUp(); 9119 9120 var post_data = form_data.data; 9121 post_data.command = "reset_password_new_api"; 9122 post_data.captcha_token = captcha_token; 9123 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 9124 if (response.result === true) { 9125 $("#password_reset_success").slideDown(); 9126 $("#password_reset_form").slideUp(function () { 9127 $("#password_reset_form").remove(); 9128 }); 9129 9130 // Handle new API reset password response if available 9131 if (response.new_api_success && response.new_api_data) { 9132 // Store new API reset password data for future use 9133 if (typeof (Storage) !== "undefined") { 9134 localStorage.setItem('karnaval_new_api_reset_password', JSON.stringify(response.new_api_data)); 9135 } 9136 } 9137 9138 // Redirect to clean URL after successful password reset 9139 setTimeout(function () { 9140 window.history.replaceState({}, document.title, '/auth/reset-password'); 9141 }, 2000); // Wait 2 seconds to show success message 9142 } else { 9143 debug(response); 9144 reset_captcha("#reset_password_captcha"); 9145 9146 // Parse backend validation error 9147 var errorData = parseBackendValidationError(response); 9148 var errorMessages = errorData.errorMessages; 9149 var isBackendValidationError = errorData.isBackendValidationError;
9150 var validationErrorMessages = errorData.validationErrorMessages; 9151 9152 // Check if it's a password validation error (from backend) - show the same UI as frontend validation 9153 if (isBackendValidationError || response.password_validation_error) { 9154 var displayMessages = isBackendValidationError ? validationErrorMessages : errorMessages; 9155 showPasswordValidationError(displayMessages); 9156 } else if (response.token_expired) { 9157 // Hide error first for non-validation errors 9158 $("#password_reset_error").hide(); 9159 // Hide password inputs and show error message with resend button 9160 showResetFlow('error', errorMessages.join("<br>")); 9161 $("#resend_reset_button").show(); 9162 } else { 9163 // Hide error first for non-validation errors 9164 $("#password_reset_error").hide(); 9165 // Show password inputs and error message (without resend button) 9166 showResetFlow('inputs', errorMessages.join("<br>")); 9167 $("#resend_reset_button").hide(); 9168 $("#password_reset_error").slideDown(); 9169 } 9170 } 9171 $(".site_overlay").fadeOut(); 9172 }, function (messages) { 9173 debug(messages); 9174 reset_captcha("#reset_password_captcha"); 9175 9176 // Check if messages contain validation error patterns 9177 var isValidationError = false; 9178 var validationErrorMessages = []; 9179 var messagesText = Array.isArray(messages) ? messages.join(" ") : messages.toString(); 9180 9181 // Check if it's a backend validation error 9182 if (messagesText.indexOf(`"password":`) !== -1) { 9183 isValidationError = true; 9184 9185 // Extract password error from messages text 9186 var passwordError = extractPasswordErrorFromText(messagesText); 9187 if (passwordError) { 9188 validationErrorMessages = [passwordError]; 9189 } else { 9190 validationErrorMessages = Array.isArray(messages) ? messages : [messages]; 9191 } 9192 } 9193 9194 // Check if it's a token expired error message 9195 var isTokenExpired = messagesText.indexOf("süresi dolmuÅ") !== -1 || messagesText.indexOf("expired") !== -1 || messagesText.indexOf("Invalid or expired") !== -1; 9196 9197 if (isValidationError && validationErrorMessages.length > 0) { 9198 // Backend validation error - show with same UI as frontend validation 9199 showPasswordValidationError(validationErrorMessages); 9200 } else { 9201 // Hide error first for non-validation errors 9202 $("#password_reset_error").hide(); 9203 9204 if (isTokenExpired) { 9205 // Hide password inputs and show error message with resend button 9206 showResetFlow('error', Array.isArray(messages) ? messages.join("<br>") : messages); 9207 $("#resend_reset_button").show(); 9208 $("#reset_password_btn").hide(); 9209 } else { 9210 $("#resend_reset_button").hide(); 9211 $("#password_reset_error").slideDown(); 9212 } 9213 showResetFlow('inputs', Array.isArray(messages) ? messages.join("<br>") : messages); 9214 } 9215 $(".site_overlay").fadeOut(); 9216 }); 9217 }); 9218 } 9219} 9220 9221// Function to check if the token might be expired (for display purposes) 9222function checkTokenValidity() { 9223 var errorContainer = document.getElementById('password_reset_error'); 9224 var errorText = document.querySelector('#password_reset_error .error_list'); 9225 var inputsContainer = document.getElementById('password_reset_inputs'); 9226 9227 // Check if there's any error message displayed 9228 if (errorText && errorText.textContent.trim() !== '') { 9229 var isTokenExpired = errorText.textContent.indexOf("süresi dolmuÅ") !== -1 || errorText.textContent.indexOf("expired") !== -1; 9230 9231 if (isTokenExpired) { 9232 // Hide inputs and show error 9233 if (inputsContainer) { 9234 inputsContainer.style.display = 'none'; 9235 } 9236 if (errorContainer) { 9237 errorContainer.style.display = 'block'; 9238 } 9239 } else { 9240 // Show inputs and error 9241 if (inputsContainer) { 9242 inputsContainer.style.display = 'block'; 9243 } 9244 if (errorContainer) { 9245 errorContainer.style.display = 'block'; 9246 } 9247 } 9248 } 9249} 9250 9251// Function to populate email from localStorage 9252function populateEmailFromStorage() { 9253 try { 9254 var forgotPasswordData = localStorage.getItem('karnaval_new_api_forgot_password'); 9255 if (forgotPasswordData) { 9256 var data = JSON.parse(forgotPasswordData); 9257 if (data && data.email) { 9258 // If email is not in URL but we have it in storage, populate the form 9259 if (!window.location.search.includes('email=')) { 9260 // Set the email field value - try multiple approaches 9261 var emailField = null; 9262 // Try getElementById first 9263 emailField = document.getElementById('email'); 9264 // If not found, try querySelector 9265 if (!emailField) { 9266 emailField = document.querySelector('input[type="email"]'); 9267 } 9268 // If still not found, try by placeholder 9269 if (!emailField) { 9270 var inputs = document.querySelectorAll('input'); 9271 for (var i = 0; i < inputs.length; i++) { 9272 if (inputs[i].placeholder && inputs[i].placeholder.includes('E-POSTA')) {
9273 emailField = inputs[i]; 9274 break; 9275 } 9276 } 9277 } 9278 if (emailField) { 9279 emailField.value = data.email; 9280 } 9281 } 9282 } 9283 } 9284 } catch (error) { 9285 // Silent error handling for production 9286 } 9287} 9288 9289// Client-side rate limiting removed per product decision 9290function canMakeResendRequest() { 9291 return {canRequest: true}; 9292} 9293 9294function getResendLimits() { 9295 return {attempts: [], lastRequest: null}; 9296} 9297 9298function recordResendAttempt() { 9299 // no-op: client-side throttling disabled 9300} 9301 9302// Function to check if email verification is needed (placeholder for backend integration) 9303function checkEmailVerificationStatus(email) { 9304 // This would typically make an API call to check verification status 9305 // For now, we'll assume all emails need verification 9306 // In a real implementation, this would call the backend to check: 9307 // - Is the email registered? 9308 // - Is the email verified? 9309 // - Is the user eligible for password reset? 9310 return { 9311 isRegistered: true, 9312 isVerified: false, // Assume needs verification 9313 canResetPassword: true 9314 }; 9315} 9316 9317// Function to update resend button state 9318function updateResendButtonState() { 9319 var button = document.querySelector('#resend_reset_button'); 9320 var countdown = document.getElementById('resend_countdown'); 9321 9322 if (button) { 9323 // Always enable the button (server may still enforce limits) 9324 button.disabled = false; 9325 button.style.opacity = '1'; 9326 var buttonSpan = button.querySelector('span'); 9327 if (buttonSpan) buttonSpan.textContent = 'Tekrar gönder'; 9328 if (countdown) countdown.textContent = ''; 9329 } 9330} 9331 9332// Function to request new password reset link 9333function requestNewPasswordReset() { 9334 // Client-side throttling removed 9335 9336 // Get email from the hidden input field - try ID first, then data-key 9337 var emailField = document.getElementById('email') || document.querySelector('input[data-key="email"]'); 9338 var email = emailField ? emailField.value : ''; 9339 9340 // If no email in the form, try to get it from localStorage 9341 if (!email) { 9342 try { 9343 var forgotPasswordData = localStorage.getItem('karnaval_new_api_forgot_password'); 9344 if (forgotPasswordData) { 9345 var data = JSON.parse(forgotPasswordData); 9346 if (data && data.email) { 9347 email = data.email; 9348 } 9349 } 9350 } catch (error) { 9351 // Silent error handling 9352 } 9353 } 9354 9355 if (!email) { 9356 $("#password_reset_error .error_list").html('Lütfen e-posta adresinizi girin.'); 9357 $("#password_reset_error").css({ 9358 'background': '#f8d7da', 9359 'border': '1px solid #f5c6cb', 9360 'color': '#721c24' 9361 }); 9362 $("#password_reset_error").slideDown(); 9363 return; 9364 } 9365 9366 // Validate email format 9367 if (!validate_email(email)) { 9368 $("#password_reset_error .error_list").html('Lütfen geçerli bir e-posta adresi girin.'); 9369 $("#password_reset_error").css({ 9370 'background': '#f8d7da', 9371 'border': '1px solid #f5c6cb', 9372 'color': '#721c24' 9373 }); 9374 $("#password_reset_error").slideDown(); 9375 return; 9376 } 9377 9378 var captcha_token = get_captcha_token("#resend_reset_captcha"); 9379 9380 if (is_captcha_enabled() && !captcha_token) { 9381 $("#password_reset_error .error_list").html(captcha_error_message); 9382 $("#password_reset_error").slideDown(); 9383 return; 9384 } 9385 9386 // Hide error message when making new request 9387 $("#password_reset_error").hide(); 9388 $("#token_expired_actions").hide(); 9389 9390 $(".site_overlay").fadeIn(); 9391 var post_data = { 9392 // Explicit command alias handled server-side for password reset emails 9393 command: "send_password_reset", 9394 email: email, 9395 captcha_token: captcha_token 9396 }; 9397 9398 k_ajax("/functions/v6/member.functions.php", post_data, function (response) { 9399 if (response.result === true || response.new_api_success) { 9400 // Store email for future use 9401 if (typeof (Storage) !== "undefined") { 9402 var emailData = {email: response.new_api_data?.data?.email || response.new_api_data?.email || email || ''}; 9403 localStorage.setItem('karnaval_new_api_forgot_password', JSON.stringify(emailData)); 9404 } 9405 9406 // Hide error container and show confirmation message using overlay_message (same as forgot_password) 9407 $("#password_reset_error").hide(); 9408 $(".overlay_message strong").text('E-posta gönderildi!'); 9409 $(".overlay_message span").text('Åifre sıfırlama baÄlantısı e-posta adresinize gönderildi. Lütfen e-postanızı kontrol edin.'); 9410 $(".site_overlay").fadeIn(); 9411 9412 // Overlay stays visible - user needs to manually close it (will redirect to "/" on close) 9413 } else { 9414 // Hide overlay and show error in the error container 9415 $(".site_overlay").fadeOut(); 9416 reset_captcha("#resend_reset_captcha"); 9417 // Show error message in UI 9418 $("#password_reset_error .error_list").html('<strong>Hata: ' + (response.messages ? response.messages.join(', ') : 'Bilinmeyen hata') + '</strong>'); 9419 $("#password_reset_error").css({ 9420 'border': '1px solid #c3e6cb', 9421 'color': '#000000', 9422 }); 9423 $("#token_expired_actions").hide(); 9424 $("#password_reset_error").slideDown(); 9425 } 9426 }, function (messages) { 9427 // Hide overlay and show error in the error container 9428 $(".site_overlay").fadeOut(); 9429 reset_captcha("#resend_reset_captcha"); 9430 // Show error message in UI 9431 $("#password_reset_error .error_list").html('<strong>Hata: ' + messages + '</strong>'); 9432 $("#password_reset_error").css({ 9433 'border': '1px solid red', 9434 'color': '#000000', 9435 }); 9436 $("#token_expired_actions").hide(); 9437 $("#password_reset_error").slideDown(); 9438 }); 9439} 9440 9441// Password reset page initialization 9442function initPasswordReset() { 9443 populateEmailFromStorage(); 9444 checkTokenValidity(); 9445 updateResendButtonState(); 9446 initResetPasswordValidation(); 9447 9448 // Set up periodic button state updates for countdown 9449 setInterval(function () { 9450 updateResendButtonState(); 9451 }, 1000); // Update every second 9452} 9453 9454// Password toggle visibility function 9455function togglePasswordVisibility(inputId) { 9456 const passwordInput = document.getElementById(inputId); 9457 const toggleIcon = passwordInput.parentElement.querySelector('.password-toggle-icon'); 9458 const eyeIcon = toggleIcon.querySelector('.eye-icon'); 9459 const eyeOffIcon = toggleIcon.querySelector('.eye-off-icon'); 9460 9461 if (passwordInput.type === 'password') { 9462 passwordInput.type = 'text'; 9463 eyeIcon.style.display = 'none'; 9464 eyeOffIcon.style.display = 'block'; 9465 } else { 9466 passwordInput.type = 'password'; 9467 eyeIcon.style.display = 'block'; 9468 eyeOffIcon.style.display = 'none'; 9469 } 9470} 9471 9472function setLoggedInMember(loggedInMemberData, new_api_data) { 9473 logged_in_member = loggedInMemberData; 9474 const tokenData = { 9475 accessToken: new_api_data.accessToken, 9476 refreshToken: new_api_data.refreshToken, 9477 refreshTokenExpiresAt: new_api_data.tokenExpiresAt, 9478 storedAt: new Date().toISOString() 9479 }; 9480 localStorage.setItem('karnaval_new_api_token', JSON.stringify(tokenData)); 9481 update_member_ui(); 9482} 9483 9484function setNewApiToken(token) { 9485 const tokenData = { 9486 accessToken: token.accessToken, 9487 refreshToken: token.refreshToken, 9488 refreshTokenExpiresAt: token.tokenExpiresAt, 9489 storedAt: new Date().toISOString() 9490 }; 9491 localStorage.setItem('karnaval_new_api_token', JSON.stringify(tokenData)); 9492} 9493 9494function validatePhone(num) { 9495 // Keep digits and plus sign
9496 let clean = num.replace(/[^\d+]/g, ''); 9497 9498 // 1) Basic check: Allow + and 8â15 digits total 9499 const basic = /^\+?[0-9]{8,15}$/; 9500 if (!basic.test(clean)) return false; 9501 9502 // Extract digits only (remove +) 9503 let digits = clean.replace(/\D/g, ''); 9504 9505 // 2) Reject repeated digits (00000000, 55555555, etc.) 9506 if (/^(\d)\1+$/.test(digits)) return false; 9507 9508 // 3) Reject sequential digits (5 or more in a row) 9509 const seq = "0123456789"; 9510 const rev = "9876543210"; 9511 9512 for (let i = 0; i <= digits.length - 5; i++) { 9513 let part = digits.substring(i, i + 5); 9514 if (seq.includes(part) || rev.includes(part)) return false; 9515 } 9516 9517 // 4) Turkish specific rule â MUST start with +90 9518 if (clean.startsWith("+90")) { 9519 // Turkish GSM format: +90 5xxxxxxxxx (total 13 chars including +) 9520 // +90 + 10 digits = 13 characters 9521 if (!/^\+905\d{9}$/.test(clean)) { 9522 return false; // "Turkish number but not mobile GSM" 9523 } 9524 } 9525 9526 return true; 9527} 9528 9529/** 9530 * Updates the display styles of the action button icons for the current player. 9531 * 9532 * @param {Object} iconTypes - An object containing display style values for each action button. 9533 * @param {string} iconTypes.play - The display style for the play button. 9534 * @param {string} iconTypes.continues - The display style for the continue button. 9535 * @param {string} iconTypes.pause - The display style for the pause button. 9536 * @return {void} This method does not return any value. 9537 */ 9538function changeActionButtonIconsForPlayer(iconTypes) { 9539 9540 $(`.play_${player_current_podcast.id}`).css('display', iconTypes.play); 9541 $(`.continue_${player_current_podcast.id}`).css('display', iconTypes.continues); 9542 $(`.pause_${player_current_podcast.id}`).css('display', iconTypes.pause); 9543} 9544 9545// KVKK Consent Form - Submit button state management with validation 9546(function () { 9547 observerForGoogleVideoAdTarget(); 9548 9549 function initKVKKForm() { 9550 const $nameInput = $('#kvkk_name'); 9551 const $emailInput = $('#kvkk_email'); 9552 const $checkbox1 = $('#kvkk_checkbox_1'); 9553 const $checkbox2 = $('#kvkk_checkbox_2'); 9554 const $submitBtn = $('#kvkk_submit_btn'); 9555 const $errorContainer = $('.kvkk_form .error_container'); 9556 const $form = $('.kvkk_form'); 9557 9558 // Only initialize if elements exist on the page 9559 if ($nameInput.length && $emailInput.length && $checkbox1.length && $checkbox2.length && $submitBtn.length) { 9560 9561 // Validation functions 9562 function validateName(name) { 9563 if (!name || name.trim() === '') { 9564 return false; 9565 } 9566 return name.length <= 250; 9567 } 9568 9569 function validateEmail(email) { 9570 if (!email || email.trim() === '') { 9571 return false; 9572 } 9573 if (email.length > 250) { 9574 return false; 9575 } 9576 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 9577 return emailRegex.test(email); 9578 } 9579 9580 function validateCheckboxes() { 9581 return $checkbox1.is(':checked') && $checkbox2.is(':checked'); 9582 } 9583 9584 function validateForm() { 9585 const name = $nameInput.val(); 9586 const email = $emailInput.val(); 9587 9588 return validateName(name) && validateEmail(email) && validateCheckboxes(); 9589 } 9590 9591 function updateSubmitButton() { 9592 const isValid = validateForm(); 9593 9594 if (isValid) { 9595 $submitBtn.css({ 9596 'background-color': '#ed1c24', 9597 'cursor': 'pointer', 9598 'pointer-events': 'auto' 9599 }).removeClass('disabled'); 9600 } else { 9601 $submitBtn.css({ 9602 'background-color': '#ccc', 9603 'cursor': 'not-allowed', 9604 'pointer-events': 'none' 9605 }).addClass('disabled'); 9606 } 9607 } 9608 9609 function showError(message) { 9610 $errorContainer.css({ 9611 'background-color': '#fee', 9612 'border-color': '#ed1c24', 9613 'color': '#ed1c24' 9614 }).html(message).fadeIn(); 9615 setTimeout(function () { 9616 $errorContainer.fadeOut(); 9617 }, 5000); 9618 } 9619 9620 function showSuccess(message) { 9621 $errorContainer.css({ 9622 'background-color': '#efe', 9623 'border-color': '#4caf50', 9624 'color': '#2e7d32' 9625 }).html(message).fadeIn(); 9626 setTimeout(function () { 9627 $errorContainer.fadeOut(); 9628 }, 5000); 9629 } 9630
9631 // Real-time validation on input change 9632 $nameInput.on('input blur', function () { 9633 const name = $(this).val(); 9634 if (name.length > 0 && !validateName(name)) { 9635 $(this).css('border-color', '#ed1c24'); 9636 } else { 9637 $(this).css('border-color', '#e6e6e6'); 9638 } 9639 updateSubmitButton(); 9640 }); 9641 9642 $emailInput.on('input blur', function () { 9643 const email = $(this).val(); 9644 if (email.length > 0 && !validateEmail(email)) { 9645 $(this).css('border-color', '#ed1c24'); 9646 } else { 9647 $(this).css('border-color', '#e6e6e6'); 9648 } 9649 updateSubmitButton(); 9650 }); 9651 9652 // Update submit button state when checkboxes change 9653 $('.kvkk_checkbox').on('change', function () { 9654 updateSubmitButton(); 9655 }); 9656 9657 // Form submission handler 9658 $submitBtn.on('click', function (e) { 9659 e.preventDefault(); 9660 9661 if ($(this).hasClass('disabled') || !validateForm()) { 9662 return false; 9663 } 9664 9665 // Get form data using the standard pattern 9666 const form_data = get_form_data(".kvkk_form"); 9667 9668 if (!form_data.result) { 9669 return false; 9670 } 9671 9672 // Disable button during submission 9673 $submitBtn.css({ 9674 'background-color': '#ccc', 9675 'cursor': 'not-allowed', 9676 'pointer-events': 'none' 9677 }).html('Gönderiliyor...'); 9678 9679 // Prepare data using form_data 9680 const postData = form_data.data; 9681 postData.command = 'send_kvkk_consent'; 9682 9683 // Send via AJAX 9684 k_ajax('/functions/v6/api.functions.php', postData, function (response) { 9685 // Success 9686 $submitBtn.html('Formu gönder').css({ 9687 'background-color': '#ed1c24', 9688 'cursor': 'pointer', 9689 'pointer-events': 'auto' 9690 }); 9691 9692 // Clear form 9693 $nameInput.val(''); 9694 $emailInput.val(''); 9695 $checkbox1.prop('checked', false); 9696 $checkbox2.prop('checked', false); 9697 updateSubmitButton(); 9698 9699 showSuccess('Form baÅarıyla gönderildi. TeÅekkür ederiz!'); 9700 }, function (messages) { 9701 // Error 9702 $submitBtn.html('Formu gönder').css({ 9703 'background-color': '#ed1c24', 9704 'cursor': 'pointer', 9705 'pointer-events': 'auto' 9706 }); 9707 9708 let errorMsg = 'Form gönderilirken bir hata oluÅtu. Lütfen tekrar deneyin.'; 9709 if (Array.isArray(messages)) { 9710 errorMsg = messages.join('<br>'); 9711 } else if (typeof messages === 'string') { 9712 errorMsg = messages; 9713 } else if (messages && typeof messages === 'object') { 9714 // Handle object with language keys 9715 let msgArray = []; 9716 for (let key in messages) { 9717 if (Array.isArray(messages[key])) { 9718 msgArray = msgArray.concat(messages[key]); 9719 } else { 9720 msgArray.push(messages[key]); 9721 } 9722 } 9723 errorMsg = msgArray.length > 0 ? msgArray.join('<br>') : errorMsg; 9724 } 9725 showError(errorMsg); 9726 }); 9727 }); 9728 9729 // Initialize button state 9730 updateSubmitButton(); 9731 } 9732 } 9733 9734 // Check if DOM is already ready, otherwise wait for it 9735 if (document.readyState === 'loading') { 9736 document.addEventListener('DOMContentLoaded', initKVKKForm); 9737 } else { 9738 // DOM is already ready, run immediately 9739 initKVKKForm(); 9740 } 9741})();
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.