style(js): stricter eslint rules (#108)
* style(js): stricter eslint rules * build: ignore .eslintignore
This commit is contained in:
parent
55a137f014
commit
846f29ef6d
4
.eslintignore
Normal file
4
.eslintignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
node_modules/
|
||||
resources/assets/dist/
|
||||
resources/assets/src/vendor/
|
||||
gulpfile.js
|
||||
|
|
@ -7,7 +7,10 @@ module.exports = {
|
|||
"object-curly-spacing": ["error", "always"],
|
||||
"no-unused-vars": "warn",
|
||||
"no-console": "off",
|
||||
"comma-style": ["warn", "last"]
|
||||
"comma-style": ["warn", "last"],
|
||||
"prefer-const": "warn",
|
||||
"no-var": "error",
|
||||
"eqeqeq": "error",
|
||||
},
|
||||
"globals": {
|
||||
"url": false,
|
||||
|
|
@ -29,6 +32,7 @@ module.exports = {
|
|||
"parserOptions": {
|
||||
"ecmaVersion": 2017
|
||||
},
|
||||
"root": true,
|
||||
"env":{
|
||||
"node": true,
|
||||
"es6": true,
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ gulp.task('zip', () => {
|
|||
'LICENSE',
|
||||
'!.babelrc',
|
||||
'!.eslintrc.js',
|
||||
'!.eslintignore',
|
||||
'!.travis.yml',
|
||||
'!{.env,.env.testing}',
|
||||
'!{.git,.git/**}',
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
$('#layout-skins-list [data-skin]').click(function (e) {
|
||||
e.preventDefault();
|
||||
let skin_name = $(this).data('skin');
|
||||
const skin_name = $(this).data('skin');
|
||||
$('body').removeClass(current_skin).addClass(skin_name);
|
||||
current_skin = skin_name;
|
||||
});
|
||||
|
|
@ -17,7 +17,7 @@ async function submitColor() {
|
|||
dataType: 'json',
|
||||
data: { color_scheme: current_skin }
|
||||
});
|
||||
errno == 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
errno === 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ async function changePreference() {
|
|||
preference: $(this).val()
|
||||
}
|
||||
});
|
||||
errno == 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
errno === 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
function changeTexture(pid, playerName) {
|
||||
let dom = `
|
||||
const dom = `
|
||||
<div class="form-group">
|
||||
<label for="model">${trans('admin.textureType')}</label>
|
||||
<select class="form-control" id="model">
|
||||
|
|
@ -41,7 +41,7 @@ function changeTexture(pid, playerName) {
|
|||
async function ajaxChangeTexture(pid) {
|
||||
// Remove interference of modal which is hide
|
||||
$('.modal').each(function () {
|
||||
if ($(this).css('display') == 'none') $(this).remove();
|
||||
if ($(this).css('display') === 'none') $(this).remove();
|
||||
});
|
||||
|
||||
const model = $('#model').val();
|
||||
|
|
@ -54,7 +54,7 @@ async function ajaxChangeTexture(pid) {
|
|||
dataType: 'json',
|
||||
data: { pid: pid, model: model, tid: tid }
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
$(`#${pid}-${model}`).attr('src', url(`preview/64/${tid}.png`));
|
||||
$('.modal').modal('hide');
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ async function ajaxChangeTexture(pid) {
|
|||
}
|
||||
|
||||
async function changePlayerName(pid, oldName) {
|
||||
let dom = $(`tr#${pid} > td:nth-child(3)`);
|
||||
const dom = $(`tr#${pid} > td:nth-child(3)`);
|
||||
let newPlayerName;
|
||||
|
||||
try {
|
||||
|
|
@ -91,7 +91,7 @@ async function changePlayerName(pid, oldName) {
|
|||
dataType: 'json',
|
||||
data: { pid: pid, name: newPlayerName }
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
dom.text(newPlayerName);
|
||||
|
||||
toastr.success(msg);
|
||||
|
|
@ -104,7 +104,7 @@ async function changePlayerName(pid, oldName) {
|
|||
}
|
||||
|
||||
function changeOwner(pid) {
|
||||
let dom = $(`#${pid} > td:nth-child(2)`);
|
||||
const dom = $(`#${pid} > td:nth-child(2)`);
|
||||
let owner = 0;
|
||||
|
||||
swal({
|
||||
|
|
@ -122,7 +122,7 @@ function changeOwner(pid) {
|
|||
dataType: 'json',
|
||||
data: { pid, uid }
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
dom.text(owner);
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
|
|
@ -137,7 +137,7 @@ function changeOwner(pid) {
|
|||
}
|
||||
|
||||
async function showNicknameInSwal() {
|
||||
let uid = $('.swal2-input').val();
|
||||
const uid = $('.swal2-input').val();
|
||||
|
||||
if (isNaN(uid) || uid <= 0)
|
||||
return;
|
||||
|
|
@ -180,7 +180,7 @@ async function deletePlayer(pid) {
|
|||
dataType: 'json',
|
||||
data: { pid: pid }
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
$(`tr#${pid}`).remove();
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ async function enablePlugin(name) {
|
|||
url: url(`admin/plugins/manage?action=enable&name=${name}`),
|
||||
dataType: 'json'
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
$.pluginsTable.ajax.reload(null, false);
|
||||
|
|
@ -26,7 +26,7 @@ async function disablePlugin(name) {
|
|||
url: url(`admin/plugins/manage?action=disable&name=${name}`),
|
||||
dataType: 'json'
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
$.pluginsTable.ajax.reload(null, false);
|
||||
|
|
@ -55,7 +55,7 @@ async function deletePlugin(name) {
|
|||
url: url(`admin/plugins/manage?action=delete&name=${name}`),
|
||||
dataType: 'json'
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
$.pluginsTable.ajax.reload(null, false);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
function initUsersTable() {
|
||||
let uid = getQueryString('uid');
|
||||
let dataUrl = url('admin/user-data') + (uid ? `?uid=${uid}` : '');
|
||||
const uid = getQueryString('uid');
|
||||
const dataUrl = url('admin/user-data') + (uid ? `?uid=${uid}` : '');
|
||||
|
||||
$('#user-table').DataTable({
|
||||
ajax: dataUrl,
|
||||
|
|
@ -127,8 +127,8 @@ function initUsersTable() {
|
|||
}
|
||||
|
||||
function initPlayersTable() {
|
||||
let uid = getQueryString('uid');
|
||||
let dataUrl = url('admin/player-data') + (uid ? `?uid=${uid}` : '');
|
||||
const uid = getQueryString('uid');
|
||||
const dataUrl = url('admin/player-data') + (uid ? `?uid=${uid}` : '');
|
||||
|
||||
$('#player-table').DataTable({
|
||||
ajax: dataUrl,
|
||||
|
|
@ -159,8 +159,8 @@ function initPlayersTable() {
|
|||
render: data => {
|
||||
return `
|
||||
<select class="form-control" onchange="changePreference.call(this)">
|
||||
<option ${(data == 'default') ? 'selected=selected' : ''} value="default">Default</option>
|
||||
<option ${(data == 'slim') ? 'selected=selected' : ''} value="slim">Slim</option>
|
||||
<option ${(data === 'default') ? 'selected=selected' : ''} value="default">Default</option>
|
||||
<option ${(data === 'slim') ? 'selected=selected' : ''} value="slim">Slim</option>
|
||||
</select>`;
|
||||
}
|
||||
},
|
||||
|
|
@ -169,7 +169,7 @@ function initPlayersTable() {
|
|||
searchable: false,
|
||||
orderable: false,
|
||||
render: (data, type, row) => {
|
||||
let html = { steve: '', alex: '', cape: '' };
|
||||
const html = { steve: '', alex: '', cape: '' };
|
||||
['steve', 'alex', 'cape'].forEach(textureType => {
|
||||
if (row['tid_' + textureType] === 0) {
|
||||
html[textureType] = `<img id="${row.pid}-${row['tid_' + textureType]}" width="64" />`;
|
||||
|
|
@ -247,7 +247,7 @@ function initPluginsTable() {
|
|||
searchable: false,
|
||||
orderable: false,
|
||||
render: (data, type, row) => {
|
||||
let switchEnableButton, configViewButton, deletePluginButton;
|
||||
let switchEnableButton, configViewButton;
|
||||
if (data.enabled) {
|
||||
switchEnableButton = `
|
||||
<a class="btn btn-warning btn-sm" style="cursor: pointer" onclick="disablePlugin('${row.name}');">${trans('admin.disablePlugin')}</a>`;
|
||||
|
|
@ -262,7 +262,7 @@ function initPluginsTable() {
|
|||
configViewButton = `
|
||||
<a class="btn btn-default btn-sm" disabled="disabled" title="${trans('admin.noPluginConfigNotice')}" data-toggle="tooltip" data-placement="top">${trans('admin.configurePlugin')}</a>`;
|
||||
}
|
||||
deletePluginButton = `
|
||||
const deletePluginButton = `
|
||||
<a class="btn btn-danger btn-sm" style="cursor: pointer" onclick="deletePlugin('${row.name}');">${trans('admin.deletePlugin')}</a>`;
|
||||
return switchEnableButton + configViewButton + deletePluginButton;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ function progressPolling(fileSize) {
|
|||
async function checkForUpdates() {
|
||||
try {
|
||||
const data = await fetch({ url: url('admin/update/check') });
|
||||
if (data.available == true) {
|
||||
let dom = `<span class="label label-primary pull-right">v${data.latest}</span>`;
|
||||
if (data.available === true) {
|
||||
const dom = `<span class="label label-primary pull-right">v${data.latest}</span>`;
|
||||
|
||||
$(`[href="${url('admin/update')}"]`).append(dom);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
async function changeUserEmail(uid) {
|
||||
let dom = $(`tr#user-${uid} > td:nth-child(2)`),
|
||||
newUserEmail = '';
|
||||
const dom = $(`tr#user-${uid} > td:nth-child(2)`);
|
||||
let newUserEmail = '';
|
||||
|
||||
try {
|
||||
newUserEmail = await swal({
|
||||
|
|
@ -26,7 +26,7 @@ async function changeUserEmail(uid) {
|
|||
data: { uid: uid, email: newUserEmail }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
dom.text(newUserEmail);
|
||||
|
||||
toastr.success(msg);
|
||||
|
|
@ -39,8 +39,8 @@ async function changeUserEmail(uid) {
|
|||
}
|
||||
|
||||
async function changeUserNickName(uid) {
|
||||
let dom = $(`tr#user-${uid} > td:nth-child(3)`),
|
||||
newNickName = '';
|
||||
const dom = $(`tr#user-${uid} > td:nth-child(3)`);
|
||||
let newNickName = '';
|
||||
|
||||
try {
|
||||
newNickName = await swal({
|
||||
|
|
@ -63,7 +63,7 @@ async function changeUserNickName(uid) {
|
|||
dataType: 'json',
|
||||
data: { uid: uid, nickname: newNickName }
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
dom.text(newNickName);
|
||||
|
||||
toastr.success(msg);
|
||||
|
|
@ -94,7 +94,7 @@ async function changeUserPwd(uid) {
|
|||
dataType: 'json',
|
||||
data: { uid: uid, password: password }
|
||||
});
|
||||
errno == 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
errno === 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ async function changeUserScore(uid, score) {
|
|||
// Handle id formatted as '#user-1234'
|
||||
data: { uid: uid.slice(5), score: score }
|
||||
});
|
||||
errno == 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
errno === 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
|
|
@ -124,17 +124,17 @@ async function changeBanStatus(uid) {
|
|||
data: { uid: uid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
let dom = $(`#ban-${uid}`);
|
||||
if (errno === 0) {
|
||||
const dom = $(`#ban-${uid}`);
|
||||
|
||||
if (dom.attr('data') == 'banned') {
|
||||
if (dom.attr('data') === 'banned') {
|
||||
dom.text(trans('admin.ban')).attr('data', 'normal');
|
||||
} else {
|
||||
dom.text(trans('admin.unban')).attr('data', 'banned');
|
||||
}
|
||||
|
||||
$(`#user-${uid} > td.status`).text(
|
||||
permission == -1 ? trans('admin.banned') : trans('admin.normal')
|
||||
permission === -1 ? trans('admin.banned') : trans('admin.normal')
|
||||
);
|
||||
|
||||
toastr.success(msg);
|
||||
|
|
@ -155,17 +155,17 @@ async function changeAdminStatus(uid) {
|
|||
data: { uid: uid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
let dom = $(`#admin-${uid}`);
|
||||
if (errno === 0) {
|
||||
const dom = $(`#admin-${uid}`);
|
||||
|
||||
if (dom.attr('data') == 'admin') {
|
||||
if (dom.attr('data') === 'admin') {
|
||||
dom.text(trans('admin.setAdmin')).attr('data', 'normal');
|
||||
} else {
|
||||
dom.text(trans('admin.unsetAdmin')).attr('data', 'admin');
|
||||
}
|
||||
|
||||
$(`#user-${uid} > td.status`).text(
|
||||
(permission == 1) ? trans('admin.admin') : trans('admin.normal')
|
||||
(permission === 1) ? trans('admin.admin') : trans('admin.normal')
|
||||
);
|
||||
|
||||
toastr.success(msg);
|
||||
|
|
@ -196,7 +196,7 @@ async function deleteUserAccount(uid) {
|
|||
data: { uid: uid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
$('tr#user-' + uid).remove();
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
|
|
@ -209,7 +209,7 @@ async function deleteUserAccount(uid) {
|
|||
|
||||
$('body').on('keypress', '.score', function(event){
|
||||
// Change score when Enter key is pressed
|
||||
if (event.which == 13) {
|
||||
if (event.which === 13) {
|
||||
$(this).blur();
|
||||
changeUserScore($(this).parent().parent().attr('id'), $(this).val());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
function refreshCaptcha() {
|
||||
let timestamp = new Date().getTime();
|
||||
const timestamp = new Date().getTime();
|
||||
// Refresh Captcha Image
|
||||
$('.captcha').attr('src', url(`auth/captcha?${timestamp}`));
|
||||
// Clear input
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
$('#forgot-button').click(e => {
|
||||
e.preventDefault();
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
email: $('#email').val(),
|
||||
captcha: $('#captcha').val()
|
||||
};
|
||||
|
||||
(function validate({ email, captcha }, callback) {
|
||||
if (email == '') {
|
||||
if (email === '') {
|
||||
showMsg(trans('auth.emptyEmail'));
|
||||
$('#email').focus();
|
||||
} else if (!/\S+@\S+\.\S+/.test(email)) {
|
||||
showMsg(trans('auth.invalidEmail'), 'warning');
|
||||
} else if (captcha == '') {
|
||||
} else if (captcha === '') {
|
||||
showMsg(trans('auth.emptyCaptcha'));
|
||||
$('#captcha').focus();
|
||||
} else {
|
||||
|
|
@ -35,7 +35,7 @@ $('#forgot-button').click(e => {
|
|||
).prop('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
showMsg(msg, 'success');
|
||||
$('#forgot-button').html(trans('auth.send')).prop('disabled', 'disabled');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@
|
|||
$('#login-button').click(async e => {
|
||||
e.preventDefault();
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
identification: $('#identification').val(),
|
||||
password: $('#password').val(),
|
||||
keep: $('#keep').prop('checked') ? true : false
|
||||
};
|
||||
|
||||
if (data.identification == '') {
|
||||
if (data.identification === '') {
|
||||
showMsg(trans('auth.emptyIdentification'));
|
||||
$('#identification').focus();
|
||||
} else if (data.password == '') {
|
||||
} else if (data.password === '') {
|
||||
showMsg(trans('auth.emptyPassword'));
|
||||
$('#password').focus();
|
||||
} else {
|
||||
// Verify it when captcha form is shown
|
||||
if ($('#captcha-form').css('display') == 'block') {
|
||||
if ($('#captcha-form').css('display') === 'block') {
|
||||
data.captcha = $('#captcha').val();
|
||||
|
||||
if (data.captcha == '') {
|
||||
if (data.captcha === '') {
|
||||
showMsg(trans('auth.emptyCaptcha'));
|
||||
$('#captcha').focus();
|
||||
return false;
|
||||
|
|
@ -41,7 +41,7 @@ $('#login-button').click(async e => {
|
|||
).prop('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
@ -49,7 +49,7 @@ $('#login-button').click(async e => {
|
|||
}, 1000);
|
||||
} else {
|
||||
if (login_fails > 3) {
|
||||
if ($('#captcha-form').css('display') == 'none') {
|
||||
if ($('#captcha-form').css('display') === 'none') {
|
||||
swal({ type: 'error', html: trans('auth.tooManyFails') });
|
||||
|
||||
$('#captcha-form').show();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
$('#register-button').click(e => {
|
||||
e.preventDefault();
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
email: $('#email').val(),
|
||||
password: $('#password').val(),
|
||||
nickname: $('#nickname').val(),
|
||||
|
|
@ -15,27 +15,27 @@ $('#register-button').click(e => {
|
|||
|
||||
(function validate({ email, password, nickname, captcha }, callback) {
|
||||
// Massive form validation
|
||||
if (email == '') {
|
||||
if (email === '') {
|
||||
showMsg(trans('auth.emptyEmail'));
|
||||
$('#email').focus();
|
||||
} else if (!/\S+@\S+\.\S+/.test(email)) {
|
||||
showMsg(trans('auth.invalidEmail'), 'warning');
|
||||
} else if (password == '') {
|
||||
} else if (password === '') {
|
||||
showMsg(trans('auth.emptyPassword'));
|
||||
$('#password').focus();
|
||||
} else if (password.length < 8 || password.length > 16) {
|
||||
showMsg(trans('auth.invalidPassword'), 'warning');
|
||||
$('#password').focus();
|
||||
} else if ($('#confirm-pwd').val() == '') {
|
||||
} else if ($('#confirm-pwd').val() === '') {
|
||||
showMsg(trans('auth.emptyConfirmPwd'));
|
||||
$('#confirm-pwd').focus();
|
||||
} else if (password != $('#confirm-pwd').val()) {
|
||||
} else if (password !== $('#confirm-pwd').val()) {
|
||||
showMsg(trans('auth.invalidConfirmPwd'), 'warning');
|
||||
$('#confirm-pwd').focus();
|
||||
} else if (nickname == '') {
|
||||
} else if (nickname === '') {
|
||||
showMsg(trans('auth.emptyNickname'));
|
||||
$('#nickname').focus();
|
||||
} else if (captcha == '') {
|
||||
} else if (captcha === '') {
|
||||
showMsg(trans('auth.emptyCaptcha'));
|
||||
$('#captcha').focus();
|
||||
} else {
|
||||
|
|
@ -56,7 +56,7 @@ $('#register-button').click(e => {
|
|||
).prop('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg })
|
||||
.then(() => window.location = url('user'));
|
||||
|
||||
|
|
|
|||
|
|
@ -3,23 +3,23 @@
|
|||
$('#reset-button').click(e => {
|
||||
e.preventDefault();
|
||||
|
||||
let data = {
|
||||
const data = {
|
||||
uid: $('#uid').val(),
|
||||
password: $('#password').val(),
|
||||
token: getQueryString('token')
|
||||
};
|
||||
|
||||
(function validate({ password }, callback) {
|
||||
if (password == '') {
|
||||
if (password === '') {
|
||||
showMsg(trans('auth.emptyPassword'));
|
||||
$('#password').focus();
|
||||
} else if (password.length < 8 || password.length > 16) {
|
||||
showMsg(trans('auth.invalidPassword'), 'warning');
|
||||
$('#password').focus();
|
||||
} else if ($('#confirm-pwd').val() == '') {
|
||||
} else if ($('#confirm-pwd').val() === '') {
|
||||
showMsg(trans('auth.emptyConfirmPwd'));
|
||||
$('#confirm-pwd').focus();
|
||||
} else if (password != $('#confirm-pwd').val()) {
|
||||
} else if (password !== $('#confirm-pwd').val()) {
|
||||
showMsg(trans('auth.invalidConfirmPwd'), 'warning');
|
||||
$('#confirm-pwd').focus();
|
||||
} else {
|
||||
|
|
@ -38,7 +38,7 @@ $('#reset-button').click(e => {
|
|||
).prop('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({
|
||||
type: 'success',
|
||||
html: msg
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ $.currentLocale = Object.create(null);
|
|||
* @return void
|
||||
*/
|
||||
function loadLocales() {
|
||||
for (let lang in $.locales) {
|
||||
for (const lang in $.locales) {
|
||||
if (!isEmpty($.locales[lang])) {
|
||||
$.currentLocale = $.locales[lang] || Object.create(null);
|
||||
}
|
||||
|
|
@ -28,10 +28,10 @@ function trans(key, parameters = {}) {
|
|||
loadLocales();
|
||||
}
|
||||
|
||||
let segments = key.split('.');
|
||||
const segments = key.split('.');
|
||||
let temp = $.currentLocale || {};
|
||||
|
||||
for (let i in segments) {
|
||||
for (const i in segments) {
|
||||
if (isEmpty(temp[segments[i]])) {
|
||||
return key;
|
||||
} else {
|
||||
|
|
@ -39,7 +39,7 @@ function trans(key, parameters = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
for (let i in parameters) {
|
||||
for (const i in parameters) {
|
||||
if (!isEmpty(parameters[i])) {
|
||||
temp = temp.replace(':'+i, parameters[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ $(document).ready(() => {
|
|||
});
|
||||
|
||||
function activateLayout() {
|
||||
if (location.pathname == '/' || location.pathname.includes('auth'))
|
||||
if (location.pathname === '/' || location.pathname.includes('auth'))
|
||||
return;
|
||||
|
||||
$.AdminLTE.layout.activate();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function showMsg(msg, type = 'info') {
|
|||
* @return {void}
|
||||
*/
|
||||
function showAjaxError(json) {
|
||||
if (typeof json == 'string') {
|
||||
if (typeof json === 'string') {
|
||||
return console.warn(json);
|
||||
}
|
||||
|
||||
|
|
@ -39,12 +39,12 @@ function showAjaxError(json) {
|
|||
* @return {void}
|
||||
*/
|
||||
function showModal(msg, title = 'Message', type = 'default', options = {}) {
|
||||
let btnType = (type != 'default') ? 'btn-outline' : 'btn-primary';
|
||||
let btnText = options.btnText || 'OK';
|
||||
let onClick = (options.callback === undefined) ? 'data-dismiss="modal"' : `onclick="${options.callback}"`;
|
||||
let destroyOnClose = (options.destroyOnClose === false) ? false : true;
|
||||
const btnType = (type !== 'default') ? 'btn-outline' : 'btn-primary';
|
||||
const btnText = options.btnText || 'OK';
|
||||
const onClick = (options.callback === undefined) ? 'data-dismiss="modal"' : `onclick="${options.callback}"`;
|
||||
const destroyOnClose = (options.destroyOnClose === false) ? false : true;
|
||||
|
||||
let dom = `
|
||||
const dom = `
|
||||
<div class="modal modal-${type} fade in">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ if (!String.prototype.includes) {
|
|||
// polyfill of String.prototype.endsWith
|
||||
if (!String.prototype.endsWith) {
|
||||
String.prototype.endsWith = function (searchString, position) {
|
||||
var subjectString = this.toString();
|
||||
const subjectString = this.toString();
|
||||
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.lastIndexOf(searchString, position);
|
||||
const lastIndex = subjectString.lastIndexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TexturePreview {
|
|||
/**
|
||||
* @type {'default'|'slim'}
|
||||
*/
|
||||
this.preference = (type == 'steve') ? 'default' : 'slim';
|
||||
this.preference = (type === 'steve') ? 'default' : 'slim';
|
||||
this.playerPreference = preference;
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ class TexturePreview {
|
|||
}
|
||||
|
||||
async change3dPreview() {
|
||||
if (this.playerPreference == this.preference || this.type == 'cape') {
|
||||
if (this.playerPreference === this.preference || this.type === 'cape') {
|
||||
try {
|
||||
const { hash } = await fetch({
|
||||
type: 'GET',
|
||||
|
|
@ -41,9 +41,9 @@ class TexturePreview {
|
|||
dataType: 'json'
|
||||
});
|
||||
|
||||
let textureUrl = url(`textures/${hash}`);
|
||||
const textureUrl = url(`textures/${hash}`);
|
||||
|
||||
if (this.type == 'cape') {
|
||||
if (this.type === 'cape') {
|
||||
MSP.changeCape(textureUrl);
|
||||
} else {
|
||||
MSP.changeSkin(textureUrl);
|
||||
|
|
@ -60,7 +60,7 @@ class TexturePreview {
|
|||
this.selector.hide().parent().next().show();
|
||||
|
||||
// clear 3D preview of cape
|
||||
if (this.type == 'cape') {
|
||||
if (this.type === 'cape') {
|
||||
MSP.changeCape('');
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class TexturePreview {
|
|||
}
|
||||
|
||||
static init3dPreview() {
|
||||
if (TexturePreview.previewType == '2D') return;
|
||||
if (TexturePreview.previewType === '2D') return;
|
||||
|
||||
$('#preview-2d').hide();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ console.log(`\n %c Blessing Skin v${blessing.version} %c https://blessing.studio
|
|||
function isEmpty(obj) {
|
||||
|
||||
// null and undefined are "empty"
|
||||
if (obj == null) return true;
|
||||
if (obj == null) return true; // eslint-disable-line eqeqeq
|
||||
|
||||
if (typeof (obj) == 'number' || typeof (obj) == 'boolean') return false;
|
||||
if (typeof (obj) === 'number' || typeof (obj) === 'boolean') return false;
|
||||
|
||||
// Assume if it has a length property with a non-zero value
|
||||
// that that property is correct.
|
||||
|
|
@ -28,7 +28,7 @@ function isEmpty(obj) {
|
|||
// Otherwise, does it have any properties of its own?
|
||||
// Note that this doesn't handle
|
||||
// toString and valueOf enumeration bugs in IE < 9
|
||||
for (var key in obj) {
|
||||
for (const key in obj) {
|
||||
if (hasOwnProperty.call(obj, key)) return false;
|
||||
}
|
||||
|
||||
|
|
@ -53,9 +53,9 @@ function fetch(option) {
|
|||
* @return {string}
|
||||
*/
|
||||
function getQueryString(key, defaultValue) {
|
||||
let result = location.search.match(new RegExp('[?&]'+key+'=([^&]+)','i'));
|
||||
const result = location.search.match(new RegExp('[?&]'+key+'=([^&]+)','i'));
|
||||
|
||||
if (result == null || result.length < 1){
|
||||
if (result === null || result.length < 1){
|
||||
return defaultValue;
|
||||
} else {
|
||||
return result[1];
|
||||
|
|
@ -69,8 +69,8 @@ function getQueryString(key, defaultValue) {
|
|||
* @return {Boolean}
|
||||
*/
|
||||
function isMobileBrowserScrolling() {
|
||||
let currentWindowWidth = $(window).width();
|
||||
let currentWindowHeight = $(window).height();
|
||||
const currentWindowWidth = $(window).width();
|
||||
const currentWindowHeight = $(window).height();
|
||||
|
||||
if ($.cachedWindowWidth === undefined) {
|
||||
$.cachedWindowWidth = currentWindowWidth;
|
||||
|
|
@ -80,8 +80,8 @@ function isMobileBrowserScrolling() {
|
|||
$.cachedWindowHeight = currentWindowHeight;
|
||||
}
|
||||
|
||||
let isWidthChanged = (currentWindowWidth !== $.cachedWindowWidth);
|
||||
let isHeightChanged = (currentWindowHeight !== $.cachedWindowHeight);
|
||||
const isWidthChanged = (currentWindowWidth !== $.cachedWindowWidth);
|
||||
const isHeightChanged = (currentWindowHeight !== $.cachedWindowHeight);
|
||||
|
||||
// If the window width & height changes simultaneously, the resize can't be fired by scrolling.
|
||||
if (isWidthChanged && isHeightChanged) {
|
||||
|
|
@ -95,10 +95,10 @@ function isMobileBrowserScrolling() {
|
|||
|
||||
// If width didn't change but height changed ?
|
||||
if (isHeightChanged) {
|
||||
let last = $.lastWindowHeight;
|
||||
const last = $.lastWindowHeight;
|
||||
$.lastWindowHeight = currentWindowHeight;
|
||||
|
||||
if (last === undefined || currentWindowHeight == last) {
|
||||
if (last === undefined || currentWindowHeight === last) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ function debounce(func, delay, args = [], context = undefined) {
|
|||
function url(relativeUri = '') {
|
||||
blessing.base_url = blessing.base_url || '';
|
||||
|
||||
if (relativeUri[0] != '/') {
|
||||
if (relativeUri[0] !== '/') {
|
||||
relativeUri = '/' + relativeUri;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ $('body').on('submit', '#search-form', function (e) {
|
|||
});
|
||||
|
||||
function initSkinlib() {
|
||||
if ($('#skinlib-container').length != 0) {
|
||||
if ($('#skinlib-container').length !== 0) {
|
||||
// Initially render skinlib
|
||||
requestSkinlibData().then(result => {
|
||||
renderSkinlib(result.items);
|
||||
|
|
@ -47,7 +47,7 @@ function initSkinlib() {
|
|||
}
|
||||
|
||||
function renderSkinlib(items) {
|
||||
let container = $('#skinlib-container').html('');
|
||||
const container = $('#skinlib-container').html('');
|
||||
|
||||
if (items.length === 0) {
|
||||
$('#skinlib-paginator').hide();
|
||||
|
|
@ -95,7 +95,7 @@ function requestSkinlibData() {
|
|||
function renderSkinlibItemComponent(item) {
|
||||
let title = '';
|
||||
let anonymous = '';
|
||||
let liked = item.liked ? 'liked' : '';
|
||||
const liked = item.liked ? 'liked' : '';
|
||||
|
||||
if (item.liked === undefined) {
|
||||
// If user haven't logged in
|
||||
|
|
@ -120,7 +120,7 @@ function renderSkinlibItemComponent(item) {
|
|||
|
||||
<a title="${title}" class="more like ${liked} ${anonymous}" tid="${ item.tid }" href="javascript:;" data-placement="top" data-toggle="tooltip"><i class="fa fa-heart"></i></a>
|
||||
|
||||
<small class="more private-label ${(item.public == 0) ? '' : 'hide'}" tid="${ item.tid }">
|
||||
<small class="more private-label ${(item.public === 0) ? '' : 'hide'}" tid="${ item.tid }">
|
||||
${ trans('skinlib.private') }
|
||||
</small>
|
||||
</div>
|
||||
|
|
@ -136,9 +136,9 @@ function updatePaginator(currentPage, totalPages) {
|
|||
total: totalPages
|
||||
}));
|
||||
|
||||
let paginator = $('#skinlib-paginator');
|
||||
const paginator = $('#skinlib-paginator');
|
||||
|
||||
if (paginator.html().length == 0) {
|
||||
if (paginator.html().length === 0) {
|
||||
// init paginator
|
||||
$('#skinlib-paginator').jqPaginator($.extend({}, $.defaultPaginatorConfig, {
|
||||
currentPage: parseInt(currentPage),
|
||||
|
|
@ -152,20 +152,20 @@ function updatePaginator(currentPage, totalPages) {
|
|||
});
|
||||
}
|
||||
|
||||
let pageSelectElement = $('select.pagination').html('');
|
||||
const pageSelectElement = $('select.pagination').html('');
|
||||
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
pageSelectElement.append(`
|
||||
<option value="${i}" ${ (i == currentPage) ? 'selected' : '' }>${i}</option>
|
||||
<option value="${i}" ${ (i === currentPage) ? 'selected' : '' }>${i}</option>
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
function updateFilter(e) {
|
||||
e.preventDefault();
|
||||
let selectedFilter = $(this).data('filter');
|
||||
const selectedFilter = $(this).data('filter');
|
||||
|
||||
if (selectedFilter == 'uploader') {
|
||||
if (selectedFilter === 'uploader') {
|
||||
$.skinlib.uploader = $(this).data('uid');
|
||||
console.log('Show items uploaded by uid ' + $.skinlib.uploader);
|
||||
} else {
|
||||
|
|
@ -180,7 +180,7 @@ function onPageChange(page, type) {
|
|||
$.skinlib.page = page;
|
||||
updateBreadCrumb();
|
||||
|
||||
if (type == 'init') {
|
||||
if (type === 'init') {
|
||||
console.log('Init paginator', page);
|
||||
} else {
|
||||
$('.overlay').show();
|
||||
|
|
@ -191,7 +191,7 @@ function onPageChange(page, type) {
|
|||
}
|
||||
|
||||
function updateUrlQueryString() {
|
||||
let query = $.param($.skinlib);
|
||||
const query = $.param($.skinlib);
|
||||
|
||||
window.history.pushState(null, null, url(`skinlib?${ query }`));
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ function updateUrlQueryString() {
|
|||
}
|
||||
|
||||
function updateBreadCrumb() {
|
||||
if ($.skinlib.filter == 'cape') {
|
||||
if ($.skinlib.filter === 'cape') {
|
||||
$('#filter-indicator').html(trans('general.cape'));
|
||||
} else {
|
||||
$('#filter-indicator').html(trans('general.skin') + `<small>
|
||||
|
|
@ -209,7 +209,7 @@ function updateBreadCrumb() {
|
|||
</small>`);
|
||||
}
|
||||
|
||||
if ($.skinlib.uploader != 0) {
|
||||
if ($.skinlib.uploader !== 0) {
|
||||
$('#uploader-indicator').html(trans('skinlib.filter.uploader', { uid: $.skinlib.uploader }));
|
||||
} else {
|
||||
$('#uploader-indicator').html(trans('skinlib.filter.allUsers'));
|
||||
|
|
@ -217,7 +217,7 @@ function updateBreadCrumb() {
|
|||
|
||||
$('#sort-indicator').html(trans('skinlib.sort.' + $.skinlib.sort));
|
||||
|
||||
if ($.skinlib.keyword != '') {
|
||||
if ($.skinlib.keyword !== '') {
|
||||
$('#search-indicator').text(trans('general.searchResult', {
|
||||
keyword: decodeURI($.skinlib.keyword)
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
$(document).on('click', '.more.like', toggleLiked);
|
||||
|
||||
function toggleLiked() {
|
||||
let tid = $(this).attr('tid');
|
||||
const tid = $(this).attr('tid');
|
||||
|
||||
if ($(this).hasClass('anonymous'))
|
||||
return;
|
||||
|
|
@ -37,7 +37,7 @@ function addToCloset(tid) {
|
|||
async function ajaxAddToCloset(tid, name) {
|
||||
// Remove interference of modal which is hide
|
||||
$('.modal').each(function () {
|
||||
return ($(this).css('display') == 'none') ? $(this).remove() : null;
|
||||
return ($(this).css('display') === 'none') ? $(this).remove() : null;
|
||||
});
|
||||
|
||||
try {
|
||||
|
|
@ -48,7 +48,7 @@ async function ajaxAddToCloset(tid, name) {
|
|||
data: { tid: tid, name: name }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
$('.modal').modal('hide');
|
||||
|
|
@ -82,7 +82,7 @@ async function removeFromCloset(tid) {
|
|||
data: { tid: tid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
updateTextureStatus(tid, 'remove');
|
||||
|
|
@ -119,7 +119,7 @@ async function changeTextureName(tid, oldName) {
|
|||
data: { tid: tid, new_name: newTextureName }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
$('#name').text(newTextureName);
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
|
|
@ -138,8 +138,8 @@ async function changeTextureName(tid, oldName) {
|
|||
* @return {null}
|
||||
*/
|
||||
function updateTextureStatus(tid, action) {
|
||||
let likes = parseInt($('#likes').html()) + (action == 'add' ? 1 : -1);
|
||||
action = (action == 'add') ? 'removeFromCloset' : 'addToCloset';
|
||||
const likes = parseInt($('#likes').html()) + (action === 'add' ? 1 : -1);
|
||||
action = (action === 'add') ? 'removeFromCloset' : 'addToCloset';
|
||||
|
||||
$(`a[tid=${tid}]`)
|
||||
.attr('href', `javascript:${action}(${tid});`)
|
||||
|
|
@ -176,10 +176,10 @@ async function changePrivacy(tid) {
|
|||
});
|
||||
const { errno, msg } = result;
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
if (result.public == '0') {
|
||||
if (result.public === '0') {
|
||||
$(`a:contains("${trans('skinlib.setAsPrivate')}")`).html(trans('skinlib.setAsPublic'));
|
||||
} else {
|
||||
$(`a:contains("${trans('skinlib.setAsPublic')}")`).html(trans('skinlib.setAsPrivate'));
|
||||
|
|
@ -211,7 +211,7 @@ async function deleteTexture(tid) {
|
|||
data: { tid: tid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
await swal({ type: 'success', html: msg });
|
||||
window.location = url('skinlib');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ function handleFiles(files, type) {
|
|||
type = type || $('#type-cape').prop('checked') ? 'cape' : 'skin';
|
||||
|
||||
if (files.length > 0) {
|
||||
let file = files[0];
|
||||
const file = files[0];
|
||||
|
||||
if (file.type === 'image/png' || file.type === 'image/x-png') {
|
||||
let reader = new FileReader();
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function () {
|
||||
let img = new Image();
|
||||
const img = new Image();
|
||||
|
||||
img.onload = () => {
|
||||
let $name = $('#name');
|
||||
const $name = $('#name');
|
||||
|
||||
(type == 'skin') ? MSP.changeSkin(img.src) : MSP.changeCape(img.src);
|
||||
(type === 'skin') ? MSP.changeSkin(img.src) : MSP.changeCape(img.src);
|
||||
|
||||
if ($name.val() === '' || $name.val() === $name.attr('data-last-file-name')) {
|
||||
// Remove png extension in filename
|
||||
|
|
@ -59,8 +59,8 @@ function handleFiles(files, type) {
|
|||
}
|
||||
|
||||
function upload() {
|
||||
let form = new FormData();
|
||||
let file = $('#file').prop('files')[0];
|
||||
const form = new FormData();
|
||||
const file = $('#file').prop('files')[0];
|
||||
|
||||
form.append('name', $('#name').val());
|
||||
form.append('file', file);
|
||||
|
|
@ -78,7 +78,7 @@ function upload() {
|
|||
if (file === undefined) {
|
||||
toastr.info(trans('skinlib.emptyUploadFile'));
|
||||
$('#file').focus();
|
||||
} else if ($('#name').val() == '') {
|
||||
} else if ($('#name').val() === '') {
|
||||
toastr.info(trans('skinlib.emptyTextureName'));
|
||||
$('#name').focus();
|
||||
} else if (file.type !== 'image/png') {
|
||||
|
|
@ -103,8 +103,8 @@ function upload() {
|
|||
}
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
let redirect = function () {
|
||||
if (errno === 0) {
|
||||
const redirect = function () {
|
||||
toastr.info(trans('skinlib.redirecting'));
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ $(document).ready(initCloset);
|
|||
|
||||
$('body').on('click', '.item-body', async function () {
|
||||
$('.item-selected').parent().removeClass('item-selected');
|
||||
let $item = $(this).parent();
|
||||
const $item = $(this).parent();
|
||||
const $indicator = $('#textures-indicator');
|
||||
|
||||
$item.addClass('item-selected');
|
||||
|
||||
let tid = parseInt($item.attr('tid'));
|
||||
const tid = parseInt($item.attr('tid'));
|
||||
|
||||
try {
|
||||
const { type, hash } = await fetch({
|
||||
|
|
@ -20,7 +20,7 @@ $('body').on('click', '.item-body', async function () {
|
|||
dataType: 'json'
|
||||
});
|
||||
|
||||
if (type == 'cape') {
|
||||
if (type === 'cape') {
|
||||
MSP.changeCape(url(`textures/${hash}`));
|
||||
$indicator.data('cape', tid);
|
||||
} else {
|
||||
|
|
@ -33,9 +33,9 @@ $('body').on('click', '.item-body', async function () {
|
|||
|
||||
if (skin !== undefined && cape !== undefined) {
|
||||
$indicator.text(`${trans('general.skin')} & ${trans('general.cape')}`);
|
||||
} else if (skin != undefined) {
|
||||
} else if (skin) {
|
||||
$indicator.text(trans('general.skin'));
|
||||
} else if (cape != undefined) {
|
||||
} else if (cape) {
|
||||
$indicator.text(trans('general.cape'));
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -44,9 +44,9 @@ $('body').on('click', '.item-body', async function () {
|
|||
});
|
||||
|
||||
$('body').on('click', '.category-switch', () => {
|
||||
let category = $('a[href="#skin-category"]').parent().hasClass('active') ? 'cape' : 'skin';
|
||||
let search = $('input[name=q]').val();
|
||||
let page = parseInt($('#closet-paginator').attr(`last-${category}-page`));
|
||||
const category = $('a[href="#skin-category"]').parent().hasClass('active') ? 'cape' : 'skin';
|
||||
const search = $('input[name=q]').val();
|
||||
const page = parseInt($('#closet-paginator').attr(`last-${category}-page`));
|
||||
|
||||
reloadCloset(category, page, search);
|
||||
});
|
||||
|
|
@ -56,7 +56,7 @@ async function initCloset() {
|
|||
return;
|
||||
|
||||
$('input[name=q]').on('input', debounce(() => {
|
||||
let category = $('#skin-category').hasClass('active') ? 'skin' : 'cape';
|
||||
const category = $('#skin-category').hasClass('active') ? 'skin' : 'cape';
|
||||
reloadCloset(category, 1, $('input[name=q]').val());
|
||||
}, 350));
|
||||
|
||||
|
|
@ -115,8 +115,8 @@ function renderClosetItemComponent(item) {
|
|||
* @param {'skin' | 'cape'} category
|
||||
*/
|
||||
function renderCloset(items, category) {
|
||||
let search = $('input[name=q]').val();
|
||||
let container = $(`#${category}-category`).html('');
|
||||
const search = $('input[name=q]').val();
|
||||
const container = $(`#${category}-category`).html('');
|
||||
|
||||
if (items.length === 0) {
|
||||
$('#closet-paginator').hide();
|
||||
|
|
@ -159,7 +159,7 @@ async function reloadCloset(textureCategory, page, search) {
|
|||
|
||||
renderCloset(items, category);
|
||||
|
||||
let paginator = $('#closet-paginator');
|
||||
const paginator = $('#closet-paginator');
|
||||
|
||||
paginator.attr(`last-${category}-page`, page);
|
||||
paginator.jqPaginator('option', {
|
||||
|
|
@ -208,7 +208,7 @@ async function renameClosetItem(tid, oldName) {
|
|||
data: { tid: tid, new_name: newTextureName }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
const type = $(`[tid=${tid}]`).data('texture-type');
|
||||
$(`[tid=${tid}]>.item-footer>.texture-name>span`).html(
|
||||
newTextureName +
|
||||
|
|
@ -242,16 +242,16 @@ async function removeFromCloset(tid) {
|
|||
data: { tid: tid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
$(`div[tid=${tid}]`).remove();
|
||||
|
||||
['skin', 'cape'].forEach(type => {
|
||||
let container = $(`#${type}-category`);
|
||||
const container = $(`#${type}-category`);
|
||||
|
||||
if ($.trim(container.html()) == '') {
|
||||
let msg = trans('user.emptyClosetMsg', { url: url(`skinlib?filter=${type}`) });
|
||||
if ($.trim(container.html()) === '') {
|
||||
const msg = trans('user.emptyClosetMsg', { url: url(`skinlib?filter=${type}`) });
|
||||
container.html(`<div class="empty-msg">${msg}</div>`);
|
||||
}
|
||||
});
|
||||
|
|
@ -283,7 +283,7 @@ async function setAsAvatar(tid) {
|
|||
data: { tid: tid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
toastr.success(msg);
|
||||
|
||||
// Refersh avatars
|
||||
|
|
@ -300,9 +300,9 @@ async function setAsAvatar(tid) {
|
|||
|
||||
async function setTexture() {
|
||||
const $indicator = $('#textures-indicator');
|
||||
let pid = 0,
|
||||
skin = $indicator.data('skin'),
|
||||
cape = $indicator.data('cape');
|
||||
let pid = 0;
|
||||
const skin = $indicator.data('skin'),
|
||||
cape = $indicator.data('cape');
|
||||
|
||||
$('input[name="player"]').each(function(){
|
||||
if (this.checked) pid = this.id;
|
||||
|
|
@ -310,7 +310,7 @@ async function setTexture() {
|
|||
|
||||
if (! pid) {
|
||||
toastr.info(trans('user.emptySelectedPlayer'));
|
||||
} else if (skin == undefined && cape == undefined) {
|
||||
} else if (!skin && !cape) {
|
||||
toastr.info(trans('user.emptySelectedTexture'));
|
||||
} else {
|
||||
try {
|
||||
|
|
@ -325,7 +325,7 @@ async function setTexture() {
|
|||
}
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
$('#modal-use-as').modal('hide');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ $('body').on('click', '.player', function () {
|
|||
|
||||
showPlayerTexturePreview(this.id);
|
||||
}).on('click', '#preview-switch', () => {
|
||||
TexturePreview.previewType == '3D' ? TexturePreview.show2dPreview() : TexturePreview.show3dPreview();
|
||||
TexturePreview.previewType === '3D' ? TexturePreview.show2dPreview() : TexturePreview.show3dPreview();
|
||||
}).on('change', '#preference', async function () {
|
||||
try {
|
||||
const { errno, msg } = await fetch({
|
||||
|
|
@ -17,7 +17,7 @@ $('body').on('click', '.player', function () {
|
|||
dataType: 'json',
|
||||
data: { pid: $(this).attr('pid'), preference: $(this).val() }
|
||||
});
|
||||
errno == 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
errno === 0 ? toastr.success(msg) : toastr.warning(msg);
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ async function showPlayerTexturePreview(pid) {
|
|||
|
||||
// Render skin preview of selected player
|
||||
['steve', 'alex', 'cape'].forEach((type) => {
|
||||
let tid = result[`tid_${type}`];
|
||||
let preview = new TexturePreview(type, tid, result.preference);
|
||||
const tid = result[`tid_${type}`];
|
||||
const preview = new TexturePreview(type, tid, result.preference);
|
||||
|
||||
if (tid) {
|
||||
preview.change2dPreview().change3dPreview();
|
||||
|
|
@ -44,8 +44,8 @@ async function showPlayerTexturePreview(pid) {
|
|||
}
|
||||
});
|
||||
|
||||
if ((result.preference == 'default' && !result.tid_steve) ||
|
||||
(result.preference == 'slim' && !result.tid_alex))
|
||||
if ((result.preference === 'default' && !result.tid_steve) ||
|
||||
(result.preference === 'slim' && !result.tid_alex))
|
||||
{
|
||||
// show default skin
|
||||
MSP.changeSkin(defaultSkin);
|
||||
|
|
@ -84,7 +84,7 @@ async function changePlayerName(pid) {
|
|||
data: { pid: pid, new_player_name: newPlayerName }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({ type: 'success', html: msg });
|
||||
|
||||
$playerName.html(newPlayerName);
|
||||
|
|
@ -97,7 +97,7 @@ async function changePlayerName(pid) {
|
|||
}
|
||||
|
||||
function clearTexture(pid) {
|
||||
let dom = `<div class="form-group">
|
||||
const dom = `<div class="form-group">
|
||||
<input type="checkbox" id="clear-steve"> Default (Steve)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
@ -117,16 +117,16 @@ function clearTexture(pid) {
|
|||
|
||||
async function ajaxClearTexture(pid) {
|
||||
$('.modal').each(function () {
|
||||
if ($(this).css('display') == 'none') $(this).remove();
|
||||
if ($(this).css('display') === 'none') $(this).remove();
|
||||
});
|
||||
|
||||
let data = { pid: pid };
|
||||
const data = { pid: pid };
|
||||
|
||||
['steve', 'alex', 'cape'].forEach(type => {
|
||||
data[type] = $(`#clear-${type}`).prop('checked') ? 1 : 0;
|
||||
});
|
||||
|
||||
if (data['steve'] == 0 && data['alex'] == 0 && data['cape'] == 0) {
|
||||
if (data['steve'] === 0 && data['alex'] === 0 && data['cape'] === 0) {
|
||||
return toastr.warning(trans('user.noClearChoice'));
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ async function ajaxClearTexture(pid) {
|
|||
dataType: 'json',
|
||||
data: data
|
||||
});
|
||||
swal({ type: errno == 0 ? 'success' : 'error', html: msg });
|
||||
swal({ type: errno === 0 ? 'success' : 'error', html: msg });
|
||||
$('.modal').modal('hide');
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
|
|
@ -166,7 +166,7 @@ async function deletePlayer(pid) {
|
|||
data: { pid: pid }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
await swal({
|
||||
type: 'success',
|
||||
html: msg
|
||||
|
|
@ -189,7 +189,7 @@ async function addNewPlayer() {
|
|||
data: { player_name: $('#player_name').val() }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
swal({
|
||||
type: 'success',
|
||||
html: msg
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
async function changeNickName() {
|
||||
let name = $('#new-nickname').val();
|
||||
const name = $('#new-nickname').val();
|
||||
|
||||
if (! name) {
|
||||
return swal({ type: 'error', html: trans('user.emptyNewNickName') });
|
||||
|
|
@ -25,7 +25,7 @@ async function changeNickName() {
|
|||
data: { new_nickname: name }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
|
||||
$('.nickname').each(function () {
|
||||
$(this).html(name);
|
||||
|
|
@ -41,23 +41,23 @@ async function changeNickName() {
|
|||
}
|
||||
|
||||
async function changePassword() {
|
||||
let $oldPasswd = $('#password'),
|
||||
$newPasswd = $('#new-passwd'),
|
||||
$confirmPwd = $('#confirm-pwd');
|
||||
const $oldPasswd = $('#password'),
|
||||
$newPasswd = $('#new-passwd'),
|
||||
$confirmPwd = $('#confirm-pwd');
|
||||
|
||||
let password = $oldPasswd.val(),
|
||||
newPasswd = $newPasswd.val();
|
||||
const password = $oldPasswd.val(),
|
||||
newPasswd = $newPasswd.val();
|
||||
|
||||
if (password == '') {
|
||||
if (password === '') {
|
||||
toastr.info(trans('user.emptyPassword'));
|
||||
$oldPasswd.focus();
|
||||
} else if (newPasswd == '') {
|
||||
} else if (newPasswd === '') {
|
||||
toastr.info(trans('user.emptyNewPassword'));
|
||||
$newPasswd.focus();
|
||||
} else if ($confirmPwd.val() == '') {
|
||||
} else if ($confirmPwd.val() === '') {
|
||||
toastr.info(trans('auth.emptyConfirmPwd'));
|
||||
$confirmPwd.focus();
|
||||
} else if (newPasswd != $confirmPwd.val()) {
|
||||
} else if (newPasswd !== $confirmPwd.val()) {
|
||||
toastr.warning(trans('auth.invalidConfirmPwd'));
|
||||
$confirmPwd.focus();
|
||||
} else {
|
||||
|
|
@ -69,7 +69,7 @@ async function changePassword() {
|
|||
data: { 'current_password': password, 'new_password': newPasswd }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
try {
|
||||
await swal({
|
||||
type: 'success',
|
||||
|
|
@ -94,7 +94,7 @@ async function changePassword() {
|
|||
$('#new-email').focusin(() => {
|
||||
$('#current-password').parent().show();
|
||||
}).focusout(debounce(() => {
|
||||
let dom = $('#current-password');
|
||||
const dom = $('#current-password');
|
||||
|
||||
if (! dom.is(':focus')) {
|
||||
dom.parent().hide();
|
||||
|
|
@ -131,7 +131,7 @@ async function changeEmail() {
|
|||
data: { new_email: newEmail, password: $('#current-password').val() }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
await swal({
|
||||
type: 'success',
|
||||
text: msg
|
||||
|
|
@ -153,7 +153,7 @@ async function changeEmail() {
|
|||
}
|
||||
|
||||
async function deleteAccount() {
|
||||
let password = $('.modal-body>#password').val();
|
||||
const password = $('.modal-body>#password').val();
|
||||
|
||||
if (! password) {
|
||||
return swal({ type: 'warning', html: trans('user.emptyDeletePassword') });
|
||||
|
|
@ -167,7 +167,7 @@ async function deleteAccount() {
|
|||
data: { password: password }
|
||||
});
|
||||
|
||||
if (errno == 0) {
|
||||
if (errno === 0) {
|
||||
await swal({
|
||||
type: 'success',
|
||||
html: msg
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ async function sign() {
|
|||
dataType: 'json'
|
||||
});
|
||||
|
||||
if (result.errno == 0) {
|
||||
if (result.errno === 0) {
|
||||
$('#score').html(result.score);
|
||||
const dom = '<i class="fa fa-calendar-check-o"></i> ' + trans(
|
||||
'user.signRemainingTime',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user