1(function (window, undefined) { 2 var History = window.History, 3 $ = window.jQuery, 4 document = window.document; 5 6 if (!History.enabled) return false; 7 8 $(function () { 9 var rootUrl = "https://radarlisboa.fm/"; 10 var contentSelector = '#contback', 11 $content = $(contentSelector), 12 $body = $(document.body); 13 14 if ($content.length === 0) $content = $body; 15 16 $.expr.pseudos.internal = function (obj) { 17 var $this = $(obj), 18 url = $this.attr('href') || ''; 19 return url.substring(0, rootUrl.length) === rootUrl || url.indexOf(':') === -1; 20 }; 21 22 var documentHtml = function (html) { 23 return String(html).replace(/<\!DOCTYPE[^>]*>/i, '') 24 .replace(/<(html|head|body|title|script)([\s\>])/gi, '<div id="document-$1"$2') 25 .replace(/<\/(html|head|body|title|script)\>/gi, '</div>'); 26 }; 27 28 $.fn.ajaxify = function () { 29 var $this = $(this); 30 $('body').on('click', 'a:internal:not(.no-ajax,[href^="#"],[href*="wp-login"])', function (event) { 31 var $this = $(this), 32 url = $this.attr('href'); 33 34 if (event.which == 2 || event.metaKey) return true; 35 36 History.pushState(null, null, url); 37 event.preventDefault(); 38 return false; 39 }); 40 return $this; 41 }; 42 43 $body.ajaxify(); 44 45 function loadScriptsSequentially(scripts, callback) { 46 if (scripts.length === 0) { 47 if (callback) callback(); 48 return; 49 } 50 51 var script = scripts.shift(); 52 if (typeof window[script.name] !== "undefined") { 53 console.log(`${script.name} já carregado.`); 54 loadScriptsSequentially(scripts, callback); 55 return; 56 } 57 58 console.log(`Carregando ${script.name}...`); 59 var newScript = document.createElement("script"); 60 newScript.src = script.src; 61 newScript.onload = function () { 62 console.log(`${script.name} carregado com sucesso.`); 63 loadScriptsSequentially(scripts, callback); 64 }; 65 newScript.onerror = function () { 66 console.error(`Erro ao carregar ${script.name}`); 67 loadScriptsSequentially(scripts, callback); 68 }; 69 document.head.appendChild(newScript); 70 } 71 72 $(window).on('statechange', function () { 73 var State = History.getState(), 74 url = State.url; 75 76 $body.addClass('loading'); 77 $content.animate({ opacity: 0 }, 500); 78 79 $.ajax({ 80 url: url, 81 success: function (data) { 82 var $data = $(documentHtml(data)), 83 $dataBody = $data.find('#document-body:first ' + contentSelector), 84 contentHtml = $dataBody.html() || $data.html(); 85 86 if (!contentHtml) { 87 document.location.href = url; 88 return false; 89 } 90 91 $content.stop(true, true); 92 $content.html(contentHtml).ajaxify().animate({ opacity: 1 }, 500, function () { 93 console.log("Conteúdo atualizado. Recarregando scripts..."); 94 95 loadScriptsSequentially([ 96 { src: "https://radarlisboa.fm/wp-includes/js/dist/vendor/react.min.js", name: "React" }, 97 { src: "https://radarlisboa.fm/wp-includes/js/dist/vendor/react-dom.min.js", name: "ReactDOM" }, 98 { src: rootUrl + "wp-content/themes/beaton/js/script.js", name: "Script principal" }, 99 { src: "https://radarlisboa.fm/wp-content/themes/beaton/js/slider.revolution.js", name: "Slider Revolution" } 100 ], function () { 101 console.log("Todos os scripts carregados."); 102 initializeSlider(); 103 initializeRadioPlayer(); 104 }); 105 }); 106 }, 107 error: function () { 108 document.location.href = url; 109 } 110 }); 111 }); 112 113 function initializeSlider() { 114 if ($('.rev_slider').length) { 115 console.log("Reinicializando Slider Revolution..."); 116 if (typeof $.fn.revolution !== "undefined") { 117 $(".rev_slider").each(function () { 118 var $slider = $(this); 119 var options = $slider.data("options") || {}; 120 console.log("Reinicializando slider..."); 121 $slider.revolution(options); 122 }); 123 } else { 124 console.error("Erro: Slider Revolution não encontrado."); 125 } 126 } 127 } 128 129 function initializeRadioPlayer() { 130 if ($('.radio_player').length) { 131 console.log("Reinicializando o player..."); 132 loadRadioPlayerScript(); 133 } 134 } 135 136 function loadRadioPlayerScript() { 137 console.log("Carregando script do player manualmente..."); 138 var playerScriptUrl = "https://radarlisboa.fm/wp-content/plugins/radio-player/assets/js/frontend.js"; 139 var newScript = document.createElement("script"); 140 newScript.src = playerScriptUrl; 141 console.log("test----"+window.radioPlayer); 142 newScript.onload = function () { 143 console.log("Script do player carregado. Tentando inicializar..."); 144 setTimeout(() => { 145 if (window.radioPlayer) { 146 console.log("Executando radioPlayer.init()..."); 147 //window.radioPlayer.init(); 148 } else { 149 console.error("Falha ao inicializar radioPlayer. Verifique a compatibilidade."); 150 console.log(window.radioPlayer); 151 //window.radioPlayer.init({ target: '.radio_player' }); 152 } 153 }, 2000); 154 }; 155 newScript.onerror = function () { 156 console.error("Erro ao carregar o script do player."); 157 }; 158 document.head.appendChild(newScript); 159 } 160 161 162 163 164 /*****End****/ 165 166 167 }); 168})(window);
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.