|
|
|
const set_image_expand = (x, set) => {
|
|
|
|
const matches = /i\/(thumb\/)?(\d+\.\w+)$/i.exec(x.getAttribute("src"));
|
|
|
|
|
|
|
|
if(matches[1])
|
|
|
|
{
|
|
|
|
//Is thumbnail
|
|
|
|
if(set===true || set===undefined)
|
|
|
|
x.setAttribute("src", "i/"+matches[2]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Is full
|
|
|
|
if(set===false || set===undefined)
|
|
|
|
x.setAttribute("src", "i/thumb/"+matches[2]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('load', () => {
|
|
|
|
document.querySelectorAll(".thread").forEach(x=> x.classList.toggle("hidden"));
|
|
|
|
document.querySelectorAll(".script").forEach(x=> x.style=""); //unhide script-specific elements
|
|
|
|
|
|
|
|
document.querySelectorAll(".expand").forEach(x=> {
|
|
|
|
x.addEventListener("click", ()=> {
|
|
|
|
document.querySelector("[id='"+ x.getAttribute("href").slice(1) +"']").classList.toggle("hidden");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
document.querySelectorAll("figure > img").forEach(x=> {
|
|
|
|
x.addEventListener("click", ()=> {
|
|
|
|
set_image_expand(x);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//nav buttons
|
|
|
|
document.querySelector("#expand_all_threads").addEventListener("click", () => {
|
|
|
|
document.querySelectorAll("section.hidden").forEach(x=> {
|
|
|
|
x.classList.toggle("hidden");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.querySelector("#collapse_all_threads").addEventListener("click", () => {
|
|
|
|
document.querySelectorAll("section:not(.hidden)").forEach(x=> {
|
|
|
|
x.classList.toggle("hidden");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.querySelector("#expand_all_images").addEventListener("click", () => {
|
|
|
|
document.querySelectorAll("figure > img").forEach(x=> {
|
|
|
|
set_image_expand(x, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.querySelector("#collapse_all_images").addEventListener("click", () => {
|
|
|
|
document.querySelectorAll("figure > img").forEach(x=> {
|
|
|
|
set_image_expand(x, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|