Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
Joe Ma 2023-11-02 21:10:53 +08:00
parent c4b1f06177
commit 601bd0b7dc
No known key found for this signature in database
GPG key ID: 7A0ECF5F5EDC587F

View file

@ -103,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]) => {
@ -151,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');
}
@ -246,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
@ -342,7 +342,7 @@ $(function () {
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');
@ -364,4 +364,4 @@ function select_input_type(name) {
input_div[name].collapse('show');
inputs[name].prop('disabled', false);
inputs[name].prop('required', true);
}
}