diff options
Diffstat (limited to 'js/index.js')
-rw-r--r-- | js/index.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/index.js b/js/index.js index 3faf152..4996d1a 100644 --- a/js/index.js +++ b/js/index.js @@ -13,6 +13,30 @@ function cache_refresh() { } } +function toggle_fav(elem) { + var bookId = elem.getAttribute("data-book-id"); + + $.post("backend.php", {op: "togglefav", id: bookId}, function(data) { + if (data) { + var msg = "[Error]"; + + if (data.status == 0) { + msg = "Add to favorites"; + } else if (data.status == 1) { + msg = "Remove from favorites"; + } + + $(elem).html(msg); + + if (index_mode == "favorites" && data.status == 0) { + $("#cell-" + bookId).remove(); + } + } + }); + + return false; +} + function mark_offline(elem) { var bookId = elem.getAttribute("data-book-id"); |