-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.html
More file actions
134 lines (113 loc) · 4.04 KB
/
editor.html
File metadata and controls
134 lines (113 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>FrequencyFilterContentEditor</title>
<script type="application/javascript">
/**
dont delete! used for initialization.
**/
function init() {
window.data = getData();
setDataGetter(dataGetter)
}
</script>
</head>
<body>
<!-- EDIT Form for User Input -->
<div>
<label for="titleInput">Enter Title:</label>
<input id="titleInput" type="text" />
<div>
<label for="description">Enter Description:</label>
<textarea id="description"></textarea>
</div>
Füge Punkte hinzu:
<table id="content">
<tr>
<th>Frequenz</th>
<th>von</th>
<th>bis</th>
</tr>
</table>
<button id="addRow" class="btn btn-primary" type="button">Add Row</button>
<button id="removeRow" class="btn btn-primary" type="button">Remove Row</button>
</div>
<!-- EDIT Form for User Input -->
<!-- EDIT Form logic -->
<script type="application/javascript">
var table = document.getElementById("content");
for (var i = 0; i < 3; i++) {
insertRow();
}
function insertRow() {
var row = table.insertRow(table.rows.length);
var cell1 = row.insertCell(0);
cell1.innerHTML = "<input>Hz";
var cell2 = row.insertCell(1);
cell2.innerHTML = "<input>db";
var cell3 = row.insertCell(2);
cell3.innerHTML = "<input>db";
}
// Rows for data
var addRowButton = document.getElementById("addRow");
addRowButton.onclick = function () {
insertRow();
}
var removeRowButton = document.getElementById("removeRow");
removeRowButton.onclick = function () {
if (table.rows.length > 4) {
table.deleteRow(table.rows.length - 1);
}
}
function dataGetter() {
var tableContent = [];
// Content from input elements
for (var i = 1; i < table.rows.length; i++) {
var row = []
for (var j = 0; j < table.rows[i].cells.length; j++) {
row.push(table.rows[i].cells[j].firstChild.value);
}
tableContent.push(row);
}
return {
// return data object
lastEdit: Date.now(),
title: document.getElementById('titleInput').value,
description: document.getElementById('description').value,
tableContent: tableContent
}
}
/**
function init() -> dont delete! used for initialization.
**/
init();
document.getElementById('titleInput').value = window.data.title;
document.getElementById('description').value = window.data.description;
window.data.tableContent.forEach(function (item, i) {
var row;
if (table.rows[i + 1] !== undefined) {
row = table.rows[i + 1];
row.cells[0].firstChild.value = item[0];
row.cells[1].firstChild.value = item[1];
row.cells[2].firstChild.value = item[2];
} else {
row = table.insertRow(table.rows.length);
var cell1 = row.insertCell(0);
var input1 = document.createElement("input");
input1.value = item[0];
cell1.appendChild(input1);
var cell2 = row.insertCell(1);
var input2 = document.createElement("input");
input2.value = item[1];
cell2.appendChild(input2);
var cell3 = row.insertCell(2);
var input3 = document.createElement("input");
input3.value = item[2];
cell3.appendChild(input3);
}
});
</script>
<!-- EDIT Form logic -->
</body>
</html>