-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
118 lines (110 loc) · 2.79 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Importieren und Anklicken von Tabelleneinträgen</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
input[type="text"] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
background-color: #f8f8f8;
font-size: 16px;
}
</style>
</head>
<body>
<p>Kopieren Sie die Daten in das untenstehende Feld:</p>
<input type="text" id="data" placeholder="Geben Sie hier Ihre Daten ein">
<table id="table">
<thead>
<tr>
<th>Monats-Mail</th>
<th>2. Mail</th>
<th>1 Woche vorh!</th>
<th>PLZ</th>
<th>Ort</th>
<th>GM-Anzahl</th>
<th>FH</th>
<th>b.S.</th>
<th>Prüfdatum 2022</th>
<th>Prüfdatum 2023</th>
<th>Anmerkungen</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
var dataKey = "tableData";
var tableBody = document.getElementById("table").getElementsByTagName("tbody")[0];
var tableData = JSON.parse(localStorage.getItem(dataKey));
if (tableData) {
for (var i = 0; i < tableData.length; i++) {
var row = document.createElement("tr");
for (var j = 0; j < tableData[i].length; j++) {
var cell = document.createElement("td");
cell.contentEditable = true;
var text = document.createTextNode(tableData[i][j]);
cell.appendChild(text);
row.appendChild(cell);
}
row.addEventListener("click", function() {
var cells = this.getElementsByTagName("td");
for (var k = 0; k < cells.length; k++) {
cells[k].contentEditable = true;
}
});
tableBody.appendChild(row);
}
}
document.getElementById("data").addEventListener("input", function() {
var data = this.value.trim();
if (data) {
var items = data.split('\n');
tableData = [];
tableBody.innerHTML = "";
for (var i = 0; i < items.length; i++) {
var fields = items[i].split('\t');
var row = document.createElement("tr");
var rowData = [];
for (var j = 0; j < fields.length; j++) {
var cell = document.createElement("td");
cell.contentEditable = true;
var text = document.createTextNode(fields[j]);
cell.appendChild(text);
row.appendChild(cell);
rowData.push(fields[j]);
}
row.addEventListener("click", function() {
var cells = this.getElementsByTagName("td");
for (var k = 0; k < cells.length; k++) {
cells[k].contentEditable = true;
}
});
tableBody.appendChild(row);
tableData.push(rowData);
}
localStorage.setItem(dataKey, JSON.stringify(tableData));
}
});
</script>
</body>
</html>