Simplify the form of catching ajax errors

This commit is contained in:
printempw 2017-08-01 12:24:32 +08:00
parent 07110d2580
commit 3e798d9cc5
11 changed files with 46 additions and 46 deletions

View File

@ -17,7 +17,7 @@ function submitColor() {
data: { color_scheme: current_skin }
}).then(({ errno, msg }) => {
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
$('#color-submit').click(submitColor);

View File

@ -11,7 +11,7 @@ function changePreference() {
}
}).then(({ errno, msg }) => {
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeTexture(pid, playerName) {
@ -58,7 +58,7 @@ function ajaxChangeTexture(pid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changePlayerName(pid, oldName) {
@ -85,7 +85,7 @@ function changePlayerName(pid, oldName) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeOwner(pid) {
@ -113,7 +113,7 @@ function changeOwner(pid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
$('.swal2-input').on('input', debounce(() => {
let uid = $('.swal2-input').val();
@ -158,7 +158,7 @@ function deletePlayer(pid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {

View File

@ -13,7 +13,7 @@ function enablePlugin(name) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function disablePlugin(name) {
@ -29,7 +29,7 @@ function disablePlugin(name) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function deletePlugin(name) {
@ -49,7 +49,7 @@ function deletePlugin(name) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {

View File

@ -39,7 +39,7 @@ function downloadUpdates() {
console.log('Downloading finished');
console.log(json);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
// Downloading progress polling
let interval_id = window.setInterval(() => {
@ -70,7 +70,7 @@ function downloadUpdates() {
}, function() {
window.location = url('/');
});
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
} else {
fetch({
@ -80,11 +80,11 @@ function downloadUpdates() {
progress = (json.size / fileSize * 100).toFixed(2);
console.log('Progress: ' + progress);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
}, 300);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}

View File

@ -25,7 +25,7 @@ function changeUserEmail(uid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeUserNickName(uid) {
@ -53,7 +53,7 @@ function changeUserNickName(uid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeUserPwd(uid) {
@ -68,7 +68,7 @@ function changeUserPwd(uid) {
data: { uid: uid, password: password }
})).then(({ errno, msg }) => {
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeUserScore(uid, score) {
@ -80,7 +80,7 @@ function changeUserScore(uid, score) {
data: { uid: uid.slice(5), score: score }
}).then(({ errno, msg }) => {
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeBanStatus(uid) {
@ -107,7 +107,7 @@ function changeBanStatus(uid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeAdminStatus(uid) {
@ -134,7 +134,7 @@ function changeAdminStatus(uid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function deleteUserAccount(uid) {
@ -154,7 +154,7 @@ function deleteUserAccount(uid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
$('body').on('keypress', '.score', function(event){

View File

@ -33,7 +33,7 @@ class TexturePreview {
} else {
MSP.changeSkin(textureUrl);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
return this;

View File

@ -47,7 +47,7 @@ function ajaxAddToCloset(tid, name) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function removeFromCloset(tid) {
@ -70,7 +70,7 @@ function removeFromCloset(tid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changeTextureName(tid, oldName) {
@ -96,7 +96,7 @@ function changeTextureName(tid, oldName) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
/**
@ -151,7 +151,7 @@ function changePrivacy(tid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function deleteTexture(tid) {
@ -172,7 +172,7 @@ function deleteTexture(tid) {
} else {
swal({ type: 'warning', html: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {

View File

@ -26,7 +26,7 @@ $(document).ready(function () {
page, $('input[name=q]').val()
)
}));
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
$('input[name=q]').on('input', debounce(() => {
let category = $('#skin-category').hasClass('active') ? 'skin' : 'cape';
@ -67,7 +67,7 @@ $('body').on('click', '.item-body', function () {
} else if (cape != undefined) {
$indicator.text(trans('general.cape'));
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
});
$('body').on('click', '.category-switch', () => {
@ -158,7 +158,7 @@ function reloadCloset(category, page, search) {
currentPage: page,
totalPages: total_pages
});
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function renameClosetItem(tid, oldName) {
@ -184,7 +184,7 @@ function renameClosetItem(tid, oldName) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function removeFromCloset(tid) {
@ -214,7 +214,7 @@ function removeFromCloset(tid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function setAsAvatar(tid) {
@ -239,7 +239,7 @@ function setAsAvatar(tid) {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {

View File

@ -17,7 +17,7 @@ $('body').on('click', '.player', function () {
data: { pid: $(this).attr('pid'), preference: $(this).val() }
}).then(({ errno, msg }) => {
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
});
function showPlayerTexturePreview(pid) {
@ -48,7 +48,7 @@ function showPlayerTexturePreview(pid) {
console.log(`Texture previews of player ${result.player_name} rendered.`);
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changePlayerName(pid) {
@ -77,7 +77,7 @@ function changePlayerName(pid) {
} else {
swal({ type: 'error', html: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function clearTexture(pid) {
@ -122,7 +122,7 @@ function ajaxClearTexture(pid) {
}).then(({ errno, msg }) => {
swal({ type: errno == 0 ? 'success' : 'error', html: msg });
$('.modal').modal('hide');
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function deletePlayer(pid) {
@ -147,7 +147,7 @@ function deletePlayer(pid) {
} else {
swal({ type: 'error', html: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function addNewPlayer() {
@ -167,7 +167,7 @@ function addNewPlayer() {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function setTexture() {
@ -200,7 +200,7 @@ function setTexture() {
} else {
toastr.warning(msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
}

View File

@ -27,7 +27,7 @@ function changeNickName() {
} else {
return swal({ type: 'warning', html: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function changePassword() {
@ -67,11 +67,11 @@ function changePassword() {
if (errno == 0) {
window.location = url('auth/login');
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
} else {
return swal({ type: 'warning', text: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
}
@ -117,11 +117,11 @@ function changeEmail() {
if (errno == 0) {
window.location = url('auth/login');
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
} else {
return swal({ type: 'warning', text: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
function deleteAccount() {
@ -147,7 +147,7 @@ function deleteAccount() {
} else {
return swal({ type: 'warning', html: msg });
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {

View File

@ -24,7 +24,7 @@ function sign() {
} else {
toastr.warning(result.msg);
}
}).catch(err => showAjaxError(err));
}).catch(showAjaxError);
}
if (typeof require !== 'undefined' && typeof module !== 'undefined') {