From fd80625003bc63b840b727b5bffe336d8d9e9f71 Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Fri, 29 Dec 2017 21:09:20 -0800 Subject: [PATCH] Clean up data on bookmarks elements --- js/editBookmarks.js | 12 ++++++------ js/loadBookmarks.js | 5 +---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/js/editBookmarks.js b/js/editBookmarks.js index 7a979fb..b312ab0 100644 --- a/js/editBookmarks.js +++ b/js/editBookmarks.js @@ -59,8 +59,8 @@ function bookmarkMoved(dropEvt) { var newIndex = dropEvt.newIndex; if (dropEvt.from != dropEvt.to) { - var oldGroupIndex = $(dropEvt.from).data("group-index"); - var newGroupIndex = $(dropEvt.to).data("group-index"); + var oldGroupIndex = $(dropEvt.from).parent().data("group-index"); + var newGroupIndex = $(dropEvt.to).parent().data("group-index"); var item = $(dropEvt.item); var itemData = {name: item.data("name"), address: item.data("address")}; @@ -87,7 +87,7 @@ function bookmarkMoved(dropEvt) { } openDBRequest.onerror = function (err) { console.error(err); } } else if (oldIndex != newIndex) { - var groupIndex = $(dropEvt.from).data("group-index"); + var groupIndex = $(dropEvt.from).parent().data("group-index"); var openDBRequest = window.indexedDB.open("bookmarks"); openDBRequest.onsuccess = function (dbe) { @@ -112,8 +112,8 @@ function bookmarkMoved(dropEvt) { function deleteBookmark(e) { var item = $(this).parent(); - var groupName = item.parent().data("group"); - var groupIndex = item.parent().data("group-index"); + var groupName = item.parent().parent().data("group-name"); + var groupIndex = item.parent().parent().data("group-index"); var bookmarkIndex = item.index(); var bookmarkItem = $("#" + groupName + "-" + bookmarkIndex); @@ -141,7 +141,7 @@ function deleteBookmark(e) { function deleteGroup(e) { var group = $(this); // the delete group button - var groupIndex = group.data("group"); + var groupIndex = group.parent().parent().data("group-index"); var openDBRequest = window.indexedDB.open("bookmarks"); diff --git a/js/loadBookmarks.js b/js/loadBookmarks.js index d298ea2..e3eb11a 100644 --- a/js/loadBookmarks.js +++ b/js/loadBookmarks.js @@ -87,15 +87,13 @@ function buildCard(title, groupIndex, itemList) { var btnDrag = $("").addClass("mr-2 start-hidden dragGroupHandle") .append($("").addClass("fas fa-bars")); var btnDel = $("") - .attr("data-group", groupIndex) .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 cardList = $("
"); - cardList.addClass("list-group list-group-flush bookmarkGroup") - .attr({"data-group": title, "data-group-index": groupIndex}); + cardList.addClass("list-group list-group-flush bookmarkGroup"); card.append(cardList); for (var i = 0; i < itemList.length; i++) { @@ -106,7 +104,6 @@ function buildCard(title, groupIndex, itemList) { .append($("").addClass("fas fa-bars")); var del = $("") - .attr({"data-group": title, "data-group-index": groupIndex, "data-key": i}) .addClass("btnDel far fa-trash-alt float-right mt-1 start-hidden text-danger"); del.css("cursor: pointer;");