Update html/account-me.ejs
This commit is contained in:
parent
9aeeb9cfbc
commit
edf0a8d3d3
@ -379,24 +379,12 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" id="poke-subs" data-name="My Poke Subscriptions JS">
|
<script>
|
||||||
/*
|
|
||||||
@licstart
|
|
||||||
Copyright (C) 2024 Poke Project
|
|
||||||
GPLv3-or-later notice below
|
|
||||||
@licend
|
|
||||||
*/
|
|
||||||
document.addEventListener("DOMContentLoaded",()=>{
|
document.addEventListener("DOMContentLoaded",()=>{
|
||||||
const channels=[...document.querySelectorAll(".channel")];
|
const channels=document.querySelectorAll(".channel");
|
||||||
const search=document.getElementById("search");
|
|
||||||
const clear=document.getElementById("clearSearch");
|
|
||||||
const sortAZ=document.getElementById("sortAZ");
|
|
||||||
const sortZA=document.getElementById("sortZA");
|
|
||||||
const list=document.getElementById("channelList");
|
|
||||||
const viewer=document.getElementById("viewer");
|
const viewer=document.getElementById("viewer");
|
||||||
const title=document.getElementById("channelTitle");
|
const title=document.getElementById("channelTitle");
|
||||||
|
|
||||||
// JS override only if JavaScript is active
|
|
||||||
document.querySelectorAll(".channel-name-link").forEach(link=>{
|
document.querySelectorAll(".channel-name-link").forEach(link=>{
|
||||||
link.addEventListener("click",e=>{
|
link.addEventListener("click",e=>{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -412,32 +400,27 @@ document.addEventListener("DOMContentLoaded",()=>{
|
|||||||
function renderIframe(id,name){
|
function renderIframe(id,name){
|
||||||
viewer.innerHTML=`
|
viewer.innerHTML=`
|
||||||
<div class="close-view" title="close">✖</div>
|
<div class="close-view" title="close">✖</div>
|
||||||
<iframe sandbox="allow-scripts allow-same-origin allow-popups" src="/channel?id=${encodeURIComponent(id)}&embedchannelsubsfeed=true" loading="lazy" allowfullscreen></iframe>`;
|
<iframe id="chanframe" sandbox="allow-scripts allow-same-origin allow-popups" src="/channel?id=${encodeURIComponent(id)}&embedchannelsubsfeed=true" loading="lazy"></iframe>`;
|
||||||
title.textContent=name;
|
title.textContent=name;
|
||||||
|
|
||||||
|
const frame=document.getElementById("chanframe");
|
||||||
const closeBtn=viewer.querySelector(".close-view");
|
const closeBtn=viewer.querySelector(".close-view");
|
||||||
closeBtn.addEventListener("click",()=>{
|
closeBtn.addEventListener("click",()=>{
|
||||||
viewer.innerHTML='<div class="placeholder">select a channel on the left to view it</div>';
|
viewer.innerHTML='<div class="placeholder">select a channel on the left to view it</div>';
|
||||||
channels.forEach(c=>c.classList.remove("active"));
|
channels.forEach(c=>c.classList.remove("active"));
|
||||||
title.textContent="nothing selected yet";
|
title.textContent="nothing selected yet";
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function filter(){
|
// ensure inside links open in new tabs
|
||||||
const term=search.value.toLowerCase();
|
frame.addEventListener("load",()=>{
|
||||||
channels.forEach(c=>{
|
try{
|
||||||
c.style.display=c.dataset.name.includes(term)?'flex':'none';
|
const doc=frame.contentDocument||frame.contentWindow.document;
|
||||||
|
doc.querySelectorAll("a").forEach(a=>{
|
||||||
|
a.setAttribute("target","_blank");
|
||||||
|
});
|
||||||
|
}catch{}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
search?.addEventListener("input",filter);
|
|
||||||
clear?.addEventListener("click",()=>{search.value='';filter();search.focus();});
|
|
||||||
|
|
||||||
function sortList(asc){
|
|
||||||
const items=[...channels];
|
|
||||||
items.sort((a,b)=>asc?a.dataset.name.localeCompare(b.dataset.name):b.dataset.name.localeCompare(a.dataset.name));
|
|
||||||
items.forEach(i=>list.appendChild(i));
|
|
||||||
}
|
|
||||||
sortAZ?.addEventListener("click",()=>{sortAZ.classList.add("active");sortZA.classList.remove("active");sortList(true);});
|
|
||||||
sortZA?.addEventListener("click",()=>{sortZA.classList.add("active");sortAZ.classList.remove("active");sortList(false);});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user