From 1224882092313d7b6b31f80aeb941df052b80735 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 15 Feb 2017 14:08:15 -0500 Subject: [PATCH] Javascript style fixes --- public/js/anime_edit.js | 23 +++++++++++------------ public/js/base/AnimeClient.js | 4 ++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/public/js/anime_edit.js b/public/js/anime_edit.js index 37bb5a68..57cc24ad 100644 --- a/public/js/anime_edit.js +++ b/public/js/anime_edit.js @@ -7,28 +7,28 @@ // Action to increment episode count _.on('body.anime.list', 'click', '.plus_one', e => { - let parent_sel = _.closestParent(e.target, 'article'); - let watched_count = parseInt(_.$('.completed_number', parent_sel)[0].textContent, 10); - let total_count = parseInt(_.$('.total_number', parent_sel)[0].textContent, 10); - let title = _.$('.name a', parent_sel)[0].textContent; + let parentSel = _.closestParent(e.target, 'article'); + let watchedCount = parseInt(_.$('.completed_number', parentSel)[0].textContent, 10); + let totalCount = parseInt(_.$('.total_number', parentSel)[0].textContent, 10); + let title = _.$('.name a', parentSel)[0].textContent; // Setup the update data let data = { - id: parent_sel.dataset.kitsuId, - mal_id: parent_sel.dataset.malId, + id: parentSel.dataset.kitsuId, + mal_id: parentSel.dataset.malId, data: { - progress: watched_count + 1 + progress: watchedCount + 1 } }; // If the episode count is 0, and incremented, // change status to currently watching - if (isNaN(watched_count) || watched_count === 0) { + if (isNaN(watchedCount) || watchedCount === 0) { data.data.status = 'current'; } // If you increment at the last episode, mark as completed - if (( ! isNaN(watched_count)) && (watched_count + 1) == total_count) { + if (( ! isNaN(watchedCount)) && (watchedCount + 1) == totalCount) { data.data.status = 'completed'; } @@ -39,15 +39,14 @@ type: 'POST', success: () => { if (data.data.status == 'completed') { - _.hide(parent_sel); + _.hide(parentSel); } _.showMessage('success', `Successfully updated ${title}`); - _.$('.completed_number', parent_sel)[0].textContent = ++watched_count; + _.$('.completed_number', parentSel)[0].textContent = ++watchedCount; _.scrollToTop(); }, error: (xhr, errorType, error) => { - console.error(error); _.showMessage('error', `Failed to update ${title}. `); _.scrollToTop(); } diff --git a/public/js/base/AnimeClient.js b/public/js/base/AnimeClient.js index e07ea9cb..92614baf 100644 --- a/public/js/base/AnimeClient.js +++ b/public/js/base/AnimeClient.js @@ -26,7 +26,7 @@ var AnimeClient = (function(w) { * @return {array} - array of dom elements */ $(selector, context) { - if (typeof selector != "string" || selector === undefined) { + if (typeof selector !== "string") { return selector; } @@ -200,7 +200,7 @@ var AnimeClient = (function(w) { delegateEvent(el, target, event, listener); }); } - } + }; // ------------------------------------------------------------------------- // ! Ajax