mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 11:09:26 +00:00
added selected tags after hash in url
This commit is contained in:
@@ -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) {
|
||||||
@@ -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;
|
||||||
@@ -266,7 +285,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () { onLoad() };
|
window.addEventListener ?
|
||||||
|
window.addEventListener("load", onLoad, false) :
|
||||||
|
window.attachEvent && window.attachEvent("onload", onLoad);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user