From 55f2b0090a9f711cfa383b0d3b3253c9431b93e9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 21 Jul 2017 14:39:14 +0300 Subject: add basic favorites via a horrible hack --- js/index.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'js/index.js') 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"); -- cgit v1.2.3