diff options
author | Andrew Dolgov <[email protected]> | 2017-07-21 14:39:14 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-07-21 14:39:14 +0300 |
commit | 55f2b0090a9f711cfa383b0d3b3253c9431b93e9 (patch) | |
tree | d87f1cbccbc066d264922518e631189227397693 /js | |
parent | ee4c7c44adabd057014b3c62cf16c6c4947ecc1a (diff) |
add basic favorites via a horrible hack
Diffstat (limited to '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"); |