").attr("id", "group-" + groupData.groupIndex)
.addClass("bookmarkGroupContainer")
.appendTo(cardList);
- }
-
- bookmarkList = [];
-
- for (let groupData of groups) {
- buildGroup(groupData, $("#group-" + groupData.groupIndex));
- bookmarkList.push(groupData);
+ buildCard(groupData.title, groupData.groupIndex, groupData.bookmarks)
+ .appendTo(placeholder);
}
db.close();
};
}
- openDBRequest.onerror = function (e) { console.log(e); }
+ openDBRequest.onupgradeneeded = function (openEvt) {
+ db = openEvt.target.result;
- openDBRequest.onupgradeneeded = function (e) {
- // the database doesn't exist
- console.log("Creating database");
- db = e.target.result;
-
- var groupStore = db.createObjectStore("Groups", {keyPath: "groupIndex"});
- groupStore.createIndex("groupIndex", "groupIndex", {unique: true});
- groupStore.createIndex("title", "title", {unique: false});
- groupStore.createIndex("bookmarks", "bookmarks", {unique: false});
+ var groupStore = db.createObjectStore("Groups", { keyPath: "groupIndex" });
+ groupStore.createIndex("groupIndex", "groupIndex", { unique: true });
+ groupStore.createIndex("title", "title", { unique: false });
+ groupStore.createIndex("bookmarks", "bookmarks", { unique: false });
var groupData = {
groupIndex: 0,
@@ -63,13 +53,15 @@ function loadBookmarks() {
};
groupStore.add(groupData);
+ db.close();
$("#aboutModal").modal("show");
}
-}
-function buildGroup(groupInfo, placeholder) {
- buildCard(groupInfo.title, groupInfo.groupIndex, groupInfo.bookmarks).appendTo(placeholder);
+ openDBRequest.onerror = function (err) {
+ console.log(err);
+ window.alert("Error loading bookmarks");
+ }
}
function buildCard(title, groupIndex, itemList) {
@@ -81,26 +73,22 @@ function buildCard(title, groupIndex, itemList) {
"data-group-index": groupIndex
});
- var cardHead = $("
");
- cardHead.addClass("card-header");
- cardHead.text(title);
- var btnDrag = $("
").addClass("mr-2 start-hidden dragGroupHandle")
- .append($("").addClass("fas fa-bars"));
- var btnDel = $("")
- .addClass("btnDelGroup far fa-trash-alt float-right mt-1 start-hidden text-danger clickable");
- btnDel.appendTo(cardHead);
- btnDrag.prependTo(cardHead);
- card.append(cardHead);
+ var cardHead = $("").addClass("card-header").text(title).appendTo(card);
+ $("
") // use wrapper, sortable has issues with