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