From 5fc70bb4fe7d0712fa53d4918577c67a60631b59 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 9 Jan 2017 21:38:42 -0500 Subject: [PATCH] Fix some javascript issues --- app/config/minify_js_groups.php | 2 +- public/js/anime_edit.js | 6 +++--- public/js/manga_edit.js | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/config/minify_js_groups.php b/app/config/minify_js_groups.php index 236f7828..c50086d8 100644 --- a/app/config/minify_js_groups.php +++ b/app/config/minify_js_groups.php @@ -31,7 +31,7 @@ return [ 'base/sort_tables.js', ], 'table_edit' => [ - 'sort_tables.js', + 'base/sort_tables.js', 'anime_edit.js', 'manga_edit.js', ], diff --git a/public/js/anime_edit.js b/public/js/anime_edit.js index e1312970..c4e53e15 100644 --- a/public/js/anime_edit.js +++ b/public/js/anime_edit.js @@ -6,7 +6,7 @@ 'use strict'; // Action to increment episode count - _.on('body.anime.list', 'click', '.plus_one', function(e) { + _.on('body.anime.list', 'click', '.plus_one', function() { let parent_sel = _.closestParent(this, 'article'); let watched_count = parseInt(_.$('.completed_number', parent_sel)[0].textContent, 10); let total_count = parseInt(_.$('.total_number', parent_sel)[0].textContent, 10); @@ -36,8 +36,8 @@ data: data, dataType: 'json', type: 'POST', - success: (res) => { - if (data.status == 'completed') { + success: () => { + if (data.data.status == 'completed') { _.hide(parent_sel); } diff --git a/public/js/manga_edit.js b/public/js/manga_edit.js index a97fb35f..7e13973d 100644 --- a/public/js/manga_edit.js +++ b/public/js/manga_edit.js @@ -5,7 +5,7 @@ 'use strict'; - _.on('.manga.list', 'click', '.edit_buttons button', function(e) { + _.on('.manga.list', 'click', '.edit_buttons button', function() { let this_sel = this; let parent_sel = _.closestParent(this, 'article'); let manga_id = parent_sel.id.replace("manga-", ""); @@ -26,6 +26,17 @@ } }; + // If the episode count is 0, and incremented, + // change status to currently reading + if (isNaN(completed) || completed === 0) { + data.data.status = 'current'; + } + + // If you increment at the last chapter, mark as completed + if (( ! isNaN(completed)) && (completed + 1) == total) { + data.data.status = 'completed'; + } + // Update the total count data['data']['progress'] = ++completed; @@ -34,7 +45,11 @@ dataType: 'json', type: 'POST', mimeType: 'application/json', - success: (res) => { + success: () => { + if (data.data.status == 'completed') { + _.hide(parent_sel); + } + _.$(`.${type}s_read`, parent_sel)[0].textContent = completed; _.showMessage('success', `Sucessfully updated ${manga_name}`); _.scrollToTop();