JS style fixes

This commit is contained in:
Timothy Warren 2017-02-16 11:47:54 -05:00
parent 85cd77267b
commit 6ed755e252
5 changed files with 22 additions and 23 deletions

View File

@ -4,7 +4,7 @@
const search = (tempHtml, query) => { const search = (tempHtml, query) => {
_.$('.cssload-loader')[0].removeAttribute('hidden'); _.$('.cssload-loader')[0].removeAttribute('hidden');
_.get(_.url('/collection/search'), {'query':query}, (searchResults, status) => { _.get(_.url('/collection/search'), {query}, (searchResults, status) => {
searchResults = JSON.parse(searchResults); searchResults = JSON.parse(searchResults);
_.$('.cssload-loader')[0].setAttribute('hidden', 'hidden'); _.$('.cssload-loader')[0].setAttribute('hidden', 'hidden');
@ -18,7 +18,7 @@
}); });
}; };
_.get('/public/templates/anime-ajax-search-results.html', tempHtml => { _.get('/public/templates/anime-ajax-search-results.html', (tempHtml) => {
_.on('#search', 'keyup', _.throttle(250, function(e) { _.on('#search', 'keyup', _.throttle(250, function(e) {
let query = encodeURIComponent(this.value); let query = encodeURIComponent(this.value);
if (query === '') { if (query === '') {

View File

@ -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', e => { _.on('body.anime.list', 'click', '.plus_one', (e) => {
let parentSel = _.closestParent(e.target, 'article'); let parentSel = _.closestParent(e.target, 'article');
let watchedCount = parseInt(_.$('.completed_number', parentSel)[0].textContent, 10); let watchedCount = parseInt(_.$('.completed_number', parentSel)[0].textContent, 10);
let totalCount = parseInt(_.$('.total_number', parentSel)[0].textContent, 10); let totalCount = parseInt(_.$('.total_number', parentSel)[0].textContent, 10);
@ -28,17 +28,17 @@
} }
// If you increment at the last episode, mark as completed // If you increment at the last episode, mark as completed
if (( ! isNaN(watchedCount)) && (watchedCount + 1) == totalCount) { if (( ! isNaN(watchedCount)) && (watchedCount + 1) === totalCount) {
data.data.status = 'completed'; data.data.status = 'completed';
} }
// okay, lets actually make some changes! // okay, lets actually make some changes!
_.ajax(_.url('/anime/update'), { _.ajax(_.url('/anime/update'), {
data: data, data,
dataType: 'json', dataType: 'json',
type: 'POST', type: 'POST',
success: () => { success: () => {
if (data.data.status == 'completed') { if (data.data.status === 'completed') {
_.hide(parentSel); _.hide(parentSel);
} }

View File

@ -26,7 +26,7 @@ var AnimeClient = (function(w) {
* @return {array} - array of dom elements * @return {array} - array of dom elements
*/ */
$(selector, context) { $(selector, context) {
if (typeof selector !== "string") { if (typeof selector !== 'string') {
return selector; return selector;
} }
@ -78,10 +78,10 @@ var AnimeClient = (function(w) {
*/ */
showMessage(type, message) { showMessage(type, message) {
let template = let template =
`<div class="message ${type}"> `<div class='message ${type}'>
<span class="icon"></span> <span class='icon'></span>
${message} ${message}
<span class="close"></span> <span class='close'></span>
</div>`; </div>`;
let sel = AnimeClient.$('.message'); let sel = AnimeClient.$('.message');
@ -225,7 +225,7 @@ var AnimeClient = (function(w) {
pairs.push(`${name}=${value}`); pairs.push(`${name}=${value}`);
}); });
return pairs.join("&"); return pairs.join('&');
}; };
/** /**
@ -255,7 +255,7 @@ var AnimeClient = (function(w) {
let request = new XMLHttpRequest(); let request = new XMLHttpRequest();
let method = String(config.type).toUpperCase(); let method = String(config.type).toUpperCase();
if (method === "GET") { if (method === 'GET') {
url += (url.match(/\?/)) url += (url.match(/\?/))
? ajaxSerialize(config.data) ? ajaxSerialize(config.data)
: `?${ajaxSerialize(config.data)}`; : `?${ajaxSerialize(config.data)}`;
@ -267,7 +267,7 @@ var AnimeClient = (function(w) {
if (request.readyState === 4) { if (request.readyState === 4) {
let responseText = ''; let responseText = '';
if (request.responseType == 'json') { if (request.responseType === 'json') {
responseText = JSON.parse(request.responseText); responseText = JSON.parse(request.responseText);
} else { } else {
responseText = request.responseText; responseText = request.responseText;
@ -291,7 +291,7 @@ var AnimeClient = (function(w) {
request.setRequestHeader('Content-Type', config.mimeType); request.setRequestHeader('Content-Type', config.mimeType);
switch (method) { switch (method) {
case "GET": case 'GET':
request.send(null); request.send(null);
break; break;

View File

@ -11,8 +11,8 @@
}); });
// Confirm deleting of list or library items // Confirm deleting of list or library items
ac.on('form.js-delete', 'submit', event => { ac.on('form.js-delete', 'submit', (event) => {
let proceed = confirm("Are you ABSOLUTELY SURE you want to delete this item?"); const proceed = confirm("Are you ABSOLUTELY SURE you want to delete this item?");
if (proceed === false) { if (proceed === false) {
event.preventDefault(); event.preventDefault();
@ -23,7 +23,7 @@
// Clear the api cache // Clear the api cache
ac.on('.js-clear-cache', 'click', () => { ac.on('.js-clear-cache', 'click', () => {
ac.get('/cache_purge', () => { ac.get('/cache_purge', () => {
ac.showMessage('success', `Successfully purged api cache`); ac.showMessage('success', 'Successfully purged api cache');
}); });
}); });

View File

@ -5,7 +5,7 @@
'use strict'; 'use strict';
_.on('.manga.list', 'click', '.edit_buttons button', e => { _.on('.manga.list', 'click', '.edit_buttons button', (e) => {
let thisSel = e.target; let thisSel = e.target;
let parentSel = _.closestParent(e.target, 'article'); let parentSel = _.closestParent(e.target, 'article');
let mangaId = parentSel.id.replace("manga-", ""); let mangaId = parentSel.id.replace("manga-", "");
@ -33,7 +33,7 @@
} }
// If you increment at the last chapter, mark as completed // If you increment at the last chapter, mark as completed
if (( ! isNaN(completed)) && (completed + 1) == total) { if (( ! isNaN(completed)) && (completed + 1) === total) {
data.data.status = 'completed'; data.data.status = 'completed';
} }
@ -41,12 +41,12 @@
data.data.progress = ++completed; data.data.progress = ++completed;
_.ajax(_.url('/manga/update'), { _.ajax(_.url('/manga/update'), {
data: data, data,
dataType: 'json', dataType: 'json',
type: 'POST', type: 'POST',
mimeType: 'application/json', mimeType: 'application/json',
success: () => { success: () => {
if (data.data.status == 'completed') { if (data.data.status === 'completed') {
_.hide(parentSel); _.hide(parentSel);
} }
@ -54,8 +54,7 @@
_.showMessage('success', `Sucessfully updated ${mangaName}`); _.showMessage('success', `Sucessfully updated ${mangaName}`);
_.scrollToTop(); _.scrollToTop();
}, },
error: (xhr, errorType, error) => { error: () => {
console.error(error);
_.showMessage('error', `Failed to updated ${mangaName}`); _.showMessage('error', `Failed to updated ${mangaName}`);
_.scrollToTop(); _.scrollToTop();
} }