forked from andyburke/autonomous.contact
refactor: rework the frontend to move topics to the top
This commit is contained in:
parent
fac8f409f4
commit
11ecd86bb9
14 changed files with 362 additions and 292 deletions
|
|
@ -1,37 +1,23 @@
|
|||
<script>
|
||||
function on_location_change() {
|
||||
const hash = window.location.hash?.slice(1);
|
||||
console.dir({ hash });
|
||||
if (hash) {
|
||||
const target_tab_url = hash.slice(0, hash.slice(1).indexOf("/") + 1);
|
||||
const target_tab = document.querySelector(`[data-hash="${target_tab_url}"]`);
|
||||
document.addEventListener("view_changed", ({ detail: { view } }) => {
|
||||
const target_tab = document.querySelector(`.tab-switch[data-view="${view}"]`);
|
||||
|
||||
console.dir({
|
||||
target_tab_url,
|
||||
target_tab,
|
||||
});
|
||||
|
||||
if (target_tab) {
|
||||
target_tab.click();
|
||||
}
|
||||
if (target_tab) {
|
||||
target_tab.click();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("locationchange", on_location_change);
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const tab_switchers = document.querySelectorAll(".tab-switch");
|
||||
for (const tab_switch of tab_switchers) {
|
||||
tab_switch.addEventListener("input", (event) => {
|
||||
const tab_selector = event.target;
|
||||
const hash = tab_selector.dataset.hash;
|
||||
if (hash) {
|
||||
window.location.hash = hash;
|
||||
const view = tab_selector.dataset.view;
|
||||
if (view) {
|
||||
window.location.hash = `/topic/${document.body.dataset.topic}/${view}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
on_location_change();
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue