debug msgbox in sciter ui

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-10-17 09:41:02 +08:00
parent 77de0d05f9
commit 9385e95b4e
7 changed files with 57 additions and 48 deletions

View File

@ -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();

View File

@ -76,28 +76,34 @@ class AddressBook: Reactor.Component
event click $(#add-id) (_, __) {
var me = this;
msgbox("custom-add-id", translate("Add ID"), <div .form>
msgbox(
"custom-add-id",
translate("Add ID"),
<div .form>
<div>{translate("whitelist_sep")}</div>
<textarea .outline-focus spellcheck="false" name="text" style="overflow: scroll-indicator; width:*; height: 160px; font-size: 1.2em; padding: 0.5em;"></textarea>
</div>, 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;
</div>,
"",
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"), <div .form>
<div>{translate("whitelist_sep")}</div>
<textarea .outline-focus spellcheck="false" name="text" style="overflow: scroll-indicator; width:*; height: 160px; font-size: 1.2em; padding: 0.5em;"></textarea>
</div>, function(res=null) {
</div>, "", 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", "<div .form> \
<div><input|text name='name' .outline-focus style='width: *; height: 23px', value='" + old_name + "' /></div> \
</div> \
", 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", <SelectTags tags={peer.tags || []} />, function(res=null) {
msgbox("custom-edit-tag", "Edit Tag", <SelectTags tags={peer.tags || []} />, "", function(res=null) {
if (!res) return;
peer.tags = selectTags.tags;
updateAb();
@ -738,7 +744,7 @@ function editRdpPort() {
<div><span>{translate('Port')}:</span>{port}</div>
<div><span>{translate('Username')}:</span><input|text name="username" value={name0} /></div>
<div><span>{translate('Password')}:</span><PasswordComponent value={pass0} /></div>
</div>, function(res=null) {
</div>, "", function(res=null) {
if (!res) return;
var p = (res.port || '').trim();
if (p != p0) {

View File

@ -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();

View File

@ -535,7 +535,7 @@ class FolderView : Reactor.Component {
msgbox("custom", translate("Create Folder"), "<div .form> \
<div>" + translate("Please enter the folder name") + ":</div> \
<div><input|text(name) .outline-focus /></div> \
</div>", function(res=null) {
</div>", "", 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", "<div .form> \
<div>" + translate('Are you sure you want to delete this file?') + "</div> \
<div.ellipsis style=\"font-weight: bold;\">" + path + "</div> \
</div>", function(res=null) {
</div>", "", 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) {
<div>" + translate('Are you sure you want to delete this file?') + "</div> \
<div.ellipsis style=\"font-weight: bold;\" .text>" + file_path + "</div> \
<div><button|checkbox(remember) {ts}>" + translate('Do this for all conflicts') + "</button></div> \
</div>", function(res=null) {
</div>", "", 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) {
<div>" + translate('This file exists, skip or overwrite this file?') + "</div> \
<div.ellipsis style=\"font-weight: bold;\" .text>" + to + "</div> \
<div><button|checkbox(remember) {ts}>" + translate('Do this for all conflicts') + "</button></div> \
</div>", function(res=null) {
</div>", "", function(res=null) {
if (!res) {
jt.updateJobStatus(id, -1, "cancel");
handler.cancel_job(id);

View File

@ -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", <div .form>
<textarea .outline-focus spellcheck="false" name="text" novalue="input note here" style="overflow: scroll-indicator; width:*; height: 140px; font-size: 1.2em; padding: 0.5em;">{self.conn_note}</textarea>
</div>, function(res=null) {
</div>, "", 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", "<div .form> \
<div><input type=\"hslider\" style=\"width: 50%\" name=\"bitrate\" max=\"100\" min=\"10\" value=\"" + bitrate + "\"/ buddy=\"bitrate-buddy\"><b #bitrate-buddy>x</b>% Bitrate</div> \
</div>", function(res=null) {
</div>", "", 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);
}

View File

@ -247,7 +247,7 @@ class Enhancements: Reactor.Component {
<div> <button #select_directory .link>{translate('Change')}</button> </div>
</div>
</div>
, 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 {
<br />" + handler.get_license() + " \
<p style='font-weight: bold'>Made with heart in this chaotic world!</p>\
</div>\
</div>", function(el) {
</div>", "", function(el) {
if (el && el.attributes) {
handler.open_url(el.attributes['url']);
};
@ -389,7 +389,7 @@ class MyIdMenu: Reactor.Component {
<div>" + translate("whitelist_sep") + "</div> \
<textarea .outline-focus spellcheck=\"false\" name=\"text\" novalue=\"0.0.0.0\" style=\"overflow: scroll-indicator; width:*; height: 140px; font-size: 1.2em; padding: 0.5em;\">" + old_value + "</textarea>\
</div> \
", function(res=null) {
", "", function(res=null) {
if (!res) return;
var value = (res.text || "").trim();
if (value) {
@ -417,7 +417,7 @@ class MyIdMenu: Reactor.Component {
<div><span>" + translate("API Server") + ": </span><input|text name='api' value='" + old_api + "' /></div> \
<div><span>" + translate("Key") + ": </span><input|text name='key' value='" + old_key + "' /></div> \
</div> \
", 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 {
<div><span>{translate("Username")}:</span><input|text name='username' value={old_username} /></div>
<div><span>{translate("Password")}:</span><PasswordComponent value={old_password} /></div>
</div>
, 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 {
<div>" + translate('id_change_tip') + " </div> \
<div><span style='width: 100px; display:inline-block'>ID: </span><input|text .outline-focus style='width: 250px' name='id' /></div> \
</div> \
", 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() {
<input|text name='port' novalue={21118} />;
msgbox("custom-direct-access-port", translate('Direct IP Access Settings'), <div .form .set-password>
<div><span style="width: 60px;">{translate('Port')}:</span>{port}</div>
</div>, function(res=null) {
</div>, "", function(res=null) {
if (!res) return;
var p = (res.port || '').trim();
if (p) {
@ -934,7 +934,7 @@ class PasswordArea: Reactor.Component {
<div><span>" + translate('Password') + ":</span><input|password(password) .outline-focus " + value_field + " /></div> \
<div><span>" + translate('Confirmation') + ":</span><input|password(confirmation) " + value_field + " /></div> \
</div> \
", 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'), <div .form .set-password>
<div><span>{translate('Username')}:</span><input|text name="username" value={name0} .outline-focus /></div>
<div><span>{translate('Password')}:</span><PasswordComponent value={pass0} /></div>
</div>, function(res=null, show_progress) {
</div>, "", function(res=null, show_progress) {
if (!res) return;
show_progress();
var name = (res.username || '').trim();

View File

@ -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);
}
}