Fix some javascript issues
This commit is contained in:
parent
6e818b7f45
commit
9f048b739e
@ -31,7 +31,7 @@ return [
|
|||||||
'base/sort_tables.js',
|
'base/sort_tables.js',
|
||||||
],
|
],
|
||||||
'table_edit' => [
|
'table_edit' => [
|
||||||
'sort_tables.js',
|
'base/sort_tables.js',
|
||||||
'anime_edit.js',
|
'anime_edit.js',
|
||||||
'manga_edit.js',
|
'manga_edit.js',
|
||||||
],
|
],
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Action to increment episode count
|
// 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 parent_sel = _.closestParent(this, 'article');
|
||||||
let watched_count = parseInt(_.$('.completed_number', parent_sel)[0].textContent, 10);
|
let watched_count = parseInt(_.$('.completed_number', parent_sel)[0].textContent, 10);
|
||||||
let total_count = parseInt(_.$('.total_number', parent_sel)[0].textContent, 10);
|
let total_count = parseInt(_.$('.total_number', parent_sel)[0].textContent, 10);
|
||||||
@ -36,8 +36,8 @@
|
|||||||
data: data,
|
data: data,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
success: (res) => {
|
success: () => {
|
||||||
if (data.status == 'completed') {
|
if (data.data.status == 'completed') {
|
||||||
_.hide(parent_sel);
|
_.hide(parent_sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
_.on('.manga.list', 'click', '.edit_buttons button', function(e) {
|
_.on('.manga.list', 'click', '.edit_buttons button', function() {
|
||||||
let this_sel = this;
|
let this_sel = this;
|
||||||
let parent_sel = _.closestParent(this, 'article');
|
let parent_sel = _.closestParent(this, 'article');
|
||||||
let manga_id = parent_sel.id.replace("manga-", "");
|
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
|
// Update the total count
|
||||||
data['data']['progress'] = ++completed;
|
data['data']['progress'] = ++completed;
|
||||||
|
|
||||||
@ -34,7 +45,11 @@
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
mimeType: 'application/json',
|
mimeType: 'application/json',
|
||||||
success: (res) => {
|
success: () => {
|
||||||
|
if (data.data.status == 'completed') {
|
||||||
|
_.hide(parent_sel);
|
||||||
|
}
|
||||||
|
|
||||||
_.$(`.${type}s_read`, parent_sel)[0].textContent = completed;
|
_.$(`.${type}s_read`, parent_sel)[0].textContent = completed;
|
||||||
_.showMessage('success', `Sucessfully updated ${manga_name}`);
|
_.showMessage('success', `Sucessfully updated ${manga_name}`);
|
||||||
_.scrollToTop();
|
_.scrollToTop();
|
||||||
|
Loading…
Reference in New Issue
Block a user