Use ES6 destructuring assignment syntax
This commit is contained in:
parent
3a74329548
commit
52a18195cd
|
|
@ -25,7 +25,7 @@ function addToCloset(tid) {
|
|||
inputValidator: value => (new Promise((resolve, reject) => {
|
||||
value ? resolve() : reject(trans('skinlib.emptyItemName'));
|
||||
}))
|
||||
}).then((result) => ajaxAddToCloset(tid, result));
|
||||
}).then(result => ajaxAddToCloset(tid, result));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
var selectedTextures = [];
|
||||
|
||||
$(document).ready(function () {
|
||||
$('input[type=radio]').iCheck({
|
||||
radioClass: 'iradio_square-blue'
|
||||
});
|
||||
|
||||
if (! window.location.pathname.includes('/user/closet'))
|
||||
return;
|
||||
|
||||
|
|
@ -13,11 +17,11 @@ $(document).ready(function () {
|
|||
type: 'GET',
|
||||
url: url('/user/closet-data'),
|
||||
dataType: 'json'
|
||||
}).then(result => {
|
||||
renderCloset(result.items, result.category);
|
||||
}).then(({ items, category, total_pages }) => {
|
||||
renderCloset(items, category);
|
||||
|
||||
$('#closet-paginator').jqPaginator($.extend({}, $.defaultPaginatorConfig, {
|
||||
totalPages: result.total_pages,
|
||||
totalPages: total_pages,
|
||||
onPageChange: page => reloadCloset(
|
||||
$('#skin-category').hasClass('active') ? 'skin' : 'cape',
|
||||
page, $('input[name=q]').val()
|
||||
|
|
@ -43,12 +47,12 @@ $('body').on('click', '.item-body', function () {
|
|||
type: 'POST',
|
||||
url: url(`skinlib/info/${tid}`),
|
||||
dataType: 'json'
|
||||
}).then(result => {
|
||||
if (result.type == 'cape') {
|
||||
MSP.changeCape(url(`textures/${result.hash}`));
|
||||
}).then(({ type, hash }) => {
|
||||
if (type == 'cape') {
|
||||
MSP.changeCape(url(`textures/${hash}`));
|
||||
selectedTextures['cape'] = tid;
|
||||
} else {
|
||||
MSP.changeSkin(url(`textures/${result.hash}`));
|
||||
MSP.changeSkin(url(`textures/${hash}`));
|
||||
selectedTextures['skin'] = tid;
|
||||
}
|
||||
|
||||
|
|
@ -145,15 +149,15 @@ function reloadCloset(category, page, search) {
|
|||
page: page,
|
||||
q: search
|
||||
}
|
||||
}).then(result => {
|
||||
renderCloset(result.items, result.category);
|
||||
}).then(({ items, category, total_pages }) => {
|
||||
renderCloset(items, category);
|
||||
|
||||
let paginator = $('#closet-paginator');
|
||||
|
||||
paginator.attr(`last-${result.category}-page`, page);
|
||||
paginator.attr(`last-${category}-page`, page);
|
||||
paginator.jqPaginator('option', {
|
||||
currentPage: page,
|
||||
totalPages: result.total_pages
|
||||
totalPages: total_pages
|
||||
});
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -174,12 +178,12 @@ function renameClosetItem(tid, oldName) {
|
|||
url: url('closet/rename'),
|
||||
dataType: 'json',
|
||||
data: { tid: tid, new_name: name }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
$(`[tid=${tid}]>.item-footer>.texture-name>span`).html(newTextureName);
|
||||
toastr.success(result.msg);
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
toastr.warning(msg);
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -194,9 +198,9 @@ function removeFromCloset(tid) {
|
|||
url: url('closet/remove'),
|
||||
dataType: 'json',
|
||||
data: { tid: tid }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
swal({ type: 'success', html: result.msg });
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
$(`div[tid=${tid}]`).remove();
|
||||
|
||||
|
|
@ -209,7 +213,7 @@ function removeFromCloset(tid) {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
toastr.warning(msg);
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -225,16 +229,16 @@ function setAsAvatar(tid) {
|
|||
url: url('user/profile/avatar'),
|
||||
dataType: 'json',
|
||||
data: { tid: tid }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
toastr.success(result.msg);
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
// Refersh avatars
|
||||
$('[alt="User Image"]').each(function () {
|
||||
$(this).prop('src', $(this).attr('src') + '?' + new Date().getTime());
|
||||
});
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
toastr.warning(msg);
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,8 @@ $('body').on('change', '#preference', function () {
|
|||
url: url('user/player/preference'),
|
||||
dataType: 'json',
|
||||
data: { pid: $(this).attr('pid'), preference: $(this).val() }
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
toastr.success(result.msg);
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
}
|
||||
}).then(({ errno, msg }) => {
|
||||
(errno == 0) ? toastr.success(msg) : toastr.warning(msg);
|
||||
}).catch(err => showAjaxError(err));
|
||||
});
|
||||
|
||||
|
|
@ -77,13 +73,13 @@ function changePlayerName(pid, currentPlayerName) {
|
|||
url: url('user/player/rename'),
|
||||
dataType: 'json',
|
||||
data: { pid: pid, new_player_name: name }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
swal({ type: 'success', html: result.msg });
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
$(`td:contains("${pid}")`).next().html(newPlayerName);
|
||||
} else {
|
||||
swal({ type: 'error', html: result.msg });
|
||||
swal({ type: 'error', html: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -127,8 +123,8 @@ function ajaxClearTexture(pid) {
|
|||
url: url('user/player/texture/clear'),
|
||||
dataType: 'json',
|
||||
data: data
|
||||
}).then(result => {
|
||||
swal({ type: result.errno == 0 ? 'success' : 'error', html: result.msg });
|
||||
}).then(({ errno, msg }) => {
|
||||
swal({ type: errno == 0 ? 'success' : 'error', html: msg });
|
||||
$('.modal').modal('hide');
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -146,14 +142,14 @@ function deletePlayer(pid) {
|
|||
url: url('user/player/delete'),
|
||||
dataType: 'json',
|
||||
data: { pid: pid }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
swal({
|
||||
type: 'success',
|
||||
html: result.msg
|
||||
html: msg
|
||||
}).then(() => $(`tr#${pid}`).remove());
|
||||
} else {
|
||||
swal({ type: 'error', html: result.msg });
|
||||
swal({ type: 'error', html: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -164,16 +160,16 @@ function addNewPlayer() {
|
|||
url: url('user/player/add'),
|
||||
dataType: 'json',
|
||||
data: { player_name: $('#player_name').val() }
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
}).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
swal({
|
||||
type: 'success',
|
||||
html: result.msg
|
||||
html: msg
|
||||
}).then(() => location.reload());
|
||||
|
||||
$('#modal-add-player').modal('hide');
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
toastr.warning(msg);
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -201,12 +197,12 @@ function setTexture() {
|
|||
'tid[skin]': skin,
|
||||
'tid[cape]': cape
|
||||
}
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
swal({ type: 'success', html: result.msg });
|
||||
}).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
$('#modal-use-as').modal('hide');
|
||||
} else {
|
||||
toastr.warning(result.msg);
|
||||
toastr.warning(msg);
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ function changeNickName() {
|
|||
url: url('user/profile?action=nickname'),
|
||||
dataType: 'json',
|
||||
data: { new_nickname: name }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
|
||||
$('.nickname').each(function () {
|
||||
$(this).html(name);
|
||||
});
|
||||
|
||||
return swal({ type: 'success', html: result.msg });
|
||||
return swal({ type: 'success', html: msg });
|
||||
} else {
|
||||
return swal({ type: 'warning', html: result.msg });
|
||||
return swal({ type: 'warning', html: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -58,20 +58,20 @@ function changePassword() {
|
|||
url: url('user/profile?action=password'),
|
||||
dataType: 'json',
|
||||
data: { 'current_password': password, 'new_password': newPasswd }
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
}).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
return swal({
|
||||
type: 'success',
|
||||
text: result.msg }
|
||||
text: msg }
|
||||
).then(() => {
|
||||
return logout();
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
}).then(({ errno }) => {
|
||||
if (errno == 0) {
|
||||
window.location = url('auth/login');
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
} else {
|
||||
return swal({ type: 'warning', text: result.msg });
|
||||
return swal({ type: 'warning', text: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -108,20 +108,20 @@ function changeEmail() {
|
|||
url: url('user/profile?action=email'),
|
||||
dataType: 'json',
|
||||
data: { new_email: newEmail, password: $('#current-password').val() }
|
||||
})).then(result => {
|
||||
if (result.errno == 0) {
|
||||
})).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
return swal({
|
||||
type: 'success',
|
||||
text: result.msg
|
||||
text: msg
|
||||
}).then(() => {
|
||||
return logout();
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
}).then(({ errno }) => {
|
||||
if (errno == 0) {
|
||||
window.location = url('auth/login');
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
} else {
|
||||
return swal({ type: 'warning', text: result.msg });
|
||||
return swal({ type: 'warning', text: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
@ -138,16 +138,16 @@ function deleteAccount() {
|
|||
url: url('user/profile?action=delete'),
|
||||
dataType: 'json',
|
||||
data: { password: password }
|
||||
}).then(result => {
|
||||
if (result.errno == 0) {
|
||||
}).then(({ errno, msg }) => {
|
||||
if (errno == 0) {
|
||||
return swal({
|
||||
type: 'success',
|
||||
html: result.msg
|
||||
html: msg
|
||||
}).then(() => {
|
||||
window.location = url('auth/login');
|
||||
});
|
||||
} else {
|
||||
return swal({ type: 'warning', html: result.msg });
|
||||
return swal({ type: 'warning', html: msg });
|
||||
}
|
||||
}).catch(err => showAjaxError(err));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user