// Timeline drag and drop elements default attributes const tl_cont_attr = {id:"tl_cont", ondrop: "drop(event, this)", ondragover:"allow_drop(event)"}; const tl_drag_attr = {id:"tl_drag", draggable:"true", ondragstart:"drag(event, this)"}; // Config var DEBUG = 0; var cmd_port = "8888"; var timeline_color_cursor = "#FF8839"; var timeline_color_bg = "#2EB8E600"; var scan_interval = 3000; var status_all = "Searching network for live hosts..."; // Global vars var src_elem = ""; var medias_status = {}; var fileButtons = []; var freeze_timeline_update = 0; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function update_playlist(host){ var media_count = document.getElementById("timeline_" + host).children.length; // Reversed loop for (i=media_count,l=0;i>l;i--) { //~ for (i=0,l=media_count;i-1){ elem = elem.children[child]; } var att = document.createAttribute(attr); att.value = val; elem.setAttributeNode(att); } function add_HTML_element(type, attr, meta=0, j=0){ // Add HTML element with type 'type' and attributes 'attr'. // 'attr' should be a javascript object // 'meta' should be an array // 'j' is used to pass an increment value when used in a loop // var elem = document.createElement(type); var keys_array = Object.keys(attr); for (i=0, l=keys_array.length;i -1 || command.indexOf("/poweroff") > -1 ) { if ( !confirm("Êtes vous certain de vouloir effectuer cette action ?") ) { return 0; } } else if ( command == "/scan" ) { document.getElementById("status_all").innerHTML = status_all; } else if ( command.indexOf("/sort") > -1 ){ if (command.indexOf('/1/') > -1 ) { clickedButton.value = clickedButton.value.replace('/1/','/0/'); } else { clickedButton.value = clickedButton.value.replace('/0/','/1/'); } } // AJAX request var request = new XMLHttpRequest(); if ( command == "/scan") { request.onload = send_ajax_cmd(command); } else if ( command.indexOf("/clear") > -1 || command.indexOf("/sort") > -1) { request.onload = send_ajax_cmd(command); } else if ( command == "/sync/all" ) { status_all = "Syncing files..."; request.onload = send_ajax_cmd("/sync/status"); } // build request request.open("GET", command, true); // send request request.send(); }); } }, true); // Metadata display function parse_result(command, infos_array) { if (command == "/all/status") { // Requests current status of every instances, especially current media file's name, position and length. // Also retrieves loop and repeat status. // // Iterate over array for (var i = 0, l=infos_array.length; i " + infos_array[i].time + " / " + infos_array[i].leng; medias_status[infos_array[i].id] = infos_array[i].pos; // Highlight currently playing element timeline_medias_array = Array.from(document.querySelectorAll('[media_id]')); for (var z=0, x=timeline_medias_array.length; z -1 ) { // Requests playlist of every instances // if (!freeze_timeline_update){ console.log("Timeline freeze : " + freeze_timeline_update); console.log("Infos array : " + infos_array); for (var i = 0, l=infos_array.length; i" + "Filename" + "Duration" + ""; for (var j = 0, k=infos_array.length; j" + infos_array[j] + "" + "" + "00:00" + "" + "" ; } html_table += ""; document.getElementById("filelist").innerHTML = html_table; } else if ( command == "/all/rssi") { // RSSI strength indicator var signal_color = 40; var best_rssi = 30; var worst_rssi = 70; for (var j = 0, k=infos_array.length; j4?4:rssi_norm; i