Removed the select boxes from the timing control editor and replaced them by sliders.
This commit is contained in:
parent
a6ac0be517
commit
9844d9fca8
2 changed files with 71 additions and 39 deletions
|
@ -409,8 +409,7 @@ tdMinute.id = "minute" + i;
|
||||||
tr.appendChild(tdMinute);
|
tr.appendChild(tdMinute);
|
||||||
for (var j = 1; j <=4; j++)
|
for (var j = 1; j <=4; j++)
|
||||||
{
|
{
|
||||||
var tdCh = createSelectCell(100, 0, 1);
|
var tdCh = createSlider("ch" + j + "_" + i, 100, 0, 1);
|
||||||
tdCh.id = "ch" + j + "_" + i;
|
|
||||||
tr.appendChild(tdCh);
|
tr.appendChild(tdCh);
|
||||||
}
|
}
|
||||||
table.appendChild(tr);
|
table.appendChild(tr);
|
||||||
|
@ -428,13 +427,23 @@ input.max = max;
|
||||||
input.step = step;
|
input.step = step;
|
||||||
input.value = value;
|
input.value = value;
|
||||||
input.classList.add("pure-slider-range");
|
input.classList.add("pure-slider-range");
|
||||||
var div = document.createElement("div");
|
if (id.startsWith("ch1_")) {
|
||||||
div.classList.add("pure-control-group");
|
input.style.backgroundColor = "blue";
|
||||||
|
} else if (id.startsWith("ch2_")) {
|
||||||
|
input.style.backgroundColor = "orange";
|
||||||
|
} else if (id.startsWith("ch3_")) {
|
||||||
|
input.style.backgroundColor = "green";
|
||||||
|
} else if (id.startsWith("ch4_")) {
|
||||||
|
input.style.backgroundColor = "red";
|
||||||
|
}
|
||||||
|
div = document.createElement("div");
|
||||||
div.appendChild(input);
|
div.appendChild(input);
|
||||||
var label = document.createElement("label");
|
var span = document.createElement("span");
|
||||||
label.innerHTML = id;
|
span.innerHTML = " " + value + " %";
|
||||||
label.classList.add("pure-slider-label");
|
div.appendChild(span);
|
||||||
div.insertBefore(label, input);
|
input.oninput = function() {
|
||||||
|
span.innerHTML = " " + this.value + " %";
|
||||||
|
};
|
||||||
var td = document.createElement("td");
|
var td = document.createElement("td");
|
||||||
td.id = id;
|
td.id = id;
|
||||||
td.appendChild(div);
|
td.appendChild(div);
|
||||||
|
@ -462,10 +471,14 @@ for (var i = 0; i < tcdata.length; i++) {
|
||||||
var row = document.getElementById("hour" + (i+1)).parentNode;
|
var row = document.getElementById("hour" + (i+1)).parentNode;
|
||||||
row.cells[0].childNodes[0].value = tcdata[i].hour;
|
row.cells[0].childNodes[0].value = tcdata[i].hour;
|
||||||
row.cells[1].childNodes[0].value = tcdata[i].min;
|
row.cells[1].childNodes[0].value = tcdata[i].min;
|
||||||
row.cells[2].childNodes[0].value = parseInt(Math.round(tcdata[i].ch1 * 100 / 255));
|
row.cells[2].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch1 * 100 / 255));
|
||||||
row.cells[3].childNodes[0].value = parseInt(Math.round(tcdata[i].ch2 * 100 / 255));
|
row.cells[2].childNodes[0].childNodes[1].innerHTML = " " + row.cells[2].childNodes[0].childNodes[0].value + " %";
|
||||||
row.cells[4].childNodes[0].value = parseInt(Math.round(tcdata[i].ch3 * 100 / 255));
|
row.cells[3].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch2 * 100 / 255));
|
||||||
row.cells[5].childNodes[0].value = parseInt(Math.round(tcdata[i].ch4 * 100 / 255));
|
row.cells[3].childNodes[0].childNodes[1].innerHTML = " " + row.cells[3].childNodes[0].childNodes[0].value + " %";
|
||||||
|
row.cells[4].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch3 * 100 / 255));
|
||||||
|
row.cells[4].childNodes[0].childNodes[1].innerHTML = " " + row.cells[4].childNodes[0].childNodes[0].value + " %";
|
||||||
|
row.cells[5].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch4 * 100 / 255));
|
||||||
|
row.cells[5].childNodes[0].childNodes[1].innerHTML = " " + row.cells[5].childNodes[0].childNodes[0].value + " %";
|
||||||
}
|
}
|
||||||
loadTCGraphData();
|
loadTCGraphData();
|
||||||
});
|
});
|
||||||
|
@ -479,10 +492,10 @@ var row = document.getElementById("hour" + i).parentNode;
|
||||||
var hour = parseInt(row.cells[0].childNodes[0].value);
|
var hour = parseInt(row.cells[0].childNodes[0].value);
|
||||||
var min = parseInt(row.cells[1].childNodes[0].value);
|
var min = parseInt(row.cells[1].childNodes[0].value);
|
||||||
timeArr.push(hour * 60 + min);
|
timeArr.push(hour * 60 + min);
|
||||||
var ch1 = Math.round(parseInt(row.cells[2].childNodes[0].value) * 2.55);
|
var ch1 = Math.round(parseInt(row.cells[2].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch2 = Math.round(parseInt(row.cells[3].childNodes[0].value) * 2.55);
|
var ch2 = Math.round(parseInt(row.cells[3].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch3 = Math.round(parseInt(row.cells[4].childNodes[0].value) * 2.55);
|
var ch3 = Math.round(parseInt(row.cells[4].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch4 = Math.round(parseInt(row.cells[5].childNodes[0].value) * 2.55);
|
var ch4 = Math.round(parseInt(row.cells[5].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
tcdata.push({hour: hour, min: min, ch1: ch1, ch2: ch2, ch3: ch3, ch4: ch4});
|
tcdata.push({hour: hour, min: min, ch1: ch1, ch2: ch2, ch3: ch3, ch4: ch4});
|
||||||
}
|
}
|
||||||
for (var i = 0; i < timeArr.length - 1; i++) {
|
for (var i = 0; i < timeArr.length - 1; i++) {
|
||||||
|
|
|
@ -486,8 +486,7 @@ function createTable() {
|
||||||
for (var j = 1; j <=4; j++)
|
for (var j = 1; j <=4; j++)
|
||||||
{
|
{
|
||||||
// chj_i
|
// chj_i
|
||||||
var tdCh = createSelectCell(100, 0, 1);
|
var tdCh = createSlider("ch" + j + "_" + i, 100, 0, 1);
|
||||||
tdCh.id = "ch" + j + "_" + i;
|
|
||||||
tr.appendChild(tdCh);
|
tr.appendChild(tdCh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,26 +508,38 @@ function createSlider(id, max, value, step) {
|
||||||
input.step = step;
|
input.step = step;
|
||||||
input.value = value;
|
input.value = value;
|
||||||
input.classList.add("pure-slider-range");
|
input.classList.add("pure-slider-range");
|
||||||
|
// Change the color of the slider based on the id
|
||||||
// Create a new div element to contain the input element
|
if (id.startsWith("ch1_")) {
|
||||||
var div = document.createElement("div");
|
input.style.backgroundColor = "blue";
|
||||||
div.classList.add("pure-control-group");
|
} else if (id.startsWith("ch2_")) {
|
||||||
|
input.style.backgroundColor = "orange";
|
||||||
|
} else if (id.startsWith("ch3_")) {
|
||||||
|
input.style.backgroundColor = "green";
|
||||||
|
} else if (id.startsWith("ch4_")) {
|
||||||
|
input.style.backgroundColor = "red";
|
||||||
|
}
|
||||||
|
|
||||||
|
div = document.createElement("div");
|
||||||
div.appendChild(input);
|
div.appendChild(input);
|
||||||
|
|
||||||
// Create a new label element for the slider
|
// Create a new span element to contain the value of the slider
|
||||||
var label = document.createElement("label");
|
var span = document.createElement("span");
|
||||||
label.innerHTML = id;
|
span.innerHTML = " " + value + " %";
|
||||||
label.classList.add("pure-slider-label");
|
div.appendChild(span);
|
||||||
div.insertBefore(label, input);
|
|
||||||
|
// Update the span element when the value of the slider changes
|
||||||
|
input.oninput = function() {
|
||||||
|
span.innerHTML = " " + this.value + " %";
|
||||||
|
};
|
||||||
|
|
||||||
// Create a new td element to contain the div element
|
// Create a new td element to contain the div element
|
||||||
var td = document.createElement("td");
|
var td = document.createElement("td");
|
||||||
td.id = id;
|
td.id = id;
|
||||||
td.appendChild(div);
|
td.appendChild(div);
|
||||||
|
|
||||||
// Return the td element
|
// Return the td element
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSelectCell(max, value, step) {
|
function createSelectCell(max, value, step) {
|
||||||
// Erstelle ein neues select-Element
|
// Erstelle ein neues select-Element
|
||||||
|
@ -564,10 +575,18 @@ function fillTableFromJson() {
|
||||||
var row = document.getElementById("hour" + (i+1)).parentNode;
|
var row = document.getElementById("hour" + (i+1)).parentNode;
|
||||||
row.cells[0].childNodes[0].value = tcdata[i].hour;
|
row.cells[0].childNodes[0].value = tcdata[i].hour;
|
||||||
row.cells[1].childNodes[0].value = tcdata[i].min;
|
row.cells[1].childNodes[0].value = tcdata[i].min;
|
||||||
row.cells[2].childNodes[0].value = parseInt(Math.round(tcdata[i].ch1 * 100 / 255));
|
|
||||||
row.cells[3].childNodes[0].value = parseInt(Math.round(tcdata[i].ch2 * 100 / 255));
|
row.cells[2].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch1 * 100 / 255));
|
||||||
row.cells[4].childNodes[0].value = parseInt(Math.round(tcdata[i].ch3 * 100 / 255));
|
row.cells[2].childNodes[0].childNodes[1].innerHTML = " " + row.cells[2].childNodes[0].childNodes[0].value + " %";
|
||||||
row.cells[5].childNodes[0].value = parseInt(Math.round(tcdata[i].ch4 * 100 / 255));
|
|
||||||
|
row.cells[3].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch2 * 100 / 255));
|
||||||
|
row.cells[3].childNodes[0].childNodes[1].innerHTML = " " + row.cells[3].childNodes[0].childNodes[0].value + " %";
|
||||||
|
|
||||||
|
row.cells[4].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch3 * 100 / 255));
|
||||||
|
row.cells[4].childNodes[0].childNodes[1].innerHTML = " " + row.cells[4].childNodes[0].childNodes[0].value + " %";
|
||||||
|
|
||||||
|
row.cells[5].childNodes[0].childNodes[0].value = parseInt(Math.round(tcdata[i].ch4 * 100 / 255));
|
||||||
|
row.cells[5].childNodes[0].childNodes[1].innerHTML = " " + row.cells[5].childNodes[0].childNodes[0].value + " %";
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTCGraphData();
|
loadTCGraphData();
|
||||||
|
@ -585,10 +604,10 @@ function createJsonFromTable() {
|
||||||
var hour = parseInt(row.cells[0].childNodes[0].value);
|
var hour = parseInt(row.cells[0].childNodes[0].value);
|
||||||
var min = parseInt(row.cells[1].childNodes[0].value);
|
var min = parseInt(row.cells[1].childNodes[0].value);
|
||||||
timeArr.push(hour * 60 + min); // Speichert die Zeitangaben als Minuten seit Mitternacht
|
timeArr.push(hour * 60 + min); // Speichert die Zeitangaben als Minuten seit Mitternacht
|
||||||
var ch1 = Math.round(parseInt(row.cells[2].childNodes[0].value) * 2.55);
|
var ch1 = Math.round(parseInt(row.cells[2].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch2 = Math.round(parseInt(row.cells[3].childNodes[0].value) * 2.55);
|
var ch2 = Math.round(parseInt(row.cells[3].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch3 = Math.round(parseInt(row.cells[4].childNodes[0].value) * 2.55);
|
var ch3 = Math.round(parseInt(row.cells[4].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
var ch4 = Math.round(parseInt(row.cells[5].childNodes[0].value) * 2.55);
|
var ch4 = Math.round(parseInt(row.cells[5].childNodes[0].childNodes[0].value) * 2.55);
|
||||||
tcdata.push({hour: hour, min: min, ch1: ch1, ch2: ch2, ch3: ch3, ch4: ch4});
|
tcdata.push({hour: hour, min: min, ch1: ch1, ch2: ch2, ch3: ch3, ch4: ch4});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue