Indention fixed
This commit is contained in:
parent
84dd924a1d
commit
fe8b70a5b9
1 changed files with 76 additions and 76 deletions
|
@ -257,91 +257,91 @@ links.forEach(function(link) {
|
|||
});
|
||||
|
||||
function createTable() {
|
||||
var table = document.createElement("table");
|
||||
var table = document.createElement("table");
|
||||
|
||||
// Headerzeile
|
||||
var headerRow = document.createElement("tr");
|
||||
var headers = ["Stunde", "Minute", "ch1", "ch2", "ch3", "ch4"];
|
||||
for (var i = 0; i < headers.length; i++) {
|
||||
var header = document.createElement("th");
|
||||
header.innerHTML = headers[i];
|
||||
headerRow.appendChild(header);
|
||||
}
|
||||
table.appendChild(headerRow);
|
||||
|
||||
// Inhaltszeilen
|
||||
for (var row = 0; row < 10; row++) {
|
||||
var contentRow = document.createElement("tr");
|
||||
|
||||
// Spalte "Stunde"
|
||||
var hourCell = document.createElement("td");
|
||||
var hourInput = document.createElement("input");
|
||||
hourInput.type = "number";
|
||||
hourInput.min = 0;
|
||||
hourInput.max = 23;
|
||||
hourCell.appendChild(hourInput);
|
||||
contentRow.appendChild(hourCell);
|
||||
|
||||
// Spalte "Minute"
|
||||
var minuteCell = document.createElement("td");
|
||||
var minuteSelect = document.createElement("select");
|
||||
for (var minute = 0; minute <= 50; minute += 10) {
|
||||
var option = document.createElement("option");
|
||||
option.value = minute;
|
||||
option.text = minute.toString().padStart(2, "0");
|
||||
minuteSelect.appendChild(option);
|
||||
// Headerzeile
|
||||
var headerRow = document.createElement("tr");
|
||||
var headers = ["Stunde", "Minute", "ch1", "ch2", "ch3", "ch4"];
|
||||
for (var i = 0; i < headers.length; i++) {
|
||||
var header = document.createElement("th");
|
||||
header.innerHTML = headers[i];
|
||||
headerRow.appendChild(header);
|
||||
}
|
||||
minuteCell.appendChild(minuteSelect);
|
||||
contentRow.appendChild(minuteCell);
|
||||
table.appendChild(headerRow);
|
||||
|
||||
// Spalten "ch1" bis "ch4"
|
||||
for (var channel = 1; channel <= 4; channel++) {
|
||||
var channelCell = document.createElement("td");
|
||||
var channelInput = document.createElement("input");
|
||||
channelInput.type = "number";
|
||||
channelInput.min = 0;
|
||||
channelInput.max = 100;
|
||||
channelCell.appendChild(channelInput);
|
||||
contentRow.appendChild(channelCell);
|
||||
// Inhaltszeilen
|
||||
for (var row = 0; row < 10; row++) {
|
||||
var contentRow = document.createElement("tr");
|
||||
|
||||
// Spalte "Stunde"
|
||||
var hourCell = document.createElement("td");
|
||||
var hourInput = document.createElement("input");
|
||||
hourInput.type = "number";
|
||||
hourInput.min = 0;
|
||||
hourInput.max = 23;
|
||||
hourCell.appendChild(hourInput);
|
||||
contentRow.appendChild(hourCell);
|
||||
|
||||
// Spalte "Minute"
|
||||
var minuteCell = document.createElement("td");
|
||||
var minuteSelect = document.createElement("select");
|
||||
for (var minute = 0; minute <= 50; minute += 10) {
|
||||
var option = document.createElement("option");
|
||||
option.value = minute;
|
||||
option.text = minute.toString().padStart(2, "0");
|
||||
minuteSelect.appendChild(option);
|
||||
}
|
||||
minuteCell.appendChild(minuteSelect);
|
||||
contentRow.appendChild(minuteCell);
|
||||
|
||||
// Spalten "ch1" bis "ch4"
|
||||
for (var channel = 1; channel <= 4; channel++) {
|
||||
var channelCell = document.createElement("td");
|
||||
var channelInput = document.createElement("input");
|
||||
channelInput.type = "number";
|
||||
channelInput.min = 0;
|
||||
channelInput.max = 100;
|
||||
channelCell.appendChild(channelInput);
|
||||
contentRow.appendChild(channelCell);
|
||||
}
|
||||
|
||||
table.appendChild(contentRow);
|
||||
}
|
||||
|
||||
table.appendChild(contentRow);
|
||||
}
|
||||
// Button
|
||||
var button = document.createElement("button");
|
||||
button.innerHTML = "Save";
|
||||
button.classList.add("pure-button");
|
||||
button.classList.add("pure-button-primary");
|
||||
button.onclick = function() {
|
||||
var data = [];
|
||||
|
||||
// Button
|
||||
var button = document.createElement("button");
|
||||
button.innerHTML = "Save";
|
||||
button.classList.add("pure-button");
|
||||
button.classList.add("pure-button-primary");
|
||||
button.onclick = function() {
|
||||
var data = [];
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
for (var row = 1; row < rows.length; row++) {
|
||||
var cells = rows[row].getElementsByTagName("td");
|
||||
|
||||
var rows = table.getElementsByTagName("tr");
|
||||
for (var row = 1; row < rows.length; row++) {
|
||||
var cells = rows[row].getElementsByTagName("td");
|
||||
var hour = cells[0].querySelector("input").value;
|
||||
var minute = cells[1].querySelector("select").value;
|
||||
var ch1 = cells[2].querySelector("input").value;
|
||||
var ch2 = cells[3].querySelector("input").value;
|
||||
var ch3 = cells[4].querySelector("input").value;
|
||||
var ch4 = cells[5].querySelector("input").value;
|
||||
|
||||
var hour = cells[0].querySelector("input").value;
|
||||
var minute = cells[1].querySelector("select").value;
|
||||
var ch1 = cells[2].querySelector("input").value;
|
||||
var ch2 = cells[3].querySelector("input").value;
|
||||
var ch3 = cells[4].querySelector("input").value;
|
||||
var ch4 = cells[5].querySelector("input").value;
|
||||
var rowObject = {"hour": hour, "min": minute, "ch1": ch1, "ch2": ch2, "ch3": ch3, "ch4": ch4};
|
||||
data.push(rowObject);
|
||||
}
|
||||
|
||||
var rowObject = {"hour": hour, "min": minute, "ch1": ch1, "ch2": ch2, "ch3": ch3, "ch4": ch4};
|
||||
data.push(rowObject);
|
||||
}
|
||||
var json = JSON.stringify(data);
|
||||
console.log(json);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://{{IP_ADDRESS}}/tc_data_save?data=" + encodeURIComponent(json), true);
|
||||
xhr.send();
|
||||
|
||||
var json = JSON.stringify(data);
|
||||
console.log(json);
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "http://{{IP_ADDRESS}}/tc_data_save?data=" + encodeURIComponent(json), true);
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
var container = document.getElementById("table-container");
|
||||
container.innerHTML = "";
|
||||
container.classList.add("pure-form");
|
||||
container.appendChild(table);
|
||||
container.appendChild(button);
|
||||
var container = document.getElementById("table-container");
|
||||
container.innerHTML = "";
|
||||
container.classList.add("pure-form");
|
||||
container.appendChild(table);
|
||||
container.appendChild(button);
|
||||
}
|
Loading…
Reference in a new issue