Added first function to fill the editor with default values
This commit is contained in:
parent
de5dbda939
commit
60b110b4b9
2 changed files with 47 additions and 2 deletions
|
@ -30,6 +30,7 @@ amain.classList.remove("pure-button-primary");
|
||||||
acfg.classList.remove("pure-button-primary");
|
acfg.classList.remove("pure-button-primary");
|
||||||
atde.classList.add("pure-button-primary");
|
atde.classList.add("pure-button-primary");
|
||||||
createTable();
|
createTable();
|
||||||
|
fillTableFromJson();
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error: load listener of the tab action listener management: " + error.message);
|
console.log("Error: load listener of the tab action listener management: " + error.message);
|
||||||
|
@ -292,4 +293,25 @@ container.innerHTML = "";
|
||||||
container.classList.add("pure-form");
|
container.classList.add("pure-form");
|
||||||
container.appendChild(table);
|
container.appendChild(table);
|
||||||
container.appendChild(button);
|
container.appendChild(button);
|
||||||
}
|
}
|
||||||
|
function fillTableFromJson() {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var json = JSON.parse(this.responseText);
|
||||||
|
var tableRows = document.querySelectorAll("table tr");
|
||||||
|
for (var i = 1; i < tableRows.length; i++) {
|
||||||
|
var cells = tableRows[i].querySelectorAll("td");
|
||||||
|
var hour = parseInt(cells[0].querySelector("select").value);
|
||||||
|
var minute = parseInt(cells[1].querySelector("select").value);
|
||||||
|
for (var j = 0; j < json.tcdata.length; j++) {
|
||||||
|
if (json.tcdata[j].hour == hour && json.tcdata[j].min == minute) {
|
||||||
|
cells[2 + j].querySelector("select").value = json.tcdata[j]["ch" + (j + 1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.open("GET", "http://192.168.0.27/tc_data_blocks_read", true);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ function addTabListener() {
|
||||||
atde.classList.add("pure-button-primary");
|
atde.classList.add("pure-button-primary");
|
||||||
|
|
||||||
createTable(); // recreate the table on timing data editor tab
|
createTable(); // recreate the table on timing data editor tab
|
||||||
|
fillTableFromJson();
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error: load listener of the tab action listener management: " + error.message);
|
console.log("Error: load listener of the tab action listener management: " + error.message);
|
||||||
|
@ -354,4 +355,26 @@ function createTable() {
|
||||||
container.classList.add("pure-form");
|
container.classList.add("pure-form");
|
||||||
container.appendChild(table);
|
container.appendChild(table);
|
||||||
container.appendChild(button);
|
container.appendChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillTableFromJson() {
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
var json = JSON.parse(this.responseText);
|
||||||
|
var tableRows = document.querySelectorAll("table tr");
|
||||||
|
for (var i = 1; i < tableRows.length; i++) {
|
||||||
|
var cells = tableRows[i].querySelectorAll("td");
|
||||||
|
var hour = parseInt(cells[0].querySelector("select").value);
|
||||||
|
var minute = parseInt(cells[1].querySelector("select").value);
|
||||||
|
for (var j = 0; j < json.tcdata.length; j++) {
|
||||||
|
if (json.tcdata[j].hour == hour && json.tcdata[j].min == minute) {
|
||||||
|
cells[2 + j].querySelector("select").value = json.tcdata[j]["ch" + (j + 1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.open("GET", "http://192.168.0.27/tc_data_blocks_read", true);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue