JS style fixes

This commit is contained in:
Timothy Warren 2017-02-16 11:47:54 -05:00
parent 4def692123
commit 672aa287dc
5 changed files with 22 additions and 23 deletions

View File

@ -4,7 +4,7 @@
const search = (tempHtml, query) => {
_.$('.cssload-loader')[0].removeAttribute('hidden');
_.get(_.url('/collection/search'), {'query':query}, (searchResults, status) => {
_.get(_.url('/collection/search'), {query}, (searchResults, status) => {
searchResults = JSON.parse(searchResults);
_.$('.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) {
let query = encodeURIComponent(this.value);
if (query === '') {

View File

@ -6,7 +6,7 @@
'use strict';
// 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 watchedCount = parseInt(_.$('.completed_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 (( ! isNaN(watchedCount)) && (watchedCount + 1) == totalCount) {
if (( ! isNaN(watchedCount)) && (watchedCount + 1) === totalCount) {
data.data.status = 'completed';
}
// okay, lets actually make some changes!
_.ajax(_.url('/anime/update'), {
data: data,
data,
dataType: 'json',
type: 'POST',
success: () => {
if (data.data.status == 'completed') {
if (data.data.status === 'completed') {
_.hide(parentSel);
}

View File

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

View File

@ -11,8 +11,8 @@
});
// Confirm deleting of list or library items
ac.on('form.js-delete', 'submit', event => {
let proceed = confirm("Are you ABSOLUTELY SURE you want to delete this item?");
ac.on('form.js-delete', 'submit', (event) => {
const proceed = confirm("Are you ABSOLUTELY SURE you want to delete this item?");
if (proceed === false) {
event.preventDefault();
@ -23,7 +23,7 @@
// Clear the api cache
ac.on('.js-clear-cache', 'click', () => {
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';
_.on('.manga.list', 'click', '.edit_buttons button', e => {
_.on('.manga.list', 'click', '.edit_buttons button', (e) => {
let thisSel = e.target;
let parentSel = _.closestParent(e.target, 'article');
let mangaId = parentSel.id.replace("manga-", "");
@ -33,7 +33,7 @@
}
// 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';
}
@ -41,12 +41,12 @@
data.data.progress = ++completed;
_.ajax(_.url('/manga/update'), {
data: data,
data,
dataType: 'json',
type: 'POST',
mimeType: 'application/json',
success: () => {
if (data.data.status == 'completed') {
if (data.data.status === 'completed') {
_.hide(parentSel);
}
@ -54,8 +54,7 @@
_.showMessage('success', `Sucessfully updated ${mangaName}`);
_.scrollToTop();
},
error: (xhr, errorType, error) => {
console.error(error);
error: () => {
_.showMessage('error', `Failed to updated ${mangaName}`);
_.scrollToTop();
}