Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
Showing only changes of commit 086b5a9f2d - Show all commits

View File

@ -6,13 +6,13 @@
'use strict'; 'use strict';
_.on('.manga.list', 'click', '.edit_buttons button', e => { _.on('.manga.list', 'click', '.edit_buttons button', e => {
let this_sel = e.target; let thisSel = e.target;
let parent_sel = _.closestParent(e.target, 'article'); let parentSel = _.closestParent(e.target, 'article');
let manga_id = parent_sel.id.replace("manga-", ""); let mangaId = parentSel.id.replace("manga-", "");
let type = this_sel.classList.contains("plus_one_chapter") ? 'chapter' : 'volume'; let type = thisSel.classList.contains("plus_one_chapter") ? 'chapter' : 'volume';
let completed = parseInt(_.$(`.${type}s_read`, parent_sel)[0].textContent, 10); let completed = parseInt(_.$(`.${type}s_read`, parentSel)[0].textContent, 10);
let total = parseInt(_.$(`.${type}_count`, parent_sel)[0].textContent, 10); let total = parseInt(_.$(`.${type}_count`, parentSel)[0].textContent, 10);
let manga_name = _.$('.name', parent_sel)[0].textContent; let mangaName = _.$('.name', parentSel)[0].textContent;
if (isNaN(completed)) { if (isNaN(completed)) {
completed = 0; completed = 0;
@ -20,7 +20,7 @@
// Setup the update data // Setup the update data
let data = { let data = {
id: manga_id, id: mangaId,
data: { data: {
progress: completed progress: completed
} }
@ -47,16 +47,16 @@
mimeType: 'application/json', mimeType: 'application/json',
success: () => { success: () => {
if (data.data.status == 'completed') { if (data.data.status == 'completed') {
_.hide(parent_sel); _.hide(parentSel);
} }
_.$(`.${type}s_read`, parent_sel)[0].textContent = completed; _.$(`.${type}s_read`, parentSel)[0].textContent = completed;
_.showMessage('success', `Sucessfully updated ${manga_name}`); _.showMessage('success', `Sucessfully updated ${mangaName}`);
_.scrollToTop(); _.scrollToTop();
}, },
error: (xhr, errorType, error) => { error: (xhr, errorType, error) => {
console.error(error); console.error(error);
_.showMessage('error', `Failed to updated ${manga_name}`); _.showMessage('error', `Failed to updated ${mangaName}`);
_.scrollToTop(); _.scrollToTop();
} }
}); });