1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2024-11-23 01:13:25 +01:00

add channel options in website

This commit is contained in:
LaQuay 2019-03-24 18:47:35 +01:00
parent d902d87521
commit 63f86be304
2 changed files with 20 additions and 22 deletions

View file

@ -60,6 +60,7 @@
<br>
<em id="video-resolution"></em>
<p id="extra-video-info" style="display: block"></p>
<div id="option-buttons"></div>
</div>
</div>
<div id="audio" style="margin-top: 15px">

View file

@ -123,13 +123,6 @@ function getURLsFromPLS(sUrl, fn_callback) {
}
});
fn_callback($urls)
//$.each($urls, function( index, value ) {
// if (checkIfWebsiteWorks(value)) {
// fn_callback(value);
// break;
// }
//});
});
};
@ -166,16 +159,8 @@ function getUrlParameter(sParam) {
}
};
// Check an URL is valid or broken
// FIXME: For streams if it works it keeps loading infinite time
function checkIfWebsiteWorks(sUrl){
$.get(sUrl, function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
}
function filterChannelsList() {
var input, filter, div, li, a, i, txtValue;
var input, filter, div, elements, txtValue;
input = document.getElementById("searchInput");
filter = input.value.toUpperCase();
@ -192,11 +177,24 @@ function filterChannelsList() {
}
}
function onChannelClick(channel){
channel = JSON.parse(channel);
reproduceVideo(channel['options'][0]['url'])
function reproduceChannel(channel_options) {
options = channel_options;
//document.getElementById("titleh1").innerText = document.getElementById("container").offsetWidth
document.getElementById("option-buttons").innerHTML = ""
if (options.length == 1) {
reproduceVideo(channel['options'][0]['url'])
} else if (options.length > 1) {
for (i = 0; i < options.length; ++i) {
var url = options[i]['url'];
document.getElementById("option-buttons").innerHTML +=
"<a href='javascript:reproduceVideo(\"" + url + "\")' class='btn btn-secondary btn-sm' style='margin-right: 10px'>Opción " + (i+1) + "</a>";
}
}
}
function onChannelClick(channel) {
channel = JSON.parse(channel);
reproduceChannel(channel['options'])
if (document.getElementById("container").offsetWidth < 720) {
document.getElementById("video").scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
@ -209,13 +207,12 @@ function loadChannelsInList() {
return response.json();
})
.then(function(myJson) {
console.log(myJson);
nacionales = myJson[1];
var items = [];
$.each(nacionales["ambits"], function( ambit, ambit_val ) {
$.each(ambit_val["channels"], function( key, val ) {
items.push("<a href='javascript:onChannelClick("+ JSON.stringify(JSON.stringify(val)) + ")' class='list-group-item list-group-item-action'>" + val["name"] + "</a>")
items.push("<a href='javascript:onChannelClick(" + JSON.stringify(JSON.stringify(val)) + ")' class='list-group-item list-group-item-action'>" + val["name"] + "</a>")
});
});