aboutsummaryrefslogtreecommitdiff
path: root/client/js/radio_emulator.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/js/radio_emulator.js')
-rw-r--r--client/js/radio_emulator.js73
1 files changed, 42 insertions, 31 deletions
diff --git a/client/js/radio_emulator.js b/client/js/radio_emulator.js
index 7064a5e..aafed52 100644
--- a/client/js/radio_emulator.js
+++ b/client/js/radio_emulator.js
@@ -135,7 +135,7 @@ function FetchAudio(url)
request.addEventListener("progress", (event)=>{
if (event.lengthComputable)
{
- dlProgressBar.value = (event.loaded/event.total)*100;
+ placeholders.dlProgress.value = (event.loaded/event.total)*100;
}
});
request.addEventListener("error", ()=>{
@@ -258,38 +258,49 @@ function listCallback(json, params)
{
FetchJSON(`${jsonRequest}${json.list[0].hash}`, loadShowCallback, [json, now_on_sequence, json.list[0], hash_of_list]);
}
- for ( var i = 1; i < json.list.length; i++)
+ else
{
- debugLog("getting there")
- if ( now_on_sequence < json.list[i].starts_on && now_on_sequence > json.list[i-1].starts_on )
- {
-
- var tmp = document.createElement('pre');
- tmp.innerText = JSON.stringify(json.list[i-1], null, 2);
- placeholders.previouslyPlayed.append(tmp);
- now_on_sequence = now_on_sequence - previous.starts_on;
- debugLog(`now_on_sequence (1updated): ${now_on_sequence}`);
- previous = json.list[i-1];
- FetchJSON(`${jsonRequest}${previous.hash}`, loadShowCallback, [json, now_on_sequence, previous, hash_of_list]);
- debugLog('First!');
- break;
- }
- else if ( now_on_sequence > json.list[i].starts_on && now_on_sequence > json.list[i-1].starts_on )
- {
- var tmp = document.createElement('pre');
- tmp.innerText = JSON.stringify(json.list[i-1], null, 2);
- placeholders.previouslyPlayed.append(tmp);
- FetchJSON(`${jsonRequest}${json.list[i].hash}`, loadShowCallback, [json, now_on_sequence, json.list[i], hash_of_list]);
- debugLog('Second!');
- break;
- }
- else
+ for ( var i = 0; i < json.list.length - 1; i++)
{
- debugLog(now_on_sequence);
- debugLog(json.list[i].starts_on);
- debugLog(json.list[i-1].starts_on);
- debugLog('Nothing!');
- continue;
+ debugLog("getting there")
+ if ( now_on_sequence > json.list[i].starts_on && now_on_sequence < json.list[i+1].starts_on )
+ {
+ if( i !== 0)
+ {
+ var tmp = document.createElement('pre');
+ tmp.innerText = JSON.stringify(json.list[i-1], null, 2);
+ tmp.style = "overflow-x: auto;";
+ placeholders.previouslyPlayed.append(tmp);
+ }
+ now_on_sequence = now_on_sequence - json.list[i].starts_on;
+ debugLog(`now_on_sequence (1updated): ${now_on_sequence}`);
+ FetchJSON(`${jsonRequest}${previous.hash}`, loadShowCallback, [json, now_on_sequence, json.list[i], hash_of_list]);
+ debugLog('First!');
+ break;
+ }
+ else if ( now_on_sequence > json.list[i].starts_on && now_on_sequence > json.list[i+1].starts_on )
+ {
+ i++;
+ if( i !== 0)
+ {
+ var tmp = document.createElement('pre');
+ tmp.innerText = JSON.stringify(json.list[i-1], null, 2);
+ tmp.style = "overflow-x: auto;";
+ placeholders.previouslyPlayed.append(tmp);
+ }
+ //now_on_sequence = now_on_sequence - json.list[i].starts_on;
+ FetchJSON(`${jsonRequest}${json.list[i].hash}`, loadShowCallback, [json, now_on_sequence, json.list[i], hash_of_list]);
+ debugLog('Second!');
+ break;
+ }
+ else
+ {
+ debugLog(now_on_sequence);
+ debugLog(json.list[i].starts_on);
+ debugLog(json.list[i-1].starts_on);
+ debugLog('Nothing!');
+ continue;
+ }
}
}
}