Folders, icons and dark theme
This commit is contained in:
2130
static/js/feather.min.js
vendored
Normal file
2130
static/js/feather.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,7 @@
|
||||
if (!localStorage.getItem("SessionID")) {
|
||||
window.location.href = "/login.html";
|
||||
}
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
console.log("loading...");
|
||||
const rootFolder = await getFolder();
|
||||
@ -6,25 +10,58 @@ window.addEventListener("load", async () => {
|
||||
bm.textContent = "Нет закладок";
|
||||
return;
|
||||
}
|
||||
const template = document.querySelector("#bookmark");
|
||||
const tagtempl = document.querySelector("#booktag");
|
||||
if (!template) {
|
||||
if (!bookmark || !folder) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (let f of rootFolder.folder.ChildFolders) {
|
||||
const clone = createFolderElement(f);
|
||||
bm.appendChild(clone);
|
||||
}
|
||||
for (let b of rootFolder.folder.ChildBookmarks) {
|
||||
const clone = createBookmarkElement(b);
|
||||
bm.appendChild(clone);
|
||||
}
|
||||
feather.replace();
|
||||
});
|
||||
|
||||
function createFolderElement(folder) {
|
||||
const template = document.querySelector("#folder");
|
||||
const clone = template.content.firstElementChild.cloneNode(true);
|
||||
clone.querySelector("#folder_name").textContent = folder.Name;
|
||||
clone.addEventListener("click", () => {
|
||||
alert(folder.Name);
|
||||
});
|
||||
for (let el of clone.querySelectorAll("[data-feather-t]")) {
|
||||
el.setAttribute("data-feather", el.getAttribute("data-feather-t"));
|
||||
}
|
||||
clone.querySelector(".xmark").addEventListener("click", (e) => {
|
||||
alert(`${folder.Name} was deleted`);
|
||||
e.stopPropagation();
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
|
||||
function createBookmarkElement(bookmark) {
|
||||
const template = document.querySelector("#bookmark");
|
||||
const tagtempl = document.querySelector("#booktag");
|
||||
const clone = template.content.firstElementChild.cloneNode(true);
|
||||
clone.querySelector("#bookmark_name").textContent = bookmark.Name;
|
||||
const link = clone.querySelector("#bookmark_link");
|
||||
link.setAttribute("href", bookmark.Url);
|
||||
link.textContent = bookmark.Url;
|
||||
for (let tag of bookmark.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);
|
||||
}
|
||||
for (let el of clone.querySelectorAll("[data-feather-t]")) {
|
||||
el.setAttribute("data-feather", el.getAttribute("data-feather-t"));
|
||||
}
|
||||
clone.querySelector(".xmark").addEventListener("click", (e) => {
|
||||
alert(`${bookmark.Name} was deleted`);
|
||||
e.stopPropagation();
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
|
Reference in New Issue
Block a user