mirror of
https://github.com/rikkaneko/paste.git
synced 2025-06-04 07:35:37 +00:00
Update project dependencies version
Add .eslintrc and .prettierrc Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
parent
50244f0c1e
commit
2ea3b0dd8d
7 changed files with 1791 additions and 550 deletions
32
.eslintrc.json
Normal file
32
.eslintrc.json
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended-type-checked", "prettier"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"project": ["./tsconfig.json"],
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn", // or "error"
|
||||
{
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^_",
|
||||
"caughtErrorsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
"error",
|
||||
{
|
||||
"checksVoidReturn": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
8
.prettierrc
Normal file
8
.prettierrc
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 120,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"bracketSameLine": true,
|
||||
"tabWidth": 2
|
||||
}
|
40
package.json
40
package.json
|
@ -1,15 +1,27 @@
|
|||
{
|
||||
"name": "paste",
|
||||
"version": "1.3",
|
||||
"dependencies": {
|
||||
"aws4fetch": "^1.0.17",
|
||||
"dedent-js": "^1.0.1",
|
||||
"js-sha256": "^0.9.0",
|
||||
"nanoid": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20230321.0",
|
||||
"typescript": "^5.0.2",
|
||||
"wrangler": "^2.13.0"
|
||||
}
|
||||
}
|
||||
"name": "paste",
|
||||
"version": "1.3.1",
|
||||
"scripts": {
|
||||
"publish": "wrangler deploy",
|
||||
"format": "prettier --write .",
|
||||
"lint": "eslint . --color --cache -f friendly --max-warnings 10"
|
||||
},
|
||||
"dependencies": {
|
||||
"aws4fetch": "^1.0.17",
|
||||
"dedent-js": "^1.0.1",
|
||||
"js-sha256": "^0.10.1",
|
||||
"nanoid": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20231025.0",
|
||||
"@types/bootstrap": "^5.2.8",
|
||||
"@types/jquery": "^3.5.25",
|
||||
"eslint": "^8.52.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-formatter-friendly": "^7.0.0",
|
||||
"eslint-plugin-import": "^2.29.0",
|
||||
"prettier": "^3.0.3",
|
||||
"typescript": "^5.2.2",
|
||||
"wrangler": "^3.15.0"
|
||||
}
|
||||
}
|
20
web/.eslintrc.json
Normal file
20
web/.eslintrc.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"extends": ["eslint:recommended", "prettier"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"plugins": ["plugin"],
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"node": true
|
||||
}
|
||||
},
|
||||
"root": true,
|
||||
"env": {
|
||||
"browser": true,
|
||||
"jquery": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off"
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// <reference path="../../../node_modules/@types/bootstrap/index.d.ts" />
|
||||
|
||||
const endpoint = 'https://pb.nekoid.cc';
|
||||
|
||||
let input_div = {
|
||||
|
@ -57,13 +59,15 @@ function validate_url(path) {
|
|||
|
||||
function show_pop_alert(message, alert_type = 'alert-primary', add_classes = null) {
|
||||
remove_pop_alert();
|
||||
$('#alert-container').prepend(jQuery.parseHTML(
|
||||
$('#alert-container').prepend(
|
||||
jQuery.parseHTML(
|
||||
`<div class="alert ${alert_type} alert-dismissible position-absolute fade show top-0 start-50 translate-middle-x"
|
||||
style="margin-top: 30px; max-width: 500px; width: 80%" id="pop_alert" role="alert"> \
|
||||
<div>${message}</div> \
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> \
|
||||
</div>`,
|
||||
));
|
||||
</div>`
|
||||
)
|
||||
);
|
||||
if (add_classes) {
|
||||
$('.alert').addClass(add_classes);
|
||||
}
|
||||
|
@ -72,8 +76,7 @@ function show_pop_alert(message, alert_type = 'alert-primary', add_classes = nul
|
|||
|
||||
function remove_pop_alert() {
|
||||
const alert = $('#pop_alert');
|
||||
if (alert.length)
|
||||
alert.remove();
|
||||
if (alert.length) alert.remove();
|
||||
}
|
||||
|
||||
function build_paste_modal(paste_info, show_qrcode = true, saved = true, build_only = false) {
|
||||
|
@ -86,7 +89,7 @@ function build_paste_modal(paste_info, show_qrcode = true, saved = true, build_o
|
|||
paste_modal.id_copy_btn_icon.removeClass('bi-check2');
|
||||
paste_modal.id_copy_btn.addClass('btn-primary');
|
||||
paste_modal.id_copy_btn.removeClass('btn-success');
|
||||
tooltip.setContent({'.tooltip-inner': 'Click to copy'});
|
||||
tooltip.setContent({ '.tooltip-inner': 'Click to copy' });
|
||||
|
||||
if (saved) {
|
||||
cached_paste_info = paste_info;
|
||||
|
@ -100,7 +103,7 @@ function build_paste_modal(paste_info, show_qrcode = true, saved = true, build_o
|
|||
else paste_modal.qrcode.removeClass('d-none');
|
||||
|
||||
// Hide/Show Forget button
|
||||
if (!!cached_paste_info) paste_modal.forget_btn.removeClass('d-none');
|
||||
if (!cached_paste_info) paste_modal.forget_btn.removeClass('d-none');
|
||||
else paste_modal.forget_btn.addClass('d-none');
|
||||
|
||||
Object.entries(paste_info).forEach(([key, val]) => {
|
||||
|
@ -148,7 +151,7 @@ $(function () {
|
|||
|
||||
// Restore saved paste info
|
||||
cached_paste_info = JSON.parse(localStorage.getItem('last_paste'));
|
||||
if (!!cached_paste_info) {
|
||||
if (!cached_paste_info) {
|
||||
show_saved_btn.prop('disabled', false);
|
||||
console.log('Restored cache paste');
|
||||
}
|
||||
|
@ -243,7 +246,7 @@ $(function () {
|
|||
// Remove empty entries
|
||||
let filtered = new FormData();
|
||||
formdata.forEach((val, key) => {
|
||||
if (!!val) filtered.set(key, val);
|
||||
if (!val) filtered.set(key, val);
|
||||
});
|
||||
|
||||
// Request JSON response
|
||||
|
@ -279,7 +282,7 @@ $(function () {
|
|||
});
|
||||
|
||||
show_saved_btn.on('click', function () {
|
||||
if (!!!cached_paste_info) {
|
||||
if (!cached_paste_info) {
|
||||
show_pop_alert('No saved paste found.', 'alert-warning');
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +306,7 @@ $(function () {
|
|||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`${endpoint}/${uuid}/settings?${new URLSearchParams({json: '1'})}`);
|
||||
const res = await fetch(`${endpoint}/${uuid}/settings?${new URLSearchParams({ json: '1' })}`);
|
||||
if (res.ok) {
|
||||
const paste_info = await res.json();
|
||||
build_paste_modal(paste_info, show_qrcode, false);
|
||||
|
@ -327,23 +330,23 @@ $(function () {
|
|||
paste_modal.id_copy_btn_icon.addClass('bi-check2');
|
||||
paste_modal.id_copy_btn.removeClass('btn-primary');
|
||||
paste_modal.id_copy_btn.addClass('btn-success');
|
||||
tooltip.setContent({'.tooltip-inner': 'Copied'});
|
||||
tooltip.setContent({ '.tooltip-inner': 'Copied' });
|
||||
} catch (err) {
|
||||
tooltip.setContent({'.tooltip-inner': 'Copied failed'});
|
||||
tooltip.setContent({ '.tooltip-inner': 'Copied failed' });
|
||||
}
|
||||
} else {
|
||||
tooltip.setContent({'.tooltip-inner': 'Copied failed'});
|
||||
tooltip.setContent({ '.tooltip-inner': 'Copied failed' });
|
||||
}
|
||||
});
|
||||
|
||||
paste_modal.forget_btn.on('click', function () {
|
||||
let tooltip = bootstrap.Tooltip.getInstance(paste_modal.forget_btn);
|
||||
|
||||
if (!!cached_paste_info) {
|
||||
if (!cached_paste_info) {
|
||||
cached_paste_info = null;
|
||||
localStorage.removeItem('last_paste');
|
||||
console.log('Removed cached paste');
|
||||
tooltip.setContent({'.tooltip-inner': 'Forgotten!'});
|
||||
tooltip.setContent({ '.tooltip-inner': 'Forgotten!' });
|
||||
show_saved_btn.prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
@ -351,12 +354,10 @@ $(function () {
|
|||
show_qrcode_checkbox.on('click', function () {
|
||||
show_qrcode = show_qrcode_checkbox.prop('checked');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
function select_input_type(name) {
|
||||
Object.keys(input_div).forEach(key => {
|
||||
Object.keys(input_div).forEach((key) => {
|
||||
input_div[key].collapse('hide');
|
||||
inputs[key].prop('disabled', true);
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width initial-scale=1 shrink-to-fit=1">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.9.1/font/bootstrap-icons.min.css"
|
||||
rel="stylesheet">
|
||||
<link href="css/paste.css" rel="stylesheet">
|
||||
|
@ -270,7 +270,7 @@
|
|||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.6/umd/popper.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.2/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.min.js"></script>
|
||||
<script src="js/paste.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue