Nashboard/static/js/mainpage.js

31 lines
1011 B
JavaScript
Raw Normal View History

2022-12-14 02:27:39 +03:00
window.addEventListener("load", async () => {
console.log("loading...");
const rootFolder = await getFolder();
const bm = document.getElementById("bookmarks");
if (!rootFolder.success) {
bm.textContent = "Нет закладок";
return;
}
const template = document.querySelector("#bookmark");
const tagtempl = document.querySelector("#booktag");
if (!template) {
return;
}
for (let b of rootFolder.folder.ChildBookmarks) {
const clone = template.content.cloneNode(true);
clone.querySelector("#bookmark_name").textContent = b.Name;
const link = clone.querySelector("#bookmark_link");
link.setAttribute("href", b.Url);
link.textContent = b.Url;
for (let tag of b.Tags) {
const t = tagtempl.content.cloneNode(true);
const el = t.querySelector("span");
el.addEventListener("onclick", () => alert(tag));
el.textContent = "#" + tag;
clone.querySelector("#bookmark_tags").appendChild(t);
}
bm.appendChild(clone);
}
});