From 9385e95b4eb653581184ae81e4cce92a4505363c Mon Sep 17 00:00:00 2001 From: fufesou Date: Mon, 17 Oct 2022 09:41:02 +0800 Subject: [PATCH] debug msgbox in sciter ui Signed-off-by: fufesou --- src/server/connection.rs | 2 +- src/ui/ab.tis | 50 ++++++++++++++++++++++------------------ src/ui/common.tis | 2 +- src/ui/file_transfer.tis | 8 +++---- src/ui/header.tis | 20 ++++++++++------ src/ui/index.tis | 18 +++++++-------- src/ui/msgbox.tis | 5 +--- 7 files changed, 57 insertions(+), 48 deletions(-) diff --git a/src/server/connection.rs b/src/server/connection.rs index dca05e088..e865a8b4f 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -748,7 +748,7 @@ impl Connection { match super::video_service::get_displays().await { Err(err) => { - res.set_error(format!("Error: {}", err)); + res.set_error(format!("{}", err)); } Ok((current, displays)) => { pi.displays = displays.into(); diff --git a/src/ui/ab.tis b/src/ui/ab.tis index ac2efb7dd..acee472a8 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -76,28 +76,34 @@ class AddressBook: Reactor.Component event click $(#add-id) (_, __) { var me = this; - msgbox("custom-add-id", translate("Add ID"),
+ msgbox( + "custom-add-id", + translate("Add ID"), +
{translate("whitelist_sep")}
-
, function(res=null) { - if (!res) return; - var value = (res.text || "").trim(); - var values = value.split(/[\s,;\n]+/g); - if (values.length == 0) return; - for (var v in values) { - var found; - for (var i = 0; i < ab.peers.length; ++i) { - if (ab.peers[i].id == v) { - found = true; - break; +
, + "", + function(res=null) { + if (!res) return; + var value = (res.text || "").trim(); + var values = value.split(/[\s,;\n]+/g); + if (values.length == 0) return; + for (var v in values) { + var found; + for (var i = 0; i < ab.peers.length; ++i) { + if (ab.peers[i].id == v) { + found = true; + break; + } } + if (found) continue; + ab.peers.push({ id: v }); } - if (found) continue; - ab.peers.push({ id: v }); - } - updateAb(); - me.update(); - }, 300); + updateAb(); + me.update(); + }, + 300); } event click $(#add-tag) (_, __) { @@ -105,7 +111,7 @@ class AddressBook: Reactor.Component msgbox("custom-add-tag", translate("Add Tag"),
{translate("whitelist_sep")}
-
, function(res=null) { + , "", function(res=null) { if (!res) return; var value = (res.text || "").trim(); var values = value.split(/[\s,;\n]+/g); @@ -483,7 +489,7 @@ class SessionList: Reactor.Component { msgbox("custom-rename", "Rename", "
\
\
\ - ", function(res=null) { + ", "", function(res=null) { if (!res) return; var name = (res.name || "").trim(); if (name != old_name) { @@ -506,7 +512,7 @@ class SessionList: Reactor.Component { } } if (!peer) return; - msgbox("custom-edit-tag", "Edit Tag", , function(res=null) { + msgbox("custom-edit-tag", "Edit Tag", , "", function(res=null) { if (!res) return; peer.tags = selectTags.tags; updateAb(); @@ -738,7 +744,7 @@ function editRdpPort() {
{translate('Port')}:{port}
{translate('Username')}:
{translate('Password')}:
- , function(res=null) { + , "", function(res=null) { if (!res) return; var p = (res.port || '').trim(); if (p != p0) { diff --git a/src/ui/common.tis b/src/ui/common.tis index e591f45a3..76e0fb84e 100644 --- a/src/ui/common.tis +++ b/src/ui/common.tis @@ -232,7 +232,7 @@ class ChatBox: Reactor.Component { /******************** start of msgbox ****************************************/ var remember_password = false; -function msgbox(type, title, content, link, callback=null, height=180, width=500, hasRetry=false, contentStyle="") { +function msgbox(type, title, content, link="", callback=null, height=180, width=500, hasRetry=false, contentStyle="") { $(body).scrollTo(0, 0); if (!type) { closeMsgbox(); diff --git a/src/ui/file_transfer.tis b/src/ui/file_transfer.tis index 38c6321dc..451117403 100644 --- a/src/ui/file_transfer.tis +++ b/src/ui/file_transfer.tis @@ -535,7 +535,7 @@ class FolderView : Reactor.Component { msgbox("custom", translate("Create Folder"), "
\
" + translate("Please enter the folder name") + ":
\
\ -
", function(res=null) { + ", "", function(res=null) { if (!res) return; if (!res.name) return; var name = res.name.trim(); @@ -716,7 +716,7 @@ function confirmDelete(id ,path, is_remote) { msgbox("custom-skip", "Confirm Delete", "
\
" + translate('Are you sure you want to delete this file?') + "
\ " + path + "
\ - ", function(res=null) { + ", "", function(res=null) { if (!res) { file_transfer.job_table.updateJobStatus(id, -1, "cancel"); file_transfer.job_table.cancelDeletePolling(); @@ -746,7 +746,7 @@ handler.confirmDeleteFiles = function(id, i, name) {
" + translate('Are you sure you want to delete this file?') + "
\ " + file_path + " \
" + translate('Do this for all conflicts') + "
\ - ", function(res=null) { + ", "", function(res=null) { if (!res) { jt.updateJobStatus(id, i - 1, "cancel"); file_transfer.job_table.cancelDeletePolling(); @@ -778,7 +778,7 @@ handler.overrideFileConfirm = function(id, file_num, to, is_upload) {
" + translate('This file exists, skip or overwrite this file?') + "
\ " + to + " \
" + translate('Do this for all conflicts') + "
\ - ", function(res=null) { + ", "", function(res=null) { if (!res) { jt.updateJobStatus(id, -1, "cancel"); handler.cancel_job(id); diff --git a/src/ui/header.tis b/src/ui/header.tis index 8f9fa8a32..01699a583 100644 --- a/src/ui/header.tis +++ b/src/ui/header.tis @@ -78,7 +78,7 @@ class EditOsPassword: Reactor.Component { function editOSPassword(login=false) { var p0 = handler.get_option('os-password'); - msgbox("custom-os-password", 'OS Password', p0, function(res=null) { + msgbox("custom-os-password", 'OS Password', p0, "", function(res=null) { if (!res) return; var a0 = handler.get_option('auto-login') != ''; var p = (res.password || '').trim(); @@ -320,7 +320,7 @@ class Header: Reactor.Component { var self = this; msgbox("custom", "Note",
-
, function(res=null) { + , "", function(res=null) { if (!res) return; if (!res.text) return; self.conn_note = res.text; @@ -333,9 +333,15 @@ class Header: Reactor.Component { } event click $(#restart_remote_device) { - msgbox("restart-confirmation", translate("Restart Remote Device"), translate("Are you sure you want to restart") + " " + pi.username + "@" + pi.hostname + "(" + get_id() + ") ?", function(res=null) { - if (res != null) handler.restart_remote_device(); - }); + msgbox( + "restart-confirmation", + translate("Restart Remote Device"), + translate("Are you sure you want to restart") + " " + pi.username + "@" + pi.hostname + "(" + get_id() + ") ?", + "", + function(res=null) { + if (res != null) handler.restart_remote_device(); + } + ); } event click $(#lock-screen) { @@ -400,7 +406,7 @@ function handle_custom_image_quality() { var bitrate = (tmp[0] || 50); msgbox("custom", "Custom Image Quality", "
\
x% Bitrate
\ -
", function(res=null) { + ", "", function(res=null) { if (!res) return; if (!res.bitrate) return; handler.save_custom_image_quality(res.bitrate); @@ -489,7 +495,7 @@ handler.updatePrivacyMode = updatePrivacyMode; function togglePrivacyMode(privacy_id) { var supported = handler.is_privacy_mode_supported(); if (!supported) { - msgbox("nocancel", translate("Privacy mode"), translate("Unsupported"), function() { }); + msgbox("nocancel", translate("Privacy mode"), translate("Unsupported"), "", function() { }); } else { handler.toggle_option(privacy_id); } diff --git a/src/ui/index.tis b/src/ui/index.tis index a2d895733..45e881096 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -247,7 +247,7 @@ class Enhancements: Reactor.Component {
- , function(res=null) { + , "", function(res=null) { if (!res) return; handler.set_option("enable-record-session", res.enable_record_session ? '' : 'N'); handler.set_option("allow-auto-record-incoming", res.auto_record_incoming ? 'Y' : ''); @@ -369,7 +369,7 @@ class MyIdMenu: Reactor.Component {
" + handler.get_license() + " \

Made with heart in this chaotic world!

\ \ - ", function(el) { + ", "", function(el) { if (el && el.attributes) { handler.open_url(el.attributes['url']); }; @@ -389,7 +389,7 @@ class MyIdMenu: Reactor.Component {
" + translate("whitelist_sep") + "
\ \ \ - ", function(res=null) { + ", "", function(res=null) { if (!res) return; var value = (res.text || "").trim(); if (value) { @@ -417,7 +417,7 @@ class MyIdMenu: Reactor.Component {
" + translate("API Server") + ":
\
" + translate("Key") + ":
\ \ - ", function(res=null) { + ", "", function(res=null) { if (!res) return; var id = (res.id || "").trim(); var relay = (res.relay || "").trim(); @@ -453,7 +453,7 @@ class MyIdMenu: Reactor.Component {
{translate("Username")}:
{translate("Password")}:
- , function(res=null) { + , "", function(res=null) { if (!res) return; var proxy = (res.proxy || "").trim(); var username = (res.username || "").trim(); @@ -474,7 +474,7 @@ class MyIdMenu: Reactor.Component {
" + translate('id_change_tip') + "
\
ID:
\ \ - ", function(res=null, show_progress) { + ", "", function(res=null, show_progress) { if (!res) return; show_progress(); var id = (res.id || "").trim(); @@ -520,7 +520,7 @@ function editDirectAccessPort() { ; msgbox("custom-direct-access-port", translate('Direct IP Access Settings'),
{translate('Port')}:{port}
-
, function(res=null) { + , "", function(res=null) { if (!res) return; var p = (res.port || '').trim(); if (p) { @@ -934,7 +934,7 @@ class PasswordArea: Reactor.Component {
" + translate('Password') + ":
\
" + translate('Confirmation') + ":
\ \ - ", function(res=null) { + ", "", function(res=null) { if (!res) return; var p0 = (res.password || "").trim(); var p1 = (res.confirmation || "").trim(); @@ -1161,7 +1161,7 @@ function login() { msgbox("custom-login", translate('Login'),
{translate('Username')}:
{translate('Password')}:
-
, function(res=null, show_progress) { + , "", function(res=null, show_progress) { if (!res) return; show_progress(); var name = (res.username || '').trim(); diff --git a/src/ui/msgbox.tis b/src/ui/msgbox.tis index 3f40c367d..d5c60d95c 100644 --- a/src/ui/msgbox.tis +++ b/src/ui/msgbox.tis @@ -1,5 +1,3 @@ -import * as env from "@env"; - function translate_text(text) { if (text.indexOf('Failed') == 0 && text.indexOf(': ') > 0) { var fds = text.split(': '); @@ -162,9 +160,8 @@ class MsgboxComponent: Reactor.Component { } event click $(button#jumplink) { - stdout.println("REMOVE ME ================================= jump link" + this.link); if (this.link.indexOf("http") == 0) { - env.launch(this.link); + Sciter.launch(this.link); } }