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 shown = [];
var re = /pid=(\d+)/; var re = /pid=(\d+)/;
var filterre = /#(.*)/;
var controllers = {} var controllers = {}
function openSwipe(img) { function openSwipe(img) {
@@ -176,7 +177,7 @@
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, shown, options); var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, shown, options);
gallery.init(); gallery.init();
} }
let totopbutton = document.getElementById("totop"); let totopbutton = document.getElementById("totop");
window.onscroll = function () { scrollFunction() }; window.onscroll = function () { scrollFunction() };
@@ -228,6 +229,7 @@
} }
function filter() { function filter() {
window.location.href = window.location.href.split("#")[0] + "#"
var selected_tags = []; var selected_tags = [];
var tagdropdown, tags, incl; var tagdropdown, tags, incl;
shown = []; shown = [];
@@ -237,6 +239,7 @@
selected_tags.push([tagdropdown[i].innerText]) selected_tags.push([tagdropdown[i].innerText])
} }
} }
var urltags = selected_tags.join(",");
items.forEach((item, index) => { items.forEach((item, index) => {
tags = item.tags; tags = item.tags;
incl = true; incl = true;
@@ -250,10 +253,26 @@
} }
}); });
updateImageList(); 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() { 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(); filter();
{%- else %} {%- else %}
shown = items; shown = items;
@@ -265,8 +284,10 @@
openSwipe(parseInt(pid)); openSwipe(parseInt(pid));
} }
} }
window.onload = function () { onLoad() }; window.addEventListener ?
window.addEventListener("load", onLoad, false) :
window.attachEvent && window.attachEvent("onload", onLoad);
</script> </script>
{%- endif %} {%- endif %}