Repository navigation
Expand file tree
/
Copy pathrote_db.html
More file actions
185 lines (179 loc) · 6.31 KB
/
Copy pathrote_db.html
File metadata and controls
185 lines (179 loc) · 6.31 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rote Search</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
border-collapse: collapse;
margin: 25px 0;
font-size: 0.9em;
font-family: sans-serif;
/*table-layout: fixed;*/
width: 100%;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
}
tbody {
width: 100%;
/*overflow: auto;*/
height: 1000px;
}
thead tr {
background-color: #0076e4;
color: #ffffff;
text-align: left;
width: auto;
}
th {
position: -webkit-sticky;
position: sticky;
}
th, td {
padding: 12px 15px;
width: auto;
}
th:first-child {
width: 100px;
}
th:last-child {
width: 100%;
}
td:first-child {
width: 100px;
}
td:last-child {
width: 100%;
}
/*
.rote-name th td {
max-width: 100px;
}
.sphere th td {
max-width: 10px;
}
.rote-desc th td {
max-width: 100%;
}
*/
tbody tr {
border-bottom: 1px solid #dddddd;
}
tbody tr:nth-of-type(even) {
background-color: #f3f3f3;
}
tbody tr:last-of-type {
border-bottom: 2px solid #0076e4;
}
tbody tr.active-row {
font-weight: bold;
color: #0076e4;
}
input, button {
padding: 8px;
}
</style>
</head>
<body>
<h2>Filters</h2>
<form id="filterForm">
<!-- <input type="text" placeholder="Rote" name="rote"> -->
C <input type="text" placeholder="Correspondence" name="Correspondence">
E <input type="text" placeholder="Entropy" name="Entropy">
F <input type="text" placeholder="Forces" name="Forces">
L <input type="text" placeholder="Life" name="Life">
Ma <input type="text" placeholder="Matter" name="Matter">
Mi <input type="text" placeholder="Mind" name="Mind">
P <input type="text" placeholder="Prime" name="Prime">
S <input type="text" placeholder="Spirit" name="Spirit">
T <input type="text" placeholder="Time" name="Time">
<!-- Add other fields as necessary -->
<button type="button" id="filterButton">Apply Filter</button>
<button type="button" id="clearButton">Clear Filter</button>
<button type="button" id="zeroOut">Zero Out</button>
</form>
<h2>Rote Table</h2>
<table>
<thead>
<tr>
<th class="rote-name">Rote</th>
<th class="sphere">C</th>
<th class="sphere">E</th>
<th class="sphere">F</th>
<th class="sphere">L</th>
<th class="sphere">Ma</th>
<th class="sphere">Mi</th>
<th class="sphere">P</th>
<th class="sphere">S</th>
<th class="sphere">T</th>
<th class="rote-desc">Description</th>
</tr>
</thead>
<tbody id="dataTable">
<!-- Data rows will go here -->
</tbody>
</table>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
function populateTable(data) {
const tableBody = $('#dataTable');
tableBody.empty(); // Clear previous rows
data.forEach(item => {
let row = `<tr>`;
row += `<td class="rote-name">${item.rote || ''}</td>`;
row += `<td class="sphere">${item.Correspondence || 0}</td>`;
row += `<td class="sphere">${item.Entropy || 0}</td>`;
row += `<td class="sphere">${item.Forces || 0}</td>`;
row += `<td class="sphere">${item.Life || 0}</td>`;
row += `<td class="sphere">${item.Matter || 0}</td>`;
row += `<td class="sphere">${item.Mind || 0}</td>`;
row += `<td class="sphere">${item.Prime || 0}</td>`;
row += `<td class="sphere">${item.Spirit || 0}</td>`;
row += `<td class="sphere">${item.Time || 0}</td>`;
row += `<td class="rote-desc">${item.description || ''}</td>`;
row += `</tr>`;
tableBody.append(row);
});
}
// This needs to be fixed to allow searching with rote name and description
function filterTable() {
const formValues = {};
$('#filterForm').serializeArray().forEach(input => {
if (input.value !== "") {
formValues[input.name] = parseInt(input.value.toLowerCase());
}
});
console.log(formValues);
const filteredData = jsonData.filter(item => {
return Object.entries(formValues).every(([key, value]) =>
key in item && (parseInt(item[key].toString().toLowerCase()) <= value));
});
populateTable(filteredData);
}
var jsonData;
fetch('rotes.json')
.then(res => res.json())
.then(data => {
jsonData = data;
})
.then(() => {
populateTable(jsonData); // Initial population of the table
});
$("#filterButton").click(filterTable);
$("#clearButton").click(function (e) {
e.preventDefault();
$("#filterForm")[0].reset();
populateTable(jsonData);
});
$("#zeroOut").click(function (e) {
e.preventDefault();
$(':input').val(0);
});
});
</script>
</body>
</html>