16
HTML & templates / Re: Custom folder previews
« on: September 14, 2021, 04:48:30 PM »
Okay, variant with images behind buttons:
Code: [Select]
[+]
<script>
var list=document.querySelectorAll("table#files>tbody>tr");
function changepic(a1)
{
var alink=a1.querySelector("a");
var adress=alink.getAttribute("href");
if(adress.endsWith("/"))
{
adress+="p.jpg";
var button=document.createElement("button");
button.setAttribute("onclick","showPreview(this)");
button.setAttribute("link",adress);
button.setAttribute("type","button");
a1.children[3].setAttribute("style","text-align:center");
a1.children[3].appendChild(button);
button.appendChild(document.createTextNode("Preview"));
}
}
list.forEach(changepic);
function showPreview(butt)
{
butt.setAttribute("style","display:none");
var par=butt.parentElement;
var img=document.createElement("img");
img.setAttribute("src",butt.getAttribute("link"));
par.appendChild(img);
}
</script>