Skip to content

Commit b30bc7a

Browse files
committed
Add hide offline toggle
1 parent 244ba92 commit b30bc7a

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

templates/cams.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
}
88
</style>
99
<main class="container">
10-
<h1>Surfcams</h1>
10+
<div style="display: flex; align-items: center; justify-content: space-between;">
11+
<h1>Surfcams</h1>
12+
<label style="display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; user-select: none;">
13+
<input type="checkbox" id="hide-offline" onchange="toggleOffline(this.checked)">
14+
Hide offline
15+
</label>
16+
</div>
1117
{% for category in categories %}
1218
<h3 style="color: {{ category.color }}; margin-bottom: 0.5rem;">{{ category.title }}</h3>
1319
<div style="display: flex;
@@ -16,6 +22,7 @@ <h3 style="color: {{ category.color }}; margin-bottom: 0.5rem;">{{ category.titl
1622
margin-bottom: 1.5rem">
1723
{% for cam in category.cam_set.all %}
1824
<a class="cam-chip"
25+
{% if cam.offline_since %}data-offline{% endif %}
1926
style="display: block;
2027
padding: 0.5rem 0.8rem;
2128
border: 1px solid rgba(255,255,255,0.1);
@@ -37,4 +44,17 @@ <h3 style="color: {{ category.color }}; margin-bottom: 0.5rem;">{{ category.titl
3744
</div>
3845
{% endfor %}
3946
</main>
47+
<script>
48+
function toggleOffline(hide) {
49+
document.querySelectorAll('[data-offline]').forEach(el => {
50+
el.style.display = hide ? 'none' : 'block';
51+
});
52+
localStorage.setItem('hideOffline', hide);
53+
}
54+
// Restore preference
55+
if (localStorage.getItem('hideOffline') === 'true') {
56+
document.getElementById('hide-offline').checked = true;
57+
toggleOffline(true);
58+
}
59+
</script>
4060
{% endblock content %}

templates/fulldetail.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ <h2 style="margin-bottom: 20px;">
3434
{% endif %}
3535
<ul style=" overflow-x:scroll; white-space: nowrap; line-height: 60px;">
3636
{% for related_cam in related_cams %}
37-
<li style="list-style: none; display: inline;">
37+
<li {% if related_cam.offline_since %}data-offline{% endif %}
38+
style="list-style: none; display: inline;">
3839
<span style="color: {% if related_cam.offline_since %}#888{% else %}{{ related_cam.bullet_color }}{% endif %}"></span>
3940
<a style="color: {% if related_cam.offline_since %}#888{% else %}{{ related_cam.title_color }}{% endif %};
4041
margin: 20px 0px"
@@ -54,5 +55,10 @@ <h2 style="margin-bottom: 20px;">
5455
(function () {
5556
const video = new Video('{{ cam.proxy_url }}', 'javascript:history.back()').play();
5657
})();
58+
if (localStorage.getItem('hideOffline') === 'true') {
59+
document.querySelectorAll('[data-offline]').forEach(el => {
60+
el.style.display = 'none';
61+
});
62+
}
5763
</script>
5864
{% endblock content %}

0 commit comments

Comments
 (0)