PageSourceSearch

https://radiovoz.com/js/home.js?guid=202512021859

js radiovoz.com collected 2026-10-02 12:48:59 UTC 37,444 bytes, 1,174 lines download raw bytes

1
2const DIST_REGULAR = false;
3var dialOne;
4var GLOBAL_NEWS_SWIPER;
5var LOCAL_NEWS_SWIPER;
6const FEEDS_NOTICIAS_OPTS = {
7    autoplay_delay: 12000,   // 12 secs.
8    refresh: 600000   // 10 min.
9}
10const DIRECTOS_REFRESH_TIME = 300000; // 5 min.
11
12const _local_feed_enabled = true;
13
14var emisoraSeleccionada;
15
16let _LVDResumeMainAudio = false;
17let lastCircleOver = -1;
18$(document).ready(function(){
19
20	// bootstrap responsive breakpoints: 768px, 992px and 1200px, representing small, medium and large devices respectively.
21	$("body").addClass(findBootstrapEnvironment());
22
23    if (emisoras && emisoras.length>0) {
24        initDialEmisoras();
25        
26        defaultEmisora();
27    } else {
28        $(".dial-emisoras").hide();
29    }
30    
31	$(".dial-emisoras .reproductor a").click(function(e) {
32        e.preventDefault();
33
34        if ($(this).hasClass("on")) {
35            stopAudio();
36        } else {
37            //Paramos lvd si esta sonando 
38            //console.log(' $("#lvd_jplayer")',  $("#lvd_jplayer").length, !$("#lvd_jplayer").data("jPlayer").status.paused);
39            if ($("#lvd_jplayer").length && !$("#lvd_jplayer").data("jPlayer").status.paused) {
40                $("#lvd_jplayer").jPlayer("pause");
41
42                $("#lvd_jplayer").jPlayer("pause");
43                $(".swiper-slide.lvd .reproductor .controls .buttons .pause").hide();
44                $(".swiper-slide.lvd .reproductor .controls .buttons .resume").show();
45
46                $(".swiper-slide.lvd .reproductor .controls .buttons .stop a").click();
47            }
48            
49            playAudio();
50        }
51
52        togglePlayBtn();
53	});
54
55	$(".dial-emisoras .reproductor .volume-controls .volume-bar").mousedown(function(e) {
56		var $bar = $(e.currentTarget),
57			offset = $bar.offset(),
58			x = e.pageX - offset.left,
59			w = $bar.width(),
60			y = $bar.height() - e.pageY + offset.top,
61			h = $bar.height();
62		
63        $(this).data("dragging", true).data("volume", y/h);
64        setPlayerValueBarHeight(y/h);
65    }).mousemove(function(e) {
66        if ($(this).data("dragging")) {
67            var $bar = $(e.currentTarget),
68                offset = $bar.offset(),
69                x = e.pageX - offset.left,
70                w = $bar.width(),
71                y = $bar.height() - e.pageY + offset.top,
72                h = $bar.height();
73            
74            $(this).data("volume", y/h);
75            setPlayerValueBarHeight(y/h);
76        }
77    }).mouseup(function(e) {
78        $(this).data("dragging", false);
79		setPlayerVolume($(this).data("volume"));				
80	}).mouseleave(function(e) {
81        if ($(this).data("dragging")) {
82            $(this).data("dragging", false);
83            setPlayerVolume($(this).data("volume"));	
84        }			
85	});
86	
87    initGlobalNewsFeed();
88	
89	let today = moment().day();
90    if (today==0)
91        today = 7;
92	//Parrilla: Mostrar dia de hoy
93	$("body.home #parrilla-submenu .week a[data-index='" + today + "']").addClass("active");
94	
95	
96	getHomePageConfig().done(function(data) {
97		
98        $("#homefooter .social > ul > li").hide();
99
100        if (data.result.showtwitter && data.result.twitter) {
101            let twitter_account = "http://x.com/" + data.result.twitter.replace("http://x.com/", "");
102            $("#homefooter .social > ul > li.tw").show();
103            $("#homefooter .social > ul > li.tw a").attr("href", twitter_account).data("general", twitter_account);
104        }
105        if (data.result.showfacebook && data.result.facebook) {
106            let facebook_account = "https://www.facebook.com/" + data.result.facebook.replace("https://www.facebook.com/", "");
107            $("#homefooter .social > ul > li.fb").show();
108            $("#homefooter .social > ul > li.fb a").attr("href", facebook_account).data("general", facebook_account);
109        }
110        if (data.result.showinstagram && data.result.instagram) {
111            let instagram_account = "https://www.instagram.com/" + data.result.instagram.replace("https://www.instagram.com/", "");
112            $("#homefooter .social > ul > li.inst").show();
113            $("#homefooter .social > ul > li.inst a").attr("href", instagram_account).data("general", instagram_account);
114        }
115
116        if (emisoraSeleccionada) {
117            updateRRSSIcons(emisoraSeleccionada);
118        }
119        
120        showHomeBanner(data.result);
121        
122	});
123	
124    //Ocultar facebook box de locales
125    $(".fb_plugin_box_local").hide();
126
127    
128    // set interval update
129    setInterval(function() {
130        refreshDirectos();
131    }, DIRECTOS_REFRESH_TIME);
132    
133
134    if ($(".swiper-slide.lvd").length>0) {
135
136        const audio_url = $(".swiper-slide.lvd .reproductor").data("src");        
137        loadLVDJPlayer(audio_url);
138
139        //la voz del dia
140        $(".swiper-slide.lvd .reproductor .play a").click(function(e) {
141            e.preventDefault();
142
143            //Paramos el otro reproductor por si estaba sonando
144            _LVDResumeMainAudio = !$("#jquery_jplayer").data("jPlayer").status.paused;
145            if (_LVDResumeMainAudio) {
146                $("#jquery_jplayer").jPlayer("pause");
147                showPlayBtn();
148            }
149
150            const reproductor = $(".swiper-slide.lvd .reproductor");
151            const botonera = reproductor.find(".controls .buttons");
152            const timebar = reproductor.find(".controls .resume-time-bar");
153            const play = $(this);
154
155            reproductor.addClass("on");
156
157            botonera.css({
158                opacity: 0,
159                width: 35,
160                height: 35
161            });
162            timebar.css({
163                opacity: 0,
164                height: 0
165            });
166
167            play.find("img").animate(
168                {
169                    width: 35,
170                    height: 35
171                }, 300, function() {
172                    // Animation complete.
173                    play.find("img").animate(
174                        {
175                            opacity: 0
176                        }, 100, function() {
177                            // Animation complete.
178                            play.hide();
179                            
180                            botonera.show().animate({
181                                opacity: 1,
182                                width: 200
183                            }, 300);
184
185                            timebar.show().animate({
186                                opacity: 1,
187                                height: 22
188                            });
189
190                        });
191                });
192
193            $("#lvd_jplayer").jPlayer("play", 0);
194            
195        });
196
197        $(".swiper-slide.lvd .reproductor .controls .buttons .stop a").click(function(e) {
198            e.preventDefault();
199            const reproductor = $(".swiper-slide.lvd .reproductor");
200            const botonera = reproductor.find(".controls .buttons");
201            const play = reproductor.find(".play a");
202            const timebar = reproductor.find(".controls .resume-time-bar");
203
204            $("#lvd_jplayer").jPlayer("pause");
205            
206            //Si estaba sonando el main lo volvemos a poner
207            if (_LVDResumeMainAudio) {
208                setTimeout(function() {
209                    $("#jquery_jplayer").jPlayer("play");
210                    showPauseBtn();
211                }, 400);
212            }
213                
214            reproductor.removeClass("on");
215            
216            botonera.animate(
217                {
218                    opacity: 0,
219                    width: 35
220                }, 300, function() {
221                    // Animation complete.
222                    play.show().find("img").animate({
223                        opacity: 1,
224                        width: 50,
225                        height: 50
226                    }, 300);
227                    
228                    botonera.css({
229                        height: 0
230                    }).hide();
231
232                });
233            
234            timebar.animate(
235                {
236                    opacity: 0,
237                    widheightth: 0
238                }, 300, function(){
239                    timebar.hide();
240                });
241
242                
243        });
244
245        $(".swiper-slide.lvd .reproductor .controls .buttons .reload a").click(function(e) {
246            e.preventDefault();
247            
248            $("#lvd_jplayer").jPlayer("play", 0);
249
250        });
251
252        $(".swiper-slide.lvd .reproductor .controls .buttons .pause a").click(function(e) {
253            e.preventDefault();
254            
255            $("#lvd_jplayer").jPlayer("pause");
256            $(this).parent().hide();
257            $(".swiper-slide.lvd .reproductor .controls .buttons .resume").show();
258
259        });
260        $(".swiper-slide.lvd .reproductor .controls .buttons .resume a").click(function(e) {
261            e.preventDefault();
262            
263            $("#lvd_jplayer").jPlayer("play");
264            $(this).parent().hide();
265            $(".swiper-slide.lvd .reproductor .controls .buttons .pause").show();
266            
267        });
268
269        $(".swiper-slide.lvd .reproductor .controls .buttons .volume a").click(function(e) {
270            e.preventDefault();
271            
272            $(this).tooltip("hide");
273            if ($(this).parent().hasClass("on")) {
274                //Silenciar
275                $("#lvd_jplayer").jPlayer("mute");
276                $(this).find("img").attr("src", "img/sm_volume_off.png");
277                $(this).attr("title", "Activar volumen").tooltip("fixTitle");
278            } else {
279                //volumen 
280                $("#lvd_jplayer").jPlayer("unmute");
281                $(this).find("img").attr("src", "img/sm_volume.png");
282                $(this).attr("title", "Silenciar").tooltip("fixTitle");
283            }
284
285            $(this).parent().toggleClass("on")
286        });
287        
288        
289        $(".swiper-slide.lvd .reproductor .controls .resume-time-bar .time-bar").click(function(e) {
290            var $bar = $(e.currentTarget),
291                offset = $bar.offset(),
292                x = e.pageX - offset.left,
293                w = $bar.width();
294            
295                let secs = _lvdAudioDuration * x / w;
296                $("#lvd_jplayer").jPlayer("play", secs);
297        });
298
299
300    }
301});
302
303function initDialEmisoras() {
304
305    emisoras.forEach((emisora) => {
306        emisora.frecuency = parseFloat(emisora.freq.split(" ")[0].replace(",","."));
307    });
308    emisoras.sort((e1, e2) => e1.frecuency - e2.frecuency);
309
310    dialOne = JogDial(document.getElementById('jogdial'),
311        {
312            wheelSize:'170px', 
313            knobSize:'35px', 
314            degreeStartAt: 0
315        }).on('mousemove', function(evt){
316            //$('#jog_dial_example_meter div').css('width', Math.round((evt.target.rotation/360)*100) + '%' )
317            $(".dial .selected-freq").css({visibility: 'hidden'});
318            let emisora = masCerca(evt.target.rotation);
319            if (emisora.data("emisora").id != lastCircleOver) {
320
321                $(".dial .circle.hover").removeClass("hover");
322                hideDialTooltip();
323                if (!emisora.hasClass("on")) {
324                    emisora.addClass("hover");
325                    showDialTooltip(emisora);
326                }
327
328                lastCircleOver = emisora.data("emisora").id;
329            }
330
331        }).on('mouseup', function(evt){
332            let emisora = $(".dial .circle.hover");
333            if (emisora.length==0) {
334                emisora = $(".dial .circle.on");
335            }
336            if (emisora.length>0) {
337				checkEmisoraSelected(emisora);
338                
339                setDefaultEmisora($(this).data("emisora"));
340            }
341        
342            $(".dial .selected-freq").css({visibility: 'visible'});
343        });
344
345    let w = $(".dial").width();
346    let radius = w/2;
347    let ow = $(".dial").outerWidth();
348
349    let numemisoras = emisoras.length;
350    let gap = 360 / numemisoras;
351
352    emisoras.forEach(function(emisora, i) {
353        var _x =  0,
354            _y =  0;
355
356
357        if (DIST_REGULAR) {
358            emisora.degrees = gap*i;
359            if (emisora.degrees>360)
360            emisora.degrees = emisora.degrees - 360;
361            emisora.radians = JogDial.utils.convertClockToUnit(emisora.degrees) * JogDial.ToRad;
362            _x =  Math.cos(emisora.radians) * radius + ow/2 - 4;
363            _y =  Math.sin(emisora.radians) * radius + ow/2;
364        } else {
365            emisora.degrees = (emisora.frecuency - 87) * 17;
366            emisora.radians = JogDial.utils.convertClockToUnit(emisora.degrees) * JogDial.ToRad;
367            
368            //Si estan muy juntos separamos un poco
369            if (i>0) {
370                let diff = emisora.radians - emisoras[i-1].radians;
371                if (diff<0.1) {
372                    emisora.radians = emisoras[i-1].radians + 0.1;
373                }
374            }
375
376            _x =  Math.cos(emisora.radians) * radius + ow/2 - 4;
377            _y =  Math.sin(emisora.radians) * radius + ow/2;
378        }
379
380        $(`<a href="#" class="circle" data-emisora="${emisora.city}" data-idemisora="${emisora.id}" data-freq="${emisora.frecuency}"></a>`)
381            .appendTo($(".dial"))
382            .data("emisora", emisora)
383            .css({
384                top: _y, left: _x
385            })
386            .mouseover(function(e) {
387                if (!$(this).hasClass("on"))
388                    showDialTooltip($(this));
389                })
390            .mouseout(function(e) {
391                hideDialTooltip();
392            })
393            .click(function(e) {
394                e.preventDefault();
395
396				checkEmisoraSelected($(this));
397                
398                setDefaultEmisora($(this).data("emisora"));
399                
400                $(".dial .selected-freq").css({visibility: 'visible'});
401            });
402
403    });
404
405    $(".dial")
406        .append(`<div class="selected-name hidden-xs" style="display: none;"></div>`)
407        .append(`<div class="selected-freq" style="display: none;"></div>`)
408        .append(`<div class="dial-tooltip" style="display: none;"></div>`);
409
410}
411
412function masCerca(rotation) {
413    if (rotation<0) {
414        rotation = 360 + (rotation % 360);
415    } else {
416        rotation = rotation % 360;
417    }
418
419    let first = $(".dial .circle").get(0);
420    let last = $(".dial .circle").get($(".dial .circle").length-1);
421    if ( $(first).data("emisora").degrees > rotation)
422        return $(first);
423
424    let masCercano = $(last);
425    $(".dial .circle").each(function() {
426        
427        if ($(this).data("emisora").degrees > rotation) {
428            masCercano = $(this).prev();
429            return false;
430        }
431    });
432
433    return masCercano;
434}
435
436function checkEmisoraSelected(circle){
437    selectDialEmisora(circle);
438    moveDial(circle.data("emisora"));
439
440    updateHomeSections(circle.data("emisora"));
441}
442
443function selectEmisora(emisora){
444	
445	let dial = $(".dial .circle[data-idemisora='" + emisora + "']");
446	
447    showDialTooltip(dial);
448    
449	_checkAutoPlay(document.getElementById('audio_mock').play());
450
451    setTimeout(function() {
452        checkEmisoraSelected(dial);
453    }, 2000);
454    
455    $(".dial .selected-freq").css({visibility: 'visible'});
456}
457
458function selectDialEmisora(btn) {
459    let emisora = btn.data("emisora");
460    let right = false;
461    if (emisora.degrees > 190 && emisora.degrees < 350) {
462        right = true;
463    }
464    
465    $(".dial .circle").removeClass("on hover");
466    btn.addClass("on");
467    
468    hideDialTooltip();
469
470    let ow = $(".dial").outerWidth();
471    $(".dial .selected-freq").html(emisora.frecuency + " FM").css({
472        visibility: 'hidden'
473    }).show();
474
475    let l = ow/2 - $(".dial .selected-freq").width()/2;
476    $(".dial .selected-freq").css({
477        left: l,
478        visibility: 'visible'
479    });
480
481    let _top = parseInt(btn.css('top'), 10) - 7;    
482    //Bajamos un poco las de abajo de todo
483    if (emisora.radians > 1.35 && emisora.radians < 2.14) {
484        _top += 15;
485    }
486
487    $(".dial .selected-name").html(emisora.city)
488        .css({
489            'visibility': 'hidden',
490            top: _top, left: parseInt(btn.css('left'), 10) + 15
491        })
492        .show();
493
494    if (right) {
495        $(".dial .selected-name").css({
496            left: parseInt(btn.css('left'), 10) - $(".dial .selected-name").width() - 10
497        }); 
498    }
499    
500    $(".dial .selected-name").css({
501        'visibility': 'visible'
502    }); 
503
504
505	$("#xs-selected-name").html(emisora.city);	
506	
507    console.log('_autoplayBlocked', _autoplayBlocked);
508    if (!_autoplayBlocked) {
509		playDialEmisora(emisora);
510	} else {
511		_autoplayBlocked = false;
512	}
513}
514
515function playDialEmisora(emisora) {
516    playEmisora(emisora);
517
518    showPauseBtn();
519}
520
521function updateHomeSections(emisora) {
522    showDirecto(emisora);    
523    showParrilla(emisora);    
524    showNewsFeed(emisora);    
525    updateRRSSIcons(emisora);
526    showFBBox(emisora);
527    
528    emisoraSeleccionada = emisora;
529}
530
531function togglePlayBtn() {
532    
533    if ($(".dial-emisoras .reproductor a").hasClass("on")) {
534        showPlayBtn();
535    } else {
536        showPauseBtn();
537    }
538}
539
540function showPauseBtn() {
541    $(".dial-emisoras .reproductor a").addClass("on");
542    $(".dial-emisoras .reproductor a img").attr("src", "img/pause.png");
543}
544function showPlayBtn() {
545    $(".dial-emisoras .reproductor a").removeClass("on");
546    $(".dial-emisoras .reproductor a img").attr("src", "img/play.png");
547}
548
549function moveDial(emisora) {
550    dialOne.angle(emisora.degrees); 
551}
552
553function showDialTooltip(btn) {
554    let emisora = btn.data("emisora");
555    let right = false;
556    if (emisora.degrees > 190 && emisora.degrees < 350) {
557        right = true;
558    }
559
560    let _top = parseInt(btn.css('top'), 10) - 7;    
561    //Bajamos un poco las de abajo de todo
562    if (emisora.radians > 1.35 && emisora.radians < 2.14) {
563        _top += 15;
564    }
565
566
567	$("#xs-selected-name").html(emisora.city + " " + emisora.frecuency + " FM");	
568	
569    $(".dial .dial-tooltip")
570        .html(emisora.city + " " + emisora.frecuency + " FM")
571        .css({
572            'visibility': 'hidden',
573            'top': _top, 
574            'left': parseInt(btn.css('left'), 10) + 15
575        })
576        .show();
577
578    if (right) {
579        $(".dial .dial-tooltip").css({
580            left: parseInt(btn.css('left'), 10) - $(".dial .dial-tooltip").width() - 10
581        }); 
582    }
583    
584    //En movil no sacamos tooltip
585    if (!$("body").hasClass("xs")) {
586	    $(".dial .dial-tooltip").css({
587	        'visibility': 'visible'
588	    }); 
589	}
590
591}
592
593function hideDialTooltip() {
594    $(".dial .dial-tooltip").empty().hide();
595
596}
597
598function showDirecto(emisora) {
599	$("#homereproductores .directos .directo").hide();
600	$("#homereproductores .directos #directo" + (emisora.id)).show();
601}
602
603function showFBBox(emisora) {
604	
605    $(".fb_plugin_box").hide();
606	
607	if (emisora.rrss.facebook) {
608		$("#fb_plugin_" + emisora.id).show();
609	} else {
610		$("#fb_plugin_golbal").show();
611	}
612}
613
614function showParrilla(emisora) {
615
616	$.ajax({
617		url: contextPath + "parrilla.action",
618		dataType: "json",
619		type: 'POST',
620		data:  {
621			action: "parrilla",
622			emisora: emisora.id
623		},
624		beforeSend: function( ) {
625            $("#parrilla-cont").empty();
626            $("#homeprogramacion").hide();
627		},
628		error: function(jqXHR, textStatus, errorThrown) {
629	    	//error(textStatus);
630        },
631        success: function(data) {
632			//console.log(data);
633            if (data.success) {
634                            
635                let today = moment().day();
636                if (today==0)
637                    today = 7;
638                
639                $("#parrilla-cont").empty();
640                for (let day in data.result.parrilla) {
641                    if (data.result.parrilla.hasOwnProperty(day)) {
642                        let programacion = $(`<div id="parrilla${day}" class="programacion" style="${today==day? '' : 'display: none;' }">
643                            <div class="table-responsive">
644                                <table class="table">
645                                    <tbody>
646                                    
647                                    </tbody>
648                                </table>
649                            </div>
650                        </div>`).appendTo($("#parrilla-cont"));
651                        data.result.parrilla[day].forEach(function(programacionParrilla) {
652                            let hostname = `<a href="programa/${programacionParrilla.programa.programId}/${programacionParrilla.programa.slug}/">${programacionParrilla.programa.name}</a>`;
653                            if (programacionParrilla.redifusion) {
654                                hostname = `<a href="#">${programacionParrilla.programa.name}</a>`;
655                            }
656                            
657                            programacion.find("table tbody").append(`<tr>
658                                <td class="hostname">
659                                    <span class="diahora">${moment(programacionParrilla.start).format("HH:mm")}</span>  ${hostname}</div>
660                                </td>
661                            </tr>`);
662                        });
663                    }
664                }
665
666                $("#homeprogramacion").show();
667            }
668		}
669	});
670}
671
672
673function showNewsFeed(emisora) {
674	
675	$("#emisora-news").removeData("lastPubDate");
676	
677	//si no hay feed
678	if (!emisora.rssFeed) {
679        $("#emisora-news .swiper-wrapper").empty();
680        $(".emisora-news").hide();
681
682        $("#emisora-news").removeData("lastPubDate");
683		return;
684    }
685    
686    $("#homeprogramacion .news-title h2").html(`en ${emisora.city}`);
687    
688    if (_local_feed_enabled) {
689        $(".emisora-news").show();
690        getLocalNewsFeed(emisora);
691
692        $("#emisora-news").mouseenter(function() {  
693            if (LOCAL_NEWS_SWIPER) 
694                LOCAL_NEWS_SWIPER.autoplay.pause();
695        }).mouseleave(function() {
696            if (LOCAL_NEWS_SWIPER) 
697                LOCAL_NEWS_SWIPER.autoplay.resume();
698        });
699        
700        // set interval update
701        setInterval(function() {
702            getLocalNewsFeed(emisora);
703        }, FEEDS_NOTICIAS_OPTS.refresh);
704    }
705
706}
707
708function getLocalNewsFeed(emisora) {
709
710    getNewsFeed(emisora).fail(function () {
711		//Ignoramos, si falla esto no le importa a nadie?
712	}).done(function (data) {
713        if (data.success) {
714			
715			let actualizar = true; 
716			
717			//Miramos si tenemos nueva versión
718			let lastPubDate = $("#emisora-news").data("lastPubDate");
719            
720            if (lastPubDate) {
721                if (data.result.pubDate) {
722                    let pubDate = moment(data.result.pubDate);                    
723                    if (!pubDate.isAfter(moment(lastPubDate))) {
724                        actualizar = false;
725                    }
726                }
727            }
728            
729            if (actualizar) {
730                $("#emisora-news").data("lastPubDate", data.result.pubDate);
731                        
732                $("#emisora-news .swiper-wrapper").empty();
733                data.result.newsList.forEach(function(noticia, i) {
734                    
735                    let figure = '';
736                    if (noticia.photo) {
737                        figure = `<div class="photo">
738                                <figure><img src="${noticia.photo}"/></figure>
739                            </div>`;
740                    }
741
742                    $(`<div class="news-slider__item swiper-slide">
743                        <div>
744							<div class="title"><a href="${noticia.link}" target="_blank">${noticia.title}</a></div>
745                            <div class="date">${noticia.pubDate? moment(noticia.pubDate).format("DD [de] MMM YYYY") : ''}</div>
746                            ${figure}
747                            <div class="desc">
748                                ${noticia.description}
749                            </div>
750                    </div>`).appendTo($("#emisora-news .swiper-wrapper"));
751                });
752
753                if (LOCAL_NEWS_SWIPER) {
754                    //LOCAL_NEWS_SWIPER.update();
755                    //Nota, el .update() no me funciona bien 
756                    LOCAL_NEWS_SWIPER.destroy();
757                }
758
759                setTimeout(function() {
760                    initLocalNewsSwiper();
761                }, 200);
762            
763			}	
764            
765        }
766	});
767}
768
769function getNewsFeed(emisora) {
770	var deferred = $.Deferred();
771    
772    let params = {
773        action: "news"
774    };
775    if (emisora) {
776        params = {
777			action: "news",
778			emisora: emisora.id,
779			rss: emisora.rssFeed
780		};
781    }
782
783	$.ajax({
784		url: contextPath + "mainpage.action",
785		dataType: "json",
786		type: 'POST',
787		data:  params,
788		error: function(jqXHR, textStatus, errorThrown) {
789	    	//error(textStatus);
790			deferred.reject({status: jqXHR.status, message: 'Error al obtener rss feed'});
791        },
792        success: function(data) {
793			deferred.resolve(data);
794		}
795	});
796	
797	return deferred.promise();
798}
799
800
801function setPlayerValueBarHeight(perc) {
802	const bar = $(".dial-emisoras .reproductor .volume-controls .volume-bar");
803    const h = bar.height()*perc;
804
805    bar.find(".volume-bar-value").height(h<0? 0 : h<=68? h : 68);
806}
807
808
809function defaultEmisora() {
810	let lastSelectedID = localStorage.getItem("defaultEmisora");
811	if (!lastSelectedID) {
812		//Una al azar
813		lastSelectedID = emisoras[Math.floor(Math.random()*emisoras.length)].id;
814	}	
815    console.log('defaultEmisora', lastSelectedID);
816	selectEmisora(lastSelectedID);
817}
818
819function setDefaultEmisora(emisora) {
820	localStorage.setItem("defaultEmisora", emisora.id)
821}
822
823function createGlobalNewsObserver() {
824    let observer;
825
826    let options = {
827        root: null,
828        rootMargin: "0px",
829        threshold: [0.0, 0.75]
830    };
831
832    observer = new IntersectionObserver(handleGlobalNewsIntersect, options);
833    observer.observe(document.querySelector("#homenews"));
834}
835
836let getGlobalNewsFeedInterval;
837function handleGlobalNewsIntersect(entries) {
838    
839
840    entries.forEach((entry) => {
841        const adBox = entry.target;
842
843        if (entry.isIntersecting) {
844            //console.log('Elvis has ENTERED the building ');
845            if (GLOBAL_NEWS_SWIPER)
846                GLOBAL_NEWS_SWIPER.autoplay.resume();
847
848        } else {            
849            //console.log('Elvis has LEFT the building ');
850            if (GLOBAL_NEWS_SWIPER)
851                GLOBAL_NEWS_SWIPER.autoplay.pause();
852        }
853    });
854    
855}
856
857function initGlobalNewsFeed() {
858    //Inicializar slide de noticias
859    initGlobalNewsSwiper();
860
861    //! sin el timeout no coge el pause
862    setTimeout(function() {
863        if (GLOBAL_NEWS_SWIPER) {
864            GLOBAL_NEWS_SWIPER.autoplay.pause();
865        }    
866    }, 200);
867
868    $("#home-news").mouseenter(function() {  
869        if (GLOBAL_NEWS_SWIPER)
870            GLOBAL_NEWS_SWIPER.autoplay.pause();
871    }).mouseleave(function() {
872        if (GLOBAL_NEWS_SWIPER)
873            GLOBAL_NEWS_SWIPER.autoplay.resume();
874    });
875    
876
877    getGlobalNewsFeedInterval = setInterval(function() {
878        console.log('feed global refresh!');
879        getGlobalNewsFeed();
880    }, FEEDS_NOTICIAS_OPTS.refresh);
881    
882	// set interval update
883    createGlobalNewsObserver();
884}
885
886function getGlobalNewsFeed() {
887        
888    getNewsFeed().fail(function () {
889		//Ignoramos, si falla esto no le importa a nadie?
890	}).done(function (data) {
891		
892        if (data.success) {
893			
894			let actualizar = true; 
895			
896			//Miramos si tenemos nueva versión
897			let lastPubDate = $("#home-news").data("lastPubDate");
898            
899            if (lastPubDate) {
900                if (data.result.pubDate) {
901                    let pubDate = moment(data.result.pubDate);                    
902                    if (!pubDate.isAfter(moment(lastPubDate))) {
903                        actualizar = false;
904                    }
905                }
906            }
907
908            if (actualizar) {
909                
910                $("#home-news").data("lastPubDate", data.result.pubDate);
911                        
912                $("#home-news .swiper-wrapper .news-slider__item:not(.keep-slider__item)").remove();
913                
914                data.result.newsList.forEach(function(noticia, i) {
915
916                    let figure = '';
917                    if (noticia.photo) {
918                        figure = `<div class="photo">
919                                <figure><img src="${noticia.photo}"/></figure>
920                            </div>`;
921                    }
922
923                    $(`<div class="news-slider__item swiper-slide">
924                        <div>
925							<div class="title"><a href="${noticia.link}" target="_blank">${noticia.title}</a></div>
926                            <div class="date">${noticia.pubDate? moment(noticia.pubDate).format("DD [de] MMM YYYY") : ''}</div>
927                            ${figure}
928                            <div class="desc">
929                                ${noticia.description}
930                            </div>
931                    </div>`).appendTo($("#home-news .swiper-wrapper"));
932                });
933
934                if (GLOBAL_NEWS_SWIPER) {
935                    //Nota, el .update() no me funciona bien 
936                    GLOBAL_NEWS_SWIPER.destroy();
937                    initGlobalNewsSwiper();
938
939                }
940
941			}	
942            
943        }
944	});
945}
946
947function initGlobalNewsSwiper() {
948
949    let hayLVD = $(".swiper-slide.lvd").length>0;
950    let numSlides = 1;
951    if ($("body").hasClass("xs")) {
952        numSlides = 1;
953    } else if ($("body").hasClass("sm")) {
954        if (hayLVD) {
955            numSlides = 2;
956        } else {
957            numSlides = 1;
958        }
959    } else {
960        if (hayLVD) {
961            numSlides = 1;
962        } else {
963            numSlides = 2;
964        }
965    }
966    
967    GLOBAL_NEWS_SWIPER = new Swiper('#home-news .swiper', {
968        // Optional parameters
969        direction: 'horizontal',
970        slidesPerView: numSlides,
971        spaceBetween: 10,
972        freeMode: true,
973        grabCursor: true,
974        autoplay: {delay: FEEDS_NOTICIAS_OPTS.autoplay_delay},
975        loop: true,
976        // If we need pagination
977        pagination: {
978            el: '.swiper-pagination',
979            clickable: true
980        }
981        
982    });
983
984}
985
986function initLocalNewsSwiper() {
987    
988    let dir = 'vertical';
989	if ($("body").hasClass("xs")) {
990        dir = 'horizontal';
991    } 
992    
993    LOCAL_NEWS_SWIPER = new Swiper('#emisora-news .swiper', {
994        // Optional parameters
995        direction: dir,
996        slidesPerView: 1,
997        spaceBetween: 30,
998        freeMode: true,
999        grabCursor: true,
1000        autoplay: {delay: FEEDS_NOTICIAS_OPTS.autoplay_delay},
1001        loop: true,
1002        // If we need pagination
1003        pagination: {
1004            el: '.swiper-pagination',
1005            clickable: true
1006        }
1007        
1008    });
1009}
1010
1011
1012function updateRRSSIcons(emisora) {
1013    $(".social li a").each(function(){
1014        $(this).attr("href", $(this).data("general"));
1015    });
1016
1017    if (emisora.rrss) {
1018        if (emisora.rrss.twitter) {
1019            let twitter_account = "http://x.com/" + emisora.rrss.twitter.replace("http://x.com/", "");
1020            $(".social li.tw a").attr("href", twitter_account);
1021        }
1022        if (emisora.rrss.facebook) {
1023            let facebook_account = "https://www.facebook.com/" + emisora.rrss.facebook.replace("https://www.facebook.com/", "");
1024            $(".social li.fb a").attr("href", facebook_account);
1025        }
1026        if (emisora.rrss.instagram) {
1027            let instagram_account = "https://www.instagram.com/" + emisora.rrss.instagram.replace("https://www.instagram.com/", "");
1028            $(".social li.inst a").attr("href", instagram_account);
1029        }
1030    }
1031
1032}
1033
1034
1035function showHomeBanner(home_config) {
1036	
1037	if (home_config.banner) {
1038		$("#homebanner").html(home_config.banner);
1039	}
1040	
1041	if (home_config.video) {
1042		$("#homevideo").html(home_config.video);
1043	}
1044	
1045	//mockImageUrls([$("#homebanner")]);
1046}
1047        
1048function refreshDirectos() {
1049    getDirectos().fail(function () {
1050		//Ignoramos, si falla esto no le importa a nadie?
1051		console.warn("Fallo la carga de los directos.");
1052	}).done(function (emisoras) {
1053		
1054        for (const [emisoraid, programa] of Object.entries(emisoras)) {
1055            let programa_url = `${contextPath}programa/${programa.programId}/${programa.slug}/`;
1056
1057            let figure = "";
1058            if (programa.photoURL) {
1059                figure = `<figure>
1060                    <img alt="${programa.name}" src="${contextPath}img/uploads/programas/${programa.photoURL}">
1061                </figure>`;
1062            }
1063            
1064            console.log('programa', programa, programa.programmingWeek);
1065            let progtext = "";
1066            if (programa.progfija) {
1067                progtext = `<li>${programa.progtext}</li>`;
1068            } else {
1069                for (let day in programa.programmingWeek){
1070                    let emision = programa.programmingWeek[day];
1071                    progtext += `<li>De lunes a viernes de ${emision.horaStart} a ${emision.horaEnd}</li>`;
1072                }
1073            }
1074
1075            let archivo = "";
1076            if (programa.archivar) {
1077                let podcast_url = `${contextPath}archivo/${programa.programId}/${programa.slug}/`;
1078                archivo = `<div class="archivo">
1079                        <a href="${podcast_url}" title="Podcast">
1080                            <i class="icon iconoir iconoir-microphone-minus"></i>
1081                            Podcast
1082                        </a>
1083                    </div> <!-- .archivo -->`;
1084            }
1085            $("#homereproductores .directos .directo#directo" + emisoraid).html(`
1086
1087                <div class="onair ${!programa.photoURL? "sinfoto" : ""}">
1088                    ${figure}
1089                    <div class="title">
1090                        <a href="${programa_url}">${programa.name}</a>
1091                    </div> <!-- .title -->
1092                    <div class="programacion">
1093                        <ul>${progtext}</ul>
1094                    </div> <!-- .programacion -->
1095                    ${archivo}													
1096                </div> <!-- .onair -->
1097            `);
1098        }
1099
1100        //mockImageUrls([$("#homereproductores .directos")]);
1101
1102	});
1103}
1104
1105function getDirectos() {	
1106	var deferred = $.Deferred();
1107    
1108	$.ajax({
1109		url: contextPath + "app/app.action",
1110		dataType: "json",
1111		type: 'POST',
1112        data: {action: 'directos'},
1113		error: function(jqXHR, textStatus, errorThrown) {
1114	    	//error(textStatus);
1115			deferred.reject({status: jqXHR.status, message: 'Error al obtener los directos'});
1116        },
1117        success: function(data) {
1118			deferred.resolve(data.result);
1119		}
1120	});
1121	
1122	return deferred.promise();
1123}
1124
1125
1126_lvdAudioDuration = 0;
1127function loadLVDJPlayer(audio_url) {
1128    var player = $("#lvd_jplayer");
1129
1130    player.jPlayer({
1131        ready: function () {
1132            ready = true;
1133
1134            $(this).jPlayer("setMedia", {
1135                title: "La voz del día",
1136                mp3: audio_url
1137            });
1138        },
1139        swfPath: "/js/ext/jplayer",
1140        supplied: "mp3",
1141        keyEnabled: false,
1142        preload: 'none',
1143        play: function () { },
1144        pause: function () { },
1145        ended: function () {
1146            $("#lvd_jplayer").jPlayer("pause");
1147            $(".swiper-slide.lvd .reproductor .controls .buttons .pause").hide();
1148            $(".swiper-slide.lvd .reproductor .controls .buttons .resume").show();
1149        },
1150        error: function(event) {
1151            console.error(event);
1152        },
1153        timeupdate: function(event) { 
1154            
1155            _lvdAudioDuration = event.jPlayer.status.duration;
1156            const currentTime = event.jPlayer.status.currentTime;
1157
1158            if (_lvdAudioDuration > 0) {
1159                let current = (Math.floor(currentTime/60)+":"+Math.floor(currentTime%60)).padStart(2,"0");
1160                let end = (Math.floor(_lvdAudioDuration/60)+":"+Math.floor(_lvdAudioDuration%60)).padStart(2,"0");
1161
1162                let total = $(".swiper-slide.lvd .reproductor .resume-time-bar .time-bar").width();
1163                let w = total*currentTime / _lvdAudioDuration;
1164
1165                $(".swiper-slide.lvd .reproductor .resume-time-bar .time-bar .time-bar-value").width(w);
1166
1167                $(".swiper-slide.lvd .reproductor .resume-time-bar .resume .actual").html(current);
1168                $(".swiper-slide.lvd .reproductor .resume-time-bar .resume .end").html(end);
1169            }
1170
1171        }
1172    });
1173    
1174}

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.