Make loadBookmarks compatible with IE/Edge

This commit is contained in:
Neil Brommer 2018-01-02 20:26:21 -08:00
parent 996844f8d2
commit 6e27927194

View file

@ -9,24 +9,30 @@ function loadBookmarks() {
openDBRequest.onsuccess = function (openEvt) { openDBRequest.onsuccess = function (openEvt) {
db = openEvt.target.result; db = openEvt.target.result;
db.transaction("Groups", "readonly").objectStore("Groups").getAll().onsuccess = function (groupsEvt) { var groupsStore = db.transaction("Groups", "readonly").objectStore("Groups");
var groups = groupsEvt.target.result; groupsStore.count().onsuccess = function (countEvt) {
groups.sort(function (a, b) { var numGroups = countEvt.target.result;
return a.groupIndex - b.groupIndex;
});
// use a placholder to prevent problems with sortable // use a placeholder to prevent problems with sortable
var cardList = $("#cardList"); var cardList = $("#cardList");
for (let groupData of groups) { for (var i = 0; i < numGroups; i++) {
var placeholder = $("<div>").attr("id", "group-" + groupData.groupIndex) $("<div>").attr("id", "group-" + i)
.addClass("bookmarkGroupContainer") .addClass("bookmarkGroupContainer")
.appendTo(cardList); .appendTo(cardList);
buildCard(groupData.title, groupData.groupIndex, groupData.bookmarks)
.appendTo(placeholder);
} }
groupsStore.openCursor().onsuccess = function (cursorEvt) {
var cursor = cursorEvt.target.result;
if (cursor) {
var groupData = cursor.value;
buildCard(groupData.title, groupData.groupIndex, groupData.bookmarks)
.appendTo($("#group-" + groupData.groupIndex));
cursor.continue();
} else {
db.close(); db.close();
}; }
}
}
} }
openDBRequest.onupgradeneeded = function (openEvt) { openDBRequest.onupgradeneeded = function (openEvt) {