// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0 var uaxhttpattempt=0; var page_init; var album_displayed=0; var overload_track_counter=NaN; var infoselected=null; var infoselected=null; var size; var album_counter=document.getElementsByClassName('lineTranslate').lenght; var thumbnail_counter=0; var thumbnail_max=0; var target_album=''; var embed=null; var overloadindexchecked=false; //yp stuff var ypping=true; var myfunc=null; var yprun=true; var ypindex=0; var appendypreq=''; var ypretries=0; var ypcurrentindexretries=0; var stall=false; var yparrvalidated=[]; var nosocialupdate=false; //ping recently played var xhttpingprecalb=null; var titleSite=''; var artist; var album; var track; var offset; var isindex=undefined; var overloadtimer=null; var embed_value=''; var isplaying; var isautoplay; var str_album_count; var dl_album_count; var recentplay; var playerErrorTimer=0; var playerErrorTimestamp=0; var myoverloadtimer=null; var radioIntervalFunc=null; var radiomsg=''; var radioajax; function clearRadioInterval(){ if (radioIntervalFunc!=null){ window.clearInterval(radioIntervalFunc); radioIntervalFunc=null; } } function update_radio_nowplaying(){ if (document.getElementById('radio_nowplaying')==null){ window.clearInterval(radioIntervalFunc); radioIntervalFunc=null; } else { document.getElementById('radio_nowplaying').innerHTML=radiomsg; } radioajax = new XMLHttpRequest; radioajax.onreadystatechange = radionymous; radioajax.open("GET", "./radio_data.php", true); radioajax.send(); } function radionymous() { if (this.readyState == 4 && this.status == 200) { myresponse=new String(this.responseText).split("\n"); if (parseFloat(myresponse[0]) only player on the main section (aka anything but Radio: index page, album pages, artist-album pages, track pages) will throw an onError JS event //since the error can be caused for many, various reason, we are just going to try to relaunch play(); on the player ; this is typically for media data not coming from the HTTP server serving... Media data //by far the most common case //So let it a chance to send again the (partial-content) data and then to allow the listener to get its playback back after a quick cut is our aim with this call to play() after an error was triggered //but since we don't want to overload the HTTP server providing us with audio, we are going //to wait a bit, before trying... And if errors continue to arrive in a short time //to wait each time a bit more, increasing the waiting time //which is necessary to avoid general server overload and therefore never recovering //This waiting behavior is achevied with the use of two global scope var defined outside this function: // * playerErrorTimer : it is initially set to 0. It defines how much we will wait before a retry. Once the first call, we'll increment it of 500ms, wait for 500ms, and try to play() // but on any possible subsequent call, we'll increment it again of 500ms each time. It means that if errors remains, we'll wait for 1000, 1500, 2000, 2500, 3000 and so on each time before attempting play() // (and test if player is not already playing, before launching play(), because an previous thread can possibly already have solved the error, since we'll use timeOuts, which are asynchronous) // * playerErrorTimestamp : it is initially set to 0. If this function is called for the first time, we'll store a current Date().getTime() and then we'll know we're in trouble and do the playerErrorIncrement // has explained above // BUT if this function is called, but playerErrorTimestamp is older than 5 minutes, which means the player hasn't triggered any error for the past 5 minutes // we will reset playerErrorTimer to its initial zero value // because if errors cames like the Niagara Falls, if the listener had to wait, if playerErrorTimer raised up to several, long seconds between each play() attempt, and finally, the playback process resumed quietly // and then that after a long while without error (5 minutes as indicated), if on another track, or on another album, an new error is triggered // we want to try to cure it after only a short (500ms) cutoff for the listener, and won't wait for the previously set to a possibly very long time playerErrorTimer before attempting our retry. //First off we look at playerErrorTimestamp, and, if it is older than 5 minutes, // * we reset playerErrorTimer // * we set playerErrorTimestamp to the current time, and, for the next 5 minutes, it will be useful d = new Date(); currentTime = d.getTime(); if (parseInt(playerErrorTimestamp)+300000'; } if (dlformats[0]=='mp3'||dlformats[1]=='mp3'||dlformats[2]=='mp3') { player.innerHTML+=''; } } else { if (strformats[0]=='ogg'||strformats[1]=='ogg'||strformats[2]=='mp3'){ player.innerHTML+=''; } if (strformats[0]=='mp3'||strformats[1]=='mp3'||strformats[2]=='mp3') { player.innerHTML+=''; } } if (document.getElementById('track_artist'+id)!=null&&document.getElementById('track_name'+id)!=null){ update_controler(document.getElementById('track_artist'+id).value, document.getElementById('track_name'+id).value, false); } else { update_controler('no info', 'no info', true) } player.load(); player.play(); setplayerstall(false); } else { set_isplaying(parseInt('-1')); } return parseInt(get_isplaying()); } else { if (document.getElementById(id)!=null){ document.getElementById(id).innerHTML='▶'; } player.pause(); player.currentTime=0; player.innerHTML=null; setplayerstall(false); set_isplaying(parseInt(-1)); } return parseInt(get_isplaying()); } function playNext() { if (isNaN(parseInt(get_isplaying()))){ set_isplaying(parseInt('0')); } player=get_player(); while(!player.paused){player.pause();} if (document.getElementById(get_isplaying())!=null){ document.getElementById(get_isplaying()).innerHTML='▶'; } if (document.getElementById(parseInt(parseInt(get_isplaying())+1))!=null){ document.getElementById(parseInt(parseInt(get_isplaying())+1)).click(); setplayerstall(false); //return parseInt(get_isplaying()); } else { player.pause(); /*if (document.getElementById('digolder')!=null&&get_embed()!=null&&get_embed()==true){//AJAX is not needed on embeded content in separate muscian specific website, since an iframe will honour autoplay without a reclick set_isplaying(-1); setplayerstall(false); window.location.href=document.getElementById('digolder').name+'&autoplay=true';//'./?offset='+(offset+1)+'&autoplay=true'; } else*/ if(document.getElementById('digolder')!=null){ //document.getElementById('digolder').href=document.getElementById('digolder').href+'&autoplay=true'; set_isplaying(-1); document.getElementById('digolder').click(); //document.location.href='./?album='+target_album+'&autoplay=true'; } else { // document.location.href='./?offset='+(offset+1)+'&autoplay=true'; } } } function playPrevious() { if (isNaN(parseInt(get_isplaying()))){ set_isplaying(parseInt('0')); } player=get_player(); while(!player.paused){player.pause();} if (document.getElementById(get_isplaying())!=null){ document.getElementById(get_isplaying()).innerHTML='▶'; } if (document.getElementById(parseInt(parseInt(get_isplaying())-1))!=null){ document.getElementById(parseInt(parseInt(get_isplaying())-1)).click(); setplayerstall(false); //return parseInt(get_isplaying()); } else { player.pause(); /*if (document.getElementById('dignewer')!=null&&get_embed()!=null&&get_embed()==true){//AJAX is not needed on embeded content in separate muscian specific website, since an iframe will honour autoplay without a reclick set_isplaying(-1); setplayerstall(false); window.location.href=document.getElementById('dignewer').name+'&autoplay=true';//'./?offset='+(offset+1)+'&autoplay=true'; } else*/ if(document.getElementById('dignewer')!=null){ //document.getElementById('digolder').href=document.getElementById('digolder').href+'&autoplay=true'; set_isplaying(-1); document.getElementById('dignewer').click(); //document.location.href='./?album='+target_album+'&autoplay=true'; } else { // document.location.href='./?offset='+(offset+1)+'&autoplay=true'; } } } function loadInfo(track) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { infoselected.style.display='block'; infoselected.innerHTML = this.responseText; } } xhttp.open("GET", "./index.php?nochat=1&getinfo="+encodeURI(track), true); xhttp.send(); } function getCover (img, target, size, ratio){ img.src="./thumbnailer.php?target="+target+"&viewportwidth="+parseInt(size)+"&ratio="+parseFloat(ratio); } function cancelCover (img){ img.src='./favicon.png'; img.onLoad='if (!get_page_init()){init_page()};if (album_displayed<=album_counter){album_displayed++;};'; } function cancelAllCovers(){ imgs=document.getElementsByClassName('lineTranslate'); for (i=0;i=height){ size=height; } else { size=width; } return size; } function update_twirling_message(text){ document.getElementById('twirling_message').innerHTML=text; } function increment_thumbnail_counter(){ thumbnail_counter++; update_twirling_message('[Cancel] '+thumbnail_counter+" thumbnails generated just for you, for you screen resolution, once for all"); } function increment_thumbnail_max(){ thumbnail_max++; //update_twirling_message(thumbnail_counter+"/"+thumbnail_max+" thumbnails generated juste for you, for you screen resolution, once for all"); } function update_ajax_body(http_url_target, comesfrominfiniteloop){ clearRadioInterval(); var infiniteloop=false; if (comesfrominfiniteloop!=undefined){ infiniteloop=true; } initlock=false; blockmoved=false; titled=false; set_page_load(false); set_page_init(false); album_displayed=0; album_counter=0; var thumbnail_counter=0; var thumbnail_max=0; var autoplay='false'; var arttruc=''; var size=0; var nosocialupdate=false; var finalurl; var parameters=''; var arg=''; set_overload_track_counter(0); //set_page_init(false); tar = http_url_target; if (tar.startsWith('http://') || tar.startsWith('https://') || tar.startsWith('//') || tar.startsWith('/')) { //this is an absolute, or external url. We don't wan't to do anything with it. //caller shouldn't have it passed to our function //just in case, and it won't respect an possible "target" directive wished by the caller //we are going to move the user brower straight to this address window.location.href=tar; //note that window.location is preferable to document.location. Both are the same. But some awkward browsers have document.location read-only } else { //Here comes our main job. First off, split the target url into //slash-separated tokens finalurl='./?body=ajax'; slashes=tar.split('/'); for (i=0 ; i60){ seconds=Math.floor(mytime%60); if (seconds<10){ seconds='0'+seconds; } mytime=Math.floor(mytime/60)+':'+seconds; } else { seconds=Math.floor(mytime%60); if (seconds<10){ seconds='0'+seconds; } mytime='0:'+seconds; } if (myduration>60){ seconds=Math.floor(myduration%60) if (seconds<10&&seconds!=0){ seconds='0'+seconds; } else if (seconds==0||isNaN(seconds)) { seconds='00'; } myduration=Math.floor(myduration/60)+':'+seconds; } else { seconds=parseInt(Math.floor(myduration)); if (seconds<10&&seconds!=0){ seconds='0'+seconds; } else if (parseInt(seconds)==parseInt('0')) { seconds='00'; } if (isNaN(seconds)){ seconds='00'; } myduration='0:'+seconds; } myclock.innerHTML=mytime+'/'+myduration; } function controler_next(){ if(!get_playerstall()){setplayerstall(true);player=get_player(); if (get_isindex()==true) {while(!player.paused){player.pause();} page_init=false;digolder(0);} else {while(!player.paused){player.pause();} playNext();} player.addEventListener('canplaythrough', function(){setplayerstall(false);});player.addEventListener('error', function(){setplayerstall(false);});player.addEventListener('abort', function(){setplayerstall(false);});} } function controler_prev(){ if(!get_playerstall()){ setplayerstall(true); if (get_isindex()||(get_embed()&&get_offset()=='-1')) {void(0);} else { player=get_player(); while(!player.paused){player.pause();} playPrevious();} player.addEventListener('canplaythrough', function(){setplayerstall(false);});player.addEventListener('error', function(){setplayerstall(false);});player.addEventListener('abort', function(){setplayerstall(false);});} } var playerstall; function get_playerstall(){ return(playerstall); } function setplayerstall(arg){ playerstall=arg; } var twindex=0; var twirl=true; function twirling(){ baton=document.getElementById('twirling'); anim= ['(\\)', '(|)', '(/)', '(-)', '(\\)', '(|)', '(/)', '(-)'] if (twirl){ baton.innerHTML=anim[twindex]; twindex++; } if (twindex==anim.length){ twindex=0; } if (!get_page_load()){ twirl=true; baton.style.display='block'; document.getElementById('twirling_message').style.display='block'; } if (get_page_load()){ twirl=false; baton.style.display='none'; document.getElementById('twirling_message').style.display='none'; } /*if (get_page_init()){ baton.style.display='none'; } if (!get_page_init()){ baton.style.display='block'; }*/ } window.setInterval(clock_tick, 1200); window.setInterval(twirling, 650); var loaded=false; function get_page_load(){ return loaded; } function set_page_load(argk){ loaded=argk; } function autoplay (mycurrenttarget, mycurrentid, mycurrentclewn, mycurrentautoplay){ play(mycurrenttarget, mycurrentid, mycurrentclewn, mycurrentautoplay); } function get_isindex(){ if (isindex==undefined){ return false; } return isindex; } function set_isindex(par){ isindex=par; } //var overloadindexchecked=false; function get_overloadindexchecked(){ return overloadindexchecked; } function set_overloadindexchecked(ckpar){ overloadindexchecked=ckpar; } function update_isindex(){ if (document.getElementById('isindex')!=null){ if (document.getElementById('isindex').value=='true'){ set_isindex(true); } else { set_isindex(false); } } else { set_isindex(false); } } function update_embed(){ if (document.getElementById('embed')!=null){ if (document.getElementById('embed').value=='true'){ set_embed(true); } else { set_embed(false); } } else { set_embed(false); } } function update_embed_value(){ if (document.getElementById('embed_value')!=null){ set_embed_value(document.getElementById('embed_value').value); } } function update_offset(){ if (document.getElementById('offset')!=null){ return parseInt(document.getElementById('offset').value); } else { return parseInt(-1); } } function update_album(){ if (document.getElementById('album')!=null){ return decodeURI(document.getElementById('album').value); } else { return ''; } } function update_artist(){ if (document.getElementById('artist')!=null){ return decodeURI(document.getElementById('artist').value); } else { return ''; } } function update_track(){ if (document.getElementById('track')!=null){ return decodeURI(document.getElementById('track').value); } else { return ''; } } function update_autoplay(){ if (document.getElementById('bodyajax_autoplay')!=null){ if(document.getElementById('bodyajax_autoplay').value=='true'){ set_autoplay(true); if (document.getElementById('autoplay')!=null){ document.getElementById('autoplay').click(); } } else { set_autoplay(false); } } else { set_autoplay(false); } } function update_recentplay() { if (document.getElementById('recentplay_pass')!=null){ if (document.getElementById('recentplay_pass').value=='true'){ set_recentplay(true); } else { set_recentplay(false); } } else { set_recentplay(false); } } function update_artisthighlighthomepage() { if (document.getElementById('artisthighlighthomepage')!=null){ if (document.getElementById('artisthighlighthomepage').value=="true"){ set_artisthighlighthomepage(true); } else { set_artisthighlighthomepage(false); } } else { set_artisthighlighthomepage(false); } } function update_creroypservices() { if (document.getElementById('creroypservices')!=null){ set_creroypservices(parseInt(document.getElementById('creroypservices').value)); } else { set_creroypservices(0); } } function update_album_count(){ if (document.getElementById('dl_album_count')!=null){ set_dl_album_count(parseInt(document.getElementById('dl_album_count').value)); } else { set_dl_album_count(parseInt('-2')); } if (document.getElementById('str_album_count')!=null){ set_str_album_count(parseInt(document.getElementById('str_album_count').value)); } else { set_str_album_count(parseInt('-2')); } } var inc_stall=undefined; function get_inc_stall(){ if (inc_stall==undefined){ return false; } return inc_stall; } function set_inc_stall(argst){ inc_stall=argst; } var toincrement=undefined; function increment_overload_track_counter(){ if (overload_track_counter=NaN){ set_overload_track_counter(0); } set_overload_track_counter(parseInt(get_overload_track_counter())+parseInt(1)); } function get_overload_track_counter(){ if (isNaN(parseInt(overload_track_counter))){ return 0; } return parseInt(overload_track_counter); } function set_overload_track_counter(otca){ overload_track_counter=parseInt(otca); } function get_album(){ return album; } function get_autoplay(){ return isautoplay; } function set_autoplay(auartarg){ isautoplay=auartarg; } function get_init_page(){ if (init_page==null){ return false; } return page_init; } function set_init_page(onld){ page_init=onld; } function get_artist(){ return artist; } function set_artist(artarg){ artist=artarg; } function get_track(){ return track; } function set_track(trarg){ track=trarg; } function get_offset(){ return offset; } function get_embed(){ return embed; } function set_embed(earg){ embed=earg; } function get_embed_value(){ return embed_value; } function set_embed_value(evarg){ embed_value=evarg; } function get_str_album_count(){ return str_album_count; } function set_str_album_count(cevarg){ str_album_count=cevarg; } function get_dl_album_count(){ return dl_album_count; } function set_dl_album_count(dcevarg){ dl_album_count=dcevarg; } function set_offset(offarg){ offset=offarg; } function set_album(aoffarg){ album=aoffarg; } function set_page_init(piarg){ page_init=piarg; } function get_page_init(){ return page_init; } function set_size(spiarg){ size=spiarg; } function get_size(){ return size; } var albumerror=undefined; function get_album_error(){ return albumerror; } function set_album_error(myargerr){ albumerror=myargerr; } function get_recentplay(){ if (recentplay==null){ return false; } return recentplay; } function set_recentplay(rparg){ recentplay=rparg; } var artisthighlighthomepage=null; function get_artisthighlighthomepage(){ if (artisthighlighthomepage==null){ return false; } return artisthighlighthomepage; } function set_artisthighlighthomepage(artparg){ artisthighlighthomepage=artparg; } var creroypservices=0; function get_creroypservices(){ return creroypservices; } function set_creroypservices(cyparg){ creroypservices=parseInt(cyparg); } function gogetit(){ if (!blockmoved){blockmove();} } var blockmoved=false; function blockmove(){ if (blockmoved){ return; } blockmoved = true; //blocks move! New page design thx to Fauve's advices ! blocksToMove=['splash-','links-','recent-','radio-','menu-','artists-','donate-']; for (i=0;i setTimeout(resolve, delayMs)); } } return false; // Échec après toutes les tentatives } // Ta logique principale encapsulée dans une fonction asynchrone async function handleRecentlyPlayedPings() { if (!get_isindex() && get_album() !== '') { const current_recent_album = get_album(); // Je pars du principe que callback_id est défini ailleurs dans ton script const callbackUrl = `./?recently_callback=true&album=${encodeURIComponent(current_recent_album)}&recently_callback_id=${encodeURIComponent(callback_id)}`; // 1. On tente le premier appel (max 10 essais, espacés de 3800ms) const firstPingSuccess = await pingWithRetry(callbackUrl, 10, 3800); // 2. Si le premier a réussi et qu'on doit pinguer le second script if (firstPingSuccess && typeof alb_willhavetoping !== 'undefined' && alb_willhavetoping) { // On tente le second appel (max 10 essais, espacés de 1000ms) const secondPingSuccess = await pingWithRetry("ping_recently_played.php", 10, 1000); if (secondPingSuccess) { alb_willhavetoping = false; // On désactive le flag une fois réussi } } } } var callback_id=Math.random(); var alb_willhavetoping=true; if (!get_isindex()&&get_album()!=''){ // Lancement du script handleRecentlyPlayedPings(); } //ping recently played if (!get_isindex()&&alb_willhavetoping){ // Lancement du script handleRecentlyPlayedPings(); } } //yp stuff ypping=true; nosocialupdate=false; if (myfunc!=null){ clearInterval(myfunc); } myfunc=null; yprun=true; ypindex=0; appendypreq=''; ypretries=0; ypcurrentindexretries=0; stall=false; yparrvalidated=[]; //end yp stuff album_displayed=0; set_size(computeSize(document.documentElement.clientWidth, document.documentElement.clientHeight)); infoselected=null; if (document.getElementById('noscripters')!=null){ document.getElementById('noscripters').style.display='none'; } if (document.getElementById('noscripters_footer')!=null){ document.getElementById('noscripters_footer').style.display='none'; } if (document.getElementById('infiniteloop')!=null){ document.getElementById('bodyajax_autoplay').value='false'; } //initial stuf stats(); update_artisthighlighthomepage(); if (get_artisthighlighthomepage()) { if (get_isindex()){ document.getElementById('crerobody').style.marginLeft="0px"; document.getElementById('crerobody').style.marginRight="0px"; document.getElementById('crerobody').style.paddingLeft="0px"; document.getElementById('crerobody').style.paddingRight="0px"; } else { if (document.documentElement.clientWidth>800){ document.getElementById('crerobody').style.paddingLeft="8%"; document.getElementById('crerobody').style.paddingRight="8%"; } } }//restoration of maring/pading(left/right) is finished //fortunately enough, these things will never change //from one page to antoher //yp stuff update_creroypservices(); if (!get_embed()&&get_creroypservices()>0) { yprun=true;myfunc=setInterval (delegate, 1000); } if (typeof update_cart === "function"){ update_cart(); } //then, sanitize the display URL with something accurate if (document.getElementById('bodyajax')!==null){//this should never happen titleSiteObj={ title:'', url:''}; titleSiteObj.title=document.getElementById('main_title').innerHTML; if ( //this is the most common case ; an GET album, or more GET, are set, and it's an ajax call, and it's not an ajax call to call the homepage (get_album()!=''|| get_artist()!=''|| (get_track()!=''&&get_album()!='') ) && (document.getElementById('bodyajax').value!='./?body=void'&&document.getElementById('bodyajax').value!='') ){ ourURL='./?'; needamp=false; if (get_album()!=''){ ourURL=ourURL+'album='+encodeURIComponent(get_album()); needamp=true; } if (get_artist()!=''){ if (needamp) {ourURL=ourURL+'&';} ourURL=ourURL+'artist='+encodeURIComponent(get_artist()); needamp=true; } if (get_track()!=''){ if (needamp) {ourURL=ourURL+'&';} ourURL=ourURL+'track='+encodeURIComponent(get_track()); needamp=true; } titleSiteObj.url=ourURL; window.history.pushState(titleSiteObj, '', ourURL); } else if (document.getElementById('bodyajax').value!='./?body=void'&&document.getElementById('bodyajax').value.startsWith('?body=ajax&')){//this will happen on anything but indexpage, which does not requires sanitization ourURL=document.getElementById('bodyajax').value; ourURL=ourURL.replace('?body=ajax&', '?'); titleSiteObj.url='./'+ourURL; window.history.pushState(titleSiteObj, '', './'+ourURL); } else if (document.getElementById('bodyajax').value==''){//index page ? //ourURL=document.getElementById('bodyajax').value; //ourURL=ourURL.replace('?body=ajax&', '?'); ourURL=''; if (window.location.href.endsWith('/radio/')){ ourURL='radio/'; } if (get_isindex()||ourURL=='radio/'){ titleSiteObj.url='./'+ourURL; window.history.pushState(titleSiteObj, '', './'+ourURL); } else { //direct arrival on a shared link titleSiteObj.url=window.location.href; window.history.pushState(titleSiteObj, '', window.location.href); } } } //playback stuff setplayerstall(false); if (document.getElementById('digolder')!=null&&get_album()!=''&&(parseInt(get_offset())==parseInt('-1'))||get_offset==''){ document.getElementById('digolder').innerHTML='Dig what\'s new...'; } update_autoplay(); if (activatehtmlcache){ if(true){increment_overload_track_counter();} if (typeof checkOverload === "function"){ checkOverload(true); } } if (document.getElementById('infiniteloop')!=null){ set_page_init(true); document.getElementById('infiniteloop').click(); } initlock=false; }//function initpage // @license-end