// Elements
const drone = document.getElementById("drone");
const droneDropdown = document.getElementById("droneSelection");
const drones = [
["1", "mu1"], ["2", "mu2"], ["3", "mu3"],
["4", "mu4"], ["5", "mu5"], ["6", "mu6"]
]
// Load initial settings
document.onload = initPage();
droneDropdown.addEventListener("change", droneChange);
// Function to initialize the page
function initPage() {
// TODO: Replace /home/spiri/services with some root level path
// Search for drones files in the services directory and populate the dropdown with directory names
addDropDown(droneDropdown, drones, "1");
}
function droneChange() {
console.log(droneDropdown.value);
return ;
var drone1Table = "
";
var drone2Table = "";
var drone3Table = "";
var drone4Table = "";
var drone5Table = "";
switch(droneDropdown.value)
{
case "Drone1":
document.getElementById("myTableContainer").innerHTML = drone1Table
break;
case "Drone2":
document.getElementById("myTableContainer").innerHTML = drone2Table
break;
case "Drone3":
document.getElementById("myTableContainer").innerHTML = drone3Table
break;
case "Drone4":
document.getElementById("myTableContainer").innerHTML = drone4Table
break;
case "Drone5":
document.getElementById("myTableContainer").innerHTML = drone5Table
break;
}
}
// Restart drone service
function displayDroneTable() {
// upaate table
;
}
function addDropDown(box, pairs, defaultValue) {
try {
for(let i = 0; i < pairs.length; i++){
if (pairs[i].length == 0 || pairs[i][0] === "" || pairs[i][1] === "") continue;
const option = document.createElement("option");
option.value = pairs[i][0];
option.text = pairs[i][1];
box.add(option);
if (defaultValue === option.value) {
box.value = option.value;
}
}
}
catch(e) {
displayFail(e)
}
}