Skip to content

Commit 6440765

Browse files
committed
html/template.html: use details element for fields
1 parent b5b24c6 commit 6440765

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/html/template.html

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
.headerlink {
3131
font-size: 50%;
3232
}
33-
.fields {
34-
display: none;
35-
}
3633
nav.menu {
3734
line-height: 2
3835
}
@@ -205,12 +202,12 @@ <h4>
205202
</tr>
206203
{% endif %}{% endfor %}
207204
</tbody></table>
208-
<a href="#" class="toggle-fields">Toggle Fields</a>
209205
</div>
210206
</div>
211207
</div>
212208
{% endif %}
213-
<div class="container fields" id="{{ pname }}-{{ register.name }}-fields">
209+
<details class="fields" id="{{ pname }}-{{ register.name }}-fields">
210+
<summary>Toggle fields</summary>
214211
{% for field in register.fields %}
215212
<div class="row">
216213
<div class="col-sm-10">
@@ -235,7 +232,7 @@ <h4>
235232
</div>
236233
</div>
237234
{% endfor %}
238-
</div>
235+
</details>
239236
</div>
240237
</div>
241238
{% endfor %}
@@ -257,27 +254,18 @@ <h4>
257254
document.querySelectorAll('.registers').forEach(el => el.open = false)
258255
e.preventDefault()
259256
})
260-
$('.fieldlink').click(function(e) {
261-
$(this).parents(".container").first().siblings(".fields").show();
262-
});
263-
$('.toggle-fields').click(function(e) {
264-
$(this).parents(".container").first().siblings(".fields").toggle();
265-
e.preventDefault();
266-
});
267-
if (window.location.hash?.includes(":")) {
268-
const hash = window.location.hash;
269-
const [peripheral, register, field] = hash.substr(1).split(":", 3)
270-
if (document.getElementById(`${peripheral}-registers`)) {
257+
function locationHashChanged() {
258+
const [peripheral, register, field] = window.location.hash.substr(1).split(":", 3)
259+
if (register && document.getElementById(`${peripheral}-registers`)) {
271260
document.getElementById(`${peripheral}-registers`).open = true
272261
}
273-
if(field) {
274-
$('#' + peripheral + '-' + register + '-fields').show(0, function() {
275-
window.location.hash = hash
276-
})
277-
} else {
278-
window.location.hash = hash
262+
if(field && document.getElementById(`${peripheral}-${register}-fields`)) {
263+
document.getElementById(`${peripheral}-${register}-fields`).open = true
279264
}
265+
window.location.hash = window.location.hash
280266
}
267+
window.addEventListener("hashchange", locationHashChanged)
268+
locationHashChanged()
281269
$(function () {
282270
$('[data-toggle="popover"]').popover()
283271
})

0 commit comments

Comments
 (0)