added selected tags after hash in url

This commit is contained in:
2025-06-25 22:37:42 +02:00
parent 85467f4f1e
commit 0cda1706fa
2 changed files with 26 additions and 5 deletions

View File

@@ -1 +1 @@
2.7.3
2.7.4

View File

@@ -167,6 +167,7 @@
];
var shown = [];
var re = /pid=(\d+)/;
var filterre = /#(.*)/;
var controllers = {}
function openSwipe(img) {
@@ -228,6 +229,7 @@
}
function filter() {
window.location.href = window.location.href.split("#")[0] + "#"
var selected_tags = [];
var tagdropdown, tags, incl;
shown = [];
@@ -237,6 +239,7 @@
selected_tags.push([tagdropdown[i].innerText])
}
}
var urltags = selected_tags.join(",");
items.forEach((item, index) => {
tags = item.tags;
incl = true;
@@ -250,10 +253,26 @@
}
});
updateImageList();
window.location.href += urltags
}
function setFilter(selected) {
tagdropdown = document.getElementById("tagdropdown").getElementsByTagName("li");
selected.forEach((tag) => {
for (var i = 0; i < tagdropdown.length; i++) {
if (tagdropdown[i].innerText == tag) {
tagdropdown[i].firstChild.firstChild.checked = true;
}
}
});
}
function onLoad() {
{%- if tags|length > 0 %}
{%- if tags | length > 0 %}
if (filterre.test(window.location.href)) {
var selected = window.location.href.match(filterre)[1].split(",");
setFilter(selected);
}
filter();
{%- else %}
shown = items;
@@ -266,7 +285,9 @@
}
}
window.onload = function () { onLoad() };
window.addEventListener ?
window.addEventListener("load", onLoad, false) :
window.attachEvent && window.attachEvent("onload", onLoad);
</script>
{%- endif %}