mirror of
https://github.com/rikkaneko/paste.git
synced 2025-08-05 13:40:09 +01:00
Use xml-js over xml2js lib
Add Go button in paste modal (frontend) Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
parent
d2a1dd13b8
commit
63578bcf9d
6 changed files with 113 additions and 75 deletions
|
@ -41,6 +41,7 @@ let paste_modal = {
|
|||
id_copy_btn: null,
|
||||
id_copy_btn_icon: null,
|
||||
forget_btn: null,
|
||||
go_btn: null,
|
||||
};
|
||||
|
||||
let cached_paste_info = null;
|
||||
|
@ -79,7 +80,7 @@ function remove_pop_alert() {
|
|||
if (alert.length) alert.remove();
|
||||
}
|
||||
|
||||
function build_paste_modal(paste_info, show_qrcode = true, saved = true, build_only = false) {
|
||||
function build_paste_modal(paste_info, show_qrcode = true, saved = true, one_time_only = false, build_only = false) {
|
||||
let tooltip = bootstrap.Tooltip.getInstance(paste_modal.id_copy_btn);
|
||||
|
||||
paste_modal.uuid.text(paste_info.link);
|
||||
|
@ -113,6 +114,8 @@ function build_paste_modal(paste_info, show_qrcode = true, saved = true, build_o
|
|||
|
||||
let modal = new bootstrap.Modal(paste_modal.modal);
|
||||
if (!build_only) modal.show();
|
||||
paste_modal.forget_btn.prop('disabled', one_time_only);
|
||||
paste_modal.forget_btn.prop('hidden', one_time_only);
|
||||
$('.modal-body').scrollTop('0');
|
||||
}
|
||||
|
||||
|
@ -139,6 +142,7 @@ $(function () {
|
|||
paste_modal.id_copy_btn = $('#id_copy_button');
|
||||
paste_modal.id_copy_btn_icon = $('#id_copy_button_icon');
|
||||
paste_modal.forget_btn = $('#forget_btn');
|
||||
paste_modal.go_btn = $('#modal_go_btn');
|
||||
|
||||
let file_stat = $('#file_stats');
|
||||
let title = $('#paste_title');
|
||||
|
@ -331,7 +335,7 @@ $(function () {
|
|||
|
||||
if (res.ok) {
|
||||
const paste_info = await res.json();
|
||||
build_paste_modal(paste_info, show_qrcode);
|
||||
build_paste_modal(paste_info, show_qrcode, true);
|
||||
show_pop_alert(`Paste #${paste_info.uuid} created!`, 'alert-success');
|
||||
pass_input.val('');
|
||||
} else {
|
||||
|
@ -380,7 +384,7 @@ $(function () {
|
|||
const res = await fetch(`https://pb.nekoid.cc/${uuid}/settings?${new URLSearchParams({ json: '1' })}`);
|
||||
if (res.ok) {
|
||||
const paste_info = await res.json();
|
||||
build_paste_modal(paste_info, show_qrcode, false);
|
||||
build_paste_modal(paste_info, show_qrcode, false, true);
|
||||
} else {
|
||||
show_pop_alert('Invalid Paste ID.', 'alert-warning');
|
||||
}
|
||||
|
@ -418,6 +422,11 @@ $(function () {
|
|||
}
|
||||
});
|
||||
|
||||
paste_modal.go_btn.on('click', function () {
|
||||
const uuid = $('#paste_info_uuid').text();
|
||||
window.open(`/${uuid}`);
|
||||
});
|
||||
|
||||
show_qrcode_checkbox.on('click', function () {
|
||||
show_qrcode = show_qrcode_checkbox.prop('checked');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue