add visibility menu

This commit is contained in:
iou1name 2022-08-17 21:19:14 -04:00
parent 8385103796
commit 8ad34cc221
4 changed files with 69 additions and 0 deletions

View File

@ -14,6 +14,10 @@ body {
opacity: 0.33; opacity: 0.33;
} }
.hidden {
display: none;
}
.tag { .tag {
font-size: 0.8em; font-size: 0.8em;
} }
@ -65,3 +69,13 @@ body {
.deadlink { .deadlink {
text-decoration: line-through; text-decoration: line-through;
} }
#visibility_menu_toggle {
cursor: pointer
}
#visibility_menu {
border: 1px solid darkgray;
position: absolute;
background-color: #FAFAFA;
}

View File

@ -46,3 +46,35 @@ function remove_tag(event) {
tag.remove(); tag.remove();
}); });
} }
function toggle_visibility_menu(event) {
let menu = document.querySelector('#visibility_menu');
if (menu.style.display == 'block') {
menu.style.display = 'none';
} else if (menu.style.display == 'none') {
menu.style.display = 'block';
}
}
function toggle_visibility(event) {
console.log(event);
let tag = event.target.parentElement.parentElement.cells[0].innerText;
let vis_class = ['faded', 'hidden'];
if (tag == 'non-qm posts') {
for (let post of document.querySelectorAll('.post_container:not(.qm_post)')) {
if (event.target.checked) {
post.classList.add(vis_class[event.target.parentElement.cellIndex - 1]);
} else {
post.classList.remove(vis_class[event.target.parentElement.cellIndex - 1]);
}
}
} else {
for (let post of document.querySelectorAll('.' + tag)) {
if (event.target.checked) {
post.classList.add(vis_class[event.target.parentElement.cellIndex - 1]);
} else {
post.classList.remove(vis_class[event.target.parentElement.cellIndex - 1]);
}
}
}
}

View File

@ -11,6 +11,28 @@
<body> <body>
<header> <header>
<h1>Voyage</h1> <h1>Voyage</h1>
<span id="visibility_menu_toggle" onclick="toggle_visibility_menu(event)">Visibility</span>
<div id="visibility_menu" style="display: none;">
<table>
<thead>
<tr>
<th>Tag</th>
<th>Faded</th>
<th>Hidden</th>
</tr>
</thead>
<tbody>
<tr>
<td>non-qm posts</td><td><input type="checkbox" onchange="toggle_visibility(event)" checked></td><td><input type="checkbox" onchange="toggle_visibility(event)"></td>
</tr>
{% for tag in tags_vis %}
<tr>
<td>{{ tag }}</td><td><input type="checkbox" onchange="toggle_visibility(event)"></td><td><input type="checkbox" onchange="toggle_visibility(event)"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</header> </header>
<main> <main>
{% for post in posts %} {% for post in posts %}

View File

@ -46,6 +46,7 @@ async def thread(request):
tags = defaultdict(list) tags = defaultdict(list)
links = defaultdict(list) links = defaultdict(list)
backlinks = defaultdict(list) backlinks = defaultdict(list)
tags_vis = sorted(list(set(t[1] for t in tags_raw)))
for tag_raw in tags_raw: for tag_raw in tags_raw:
tag = tags[tag_raw['post_id']] tag = tags[tag_raw['post_id']]