mirror of
https://github.com/xHyroM/roles-bot.git
synced 2024-11-22 00:11:06 +01:00
refactor(*): eslint
This commit is contained in:
parent
65b7c2f4c2
commit
c7b55c9c06
3 changed files with 65 additions and 63 deletions
2
packages/website/.eslintignore
Normal file
2
packages/website/.eslintignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
public/script.js
|
||||||
|
next.config.js
|
|
@ -1,14 +1,14 @@
|
||||||
const { createSecureHeaders } = require("next-secure-headers");
|
const { createSecureHeaders } = require('next-secure-headers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
assetPrefix: '/roles-bot/',
|
assetPrefix: '/roles-bot/',
|
||||||
async headers() {
|
async headers() {
|
||||||
return [{
|
return [{
|
||||||
source: "/(.*)",
|
source: '/(.*)',
|
||||||
headers: createSecureHeaders({
|
headers: createSecureHeaders({
|
||||||
forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }],
|
forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }],
|
||||||
referrerPolicy: "same-origin",
|
referrerPolicy: 'same-origin',
|
||||||
}),
|
}),
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
}
|
};
|
|
@ -1,68 +1,68 @@
|
||||||
let json = {
|
const json = {
|
||||||
roles: []
|
roles: []
|
||||||
}
|
};
|
||||||
|
|
||||||
$('input').change((e) => {
|
$('input').change((e) => {
|
||||||
json[e.currentTarget.id] = e.currentTarget.value;
|
json[e.currentTarget.id] = e.currentTarget.value;
|
||||||
|
|
||||||
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
||||||
})
|
});
|
||||||
|
|
||||||
$('button[id=addRole]').click((e) => {
|
$('button[id=addRole]').click((e) => {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Add Role',
|
title: 'Add Role',
|
||||||
html:
|
html:
|
||||||
'<input id="swal-input1" class="swal2-input" placeholder="Button Label*" required />' +
|
'<input id="swal-input1" class="swal2-input" placeholder="Button Label*" required />' +
|
||||||
'<input id="swal-input2" class="swal2-input" placeholder="Role Id*" required />' +
|
'<input id="swal-input2" class="swal2-input" placeholder="Role Id*" required />' +
|
||||||
'<input id="swal-input3" class="swal2-input" placeholder="Emoji" />',
|
'<input id="swal-input3" class="swal2-input" placeholder="Emoji" />',
|
||||||
preConfirm: function () {
|
preConfirm: function () {
|
||||||
return new Promise(function (resolve) {
|
return new Promise(function (resolve) {
|
||||||
resolve([
|
resolve([
|
||||||
$('#swal-input1').val(),
|
$('#swal-input1').val(),
|
||||||
$('#swal-input2').val(),
|
$('#swal-input2').val(),
|
||||||
$('#swal-input3').val()
|
$('#swal-input3').val()
|
||||||
])
|
]);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
if (result.value?.[0] && result.value?.[1]) {
|
if (result.value?.[0] && result.value?.[1]) {
|
||||||
json.roles.push({
|
json.roles.push({
|
||||||
id: result.value[1],
|
id: result.value[1],
|
||||||
label: result.value[0],
|
label: result.value[0],
|
||||||
emoji: result.value[2] || null
|
emoji: result.value[2] || null
|
||||||
})
|
});
|
||||||
|
|
||||||
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
||||||
} else Swal.fire('Missing parameters')
|
} else Swal.fire('Missing parameters');
|
||||||
}).catch(swal.noop)
|
}).catch(swal.noop);
|
||||||
})
|
});
|
||||||
|
|
||||||
$('pre[id=jsonPre].copy').click((e) => {
|
$('pre[id=jsonPre].copy').click((e) => {
|
||||||
navigator.clipboard.writeText(e?.currentTarget?.textContent || e.textContent);
|
navigator.clipboard.writeText(e?.currentTarget?.textContent || e.textContent);
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
position: 'top-end',
|
position: 'top-end',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Copied!',
|
title: 'Copied!',
|
||||||
showConfirmButton: false,
|
showConfirmButton: false,
|
||||||
timer: 1500
|
timer: 1500
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
$('button[id=buttonCopy]').click((e) => {
|
$('button[id=buttonCopy]').click((e) => {
|
||||||
const element = $('pre[id=jsonPre].copy')[0];
|
const element = $('pre[id=jsonPre].copy')[0];
|
||||||
navigator.clipboard.writeText(element?.currentTarget?.textContent || element.textContent);
|
navigator.clipboard.writeText(element?.currentTarget?.textContent || element.textContent);
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
position: 'top-end',
|
position: 'top-end',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Copied!',
|
title: 'Copied!',
|
||||||
showConfirmButton: false,
|
showConfirmButton: false,
|
||||||
timer: 1500
|
timer: 1500
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
$(window).on('load', () => {
|
$(window).on('load', () => {
|
||||||
$('input').toArray().forEach((i) => i.value = '');
|
$('input').toArray().forEach((i) => i.value = '');
|
||||||
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
document.getElementById('json').innerHTML = hljs.highlight(JSON.stringify(json), { language: 'json' }).value;
|
||||||
})
|
});
|
Loading…
Reference in a new issue