").attr("id", "group-" + indexes[i].groupIndex).appendTo(cardList);
}
for (let item of indexes) {
@@ -84,6 +87,12 @@ function buildGroup(groupInfo, placeholder) {
var groupRequest = groupStore.getAll();
groupRequest.onsuccess = function (e) {
var bookmarks = e.target.result;
+ var keyRequest = groupStore.getAllKeys();
+ keyRequest.onsuccess = function (evt) {
+ var keys = evt.target.result;
+ for (var i = 0; i < bookmarks.length; i++) {
+ bookmarks[i].key = keys[i];
+ }
bookmarkList[groupInfo.groupIndex] = {
"title": groupInfo.title,
@@ -93,33 +102,45 @@ function buildGroup(groupInfo, placeholder) {
buildCard(groupInfo.title, bookmarks).appendTo(placeholder);
}
}
+}
function buildCard(title, itemList) {
- var card = $(document.createElement("div"));
+ var card = $("
");
card.attr({
- "id": "group-" + title,
- "class": "card bookmarkGroup"
+ "id": "group-" + title.replace(" ", "-"),
+ "class": "card"
});
- var cardHead = $(document.createElement("div"));
- cardHead.attr({ "class": "card-header" });
+ var cardHead = $("
");
+ cardHead.addClass("card-header");
cardHead.text(title);
+ var btnDel = $("
")
+ .attr("data-group", title)
+ .addClass("btnDelGroup far fa-trash-alt float-right mt-1 start-hidden text-danger clickable");
+ btnDel.appendTo(cardHead);
card.append(cardHead);
- var cardList = $(document.createElement("div"));
- cardList.attr({ "class": "list-group list-group-flush" });
+ var cardList = $("");
+ cardList.addClass("list-group list-group-flush bookmarkGroup").attr("data-group", title);
card.append(cardList);
for (var i = 0; i < itemList.length; i++) {
var item = itemList[i];
- var link = $(document.createElement("a"));
- link.attr({
- "class": "list-group-item list-group-item-action",
- "href": item.address
- });
- link.text(item.name);
- cardList.append(link);
+ var del = $("
")
+ .attr({"data-group": title, "data-key": item.key})
+ .addClass("btnDel far fa-trash-alt float-right mt-1 start-hidden text-danger");
+ del.css("cursor: pointer;");
+
+ $("")
+ .attr({
+ "id": title + "-" + item.key,
+ "class": "list-group-item list-group-item-action bookmark",
+ "href": item.address,
+ })
+ .text(item.name)
+ .append(del)
+ .appendTo(cardList);
}
return card;
diff --git a/main.css b/main.css
index 2f66591..2c74931 100644
--- a/main.css
+++ b/main.css
@@ -24,6 +24,11 @@ body {
padding-bottom: 0.4em;
}
+.start-hidden {
+ display: none;
+ height: 16px; /* prvents problems with height jumping with jquery show/hide */
+}
+
.list-group-item {
padding-top: .4rem;
padding-bottom: .4rem;
@@ -34,6 +39,10 @@ body {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
+.list-group {
+ min-height: 31px;
+}
+
.navbar {
background: transparent !important;
}
@@ -59,6 +68,10 @@ pre {
background: rgba(255, 255, 255, 0.24);
}
+.clickable {
+ cursor: pointer;
+}
+
/* set the width of the main container based on element width */
@media (max-width: 34em) {
#wrapper {