+ );
+ }
- function send() {
- var el = this.$(input);
- var value = (el.value || "").trim();
- el.value = "";
- if (!value) return;
- if (this.callback) this.callback(value);
- }
+ render() {
+ let msgs = this.msgs.map((msg) => this.renderMsg(msg));
+ setTimeout(() => {
+ scrollToBottom(this.msgs);
+ }, 1);
+ // TODO @{this.msgs} in TIS:
+ return (
+
+ {msgs}
+
+
+
+ {svg_send}
+
+
);
+ }
- event keydown $(input) (evt) {
- if (!evt.shortcutKey) {
- if (evt.keyCode == Event.VK_ENTER ||
- (view.mediaVar("platform") == "OSX" && evt.keyCode == 0x4C)) {
+ send() {
+ let el = this.$("input");
+ let value = (el.value || "").trim();
+ el.value = "";
+ if (!value) return;
+ if (this.callback) this.callback(value);
+ }
+
+ ["on keydown at input"](evt) {
+ // TODO is shortcutKey useless?
+ if (!evt.shortcutKey) {
+ // TODO TEST Windows/Mac
+ if (evt.code == "KeyRETURN") {
this.send();
}
+ }
}
- }
- event click $(div.send span) {
- this.send();
- view.focus = $(input);
- }
+ ["on click at div.send span"](evt) {
+ this.send();
+ view.focus = this.$("input");
+ }
}
/******************** end of chatbox ****************************************/
@@ -213,47 +213,44 @@ class ChatBox: Reactor.Component {
var remember_password = false;
var msgbox_params;
function getMsgboxParams() {
- return msgbox_params;
+ return msgbox_params;
}
// tmp workaround https://sciter.com/forums/topic/menu-not-be-hidden-when-open-dialog-on-linux/
-function msgbox(type, title, text, callback=null, height=180, width=500, retry=0, contentStyle="") {
+function msgbox(type, title, text, callback = null, height = 180, width = 500, retry = 0, contentStyle = "") {
if (is_linux) { // fix menu not hidden issue
- self.timer(1ms,
- function() {
- msgbox_(type, title, text, callback, height, width, retry, contentStyle);
- });
+ setTimeout(() => msgbox_(type, title, text, callback, height, width, retry, contentStyle), 1);
} else {
msgbox_(type, title, text, callback, height, width, retry, contentStyle);
}
}
function msgbox_(type, title, text, callback, height, width, retry, contentStyle) {
- var has_msgbox = msgbox_params != null;
+ let has_msgbox = msgbox_params != null;
if (!has_msgbox && !type) return;
- var remember = false;
+ let remember = false;
try {
- remember = handler.get_remember();
- } catch(e) {}
- msgbox_params = {
+ remember = handler.xcall("get_remember");
+ } catch (e) { }
+ msgbox_params = {
remember: remember, type: type, text: text, title: title,
getParams: getMsgboxParams,
callback: callback, translate: translate,
retry: retry, contentStyle: contentStyle,
};
if (has_msgbox) return;
- var dialog = {
+ let dialog = {
client: true,
parameters: msgbox_params,
width: width + (is_xfce ? 50 : 0),
height: height + (is_xfce ? 50 : 0),
};
- var html = handler.get_msgbox();
+ let html = handler.xcall("get_msgbox");
if (html) dialog.html = html;
- else dialog.url = self.url("msgbox.html");
- var res = view.dialog(dialog);
+ else dialog.url = document.url("msgbox.html");
+ let res = view.modal(dialog);
msgbox_params = null;
- stdout.printf("msgbox return, type: %s, res: %s\n", type, res);
+ console.log(`msgbox return, type: ${type}, res: ${res}`);
if (type.indexOf("custom") >= 0) {
//
} else if (!res) {
@@ -273,12 +270,12 @@ function connecting() {
handler.msgbox("connecting", "Connecting...", "Connection in progress. Please wait.");
}
-handler.msgbox = function(type, title, text, retry=0) {
- self.timer(30ms, function() { msgbox(type, title, text, null, 180, 500, retry); });
+handler.msgbox = function (type, title, text, retry = 0) {
+ setTimeout(() => msgbox(type, title, text, null, 180, 500, retry), 30);
}
var reconnectTimeout = 1;
-handler.msgbox_retry = function(type, title, text, hasRetry) {
+handler.msgbox_retry = function (type, title, text, hasRetry) {
handler.msgbox(type, title, text, hasRetry ? reconnectTimeout : 0);
if (hasRetry) {
reconnectTimeout *= 2;
@@ -287,7 +284,7 @@ handler.msgbox_retry = function(type, title, text, hasRetry) {
}
}
/******************** end of msgbox ****************************************/
-
+// TODO Progress
function Progress()
{
var _val;
@@ -328,51 +325,52 @@ function Progress()
this.value = "";
}
-var svg_eye_cross = ;
+const svg_eye_cross = ();
-class PasswordComponent: Reactor.Component {
- this var visible = false;
- this var value = '';
- this var name = 'password';
-
- function this(params) {
- if (params && params.value) {
- this.value = params.value;
- }
- if (params && params.name) {
- this.name = params.name;
- }
+export class PasswordComponent extends Element {
+ visible = false;
+ value = '';
+ name = 'password';
+
+ constructor(props) {
+ if (props && props.value) {
+ this.value = props.value;
+ }
+ if (props && props.name) {
+ this.name = props.name;
+ }
}
- function render() {
- return
-
- {this.visible ? svg_eye_cross : svg_eye}
-
;
+ render() {
+ return (
+
+
+ {this.visible ? svg_eye_cross : svg_eye}
+
);
}
- event click $(svg) {
- var el = this.$(input);
- var value = el.value;
- var start = el.xcall(#selectionStart) || 0;
- var end = el.xcall(#selectionEnd);
- this.update({ visible: !this.visible });
- var me = this;
- self.timer(30ms, function() {
- var el = me.$(input);
+ ["on click at svg"](svg) {
+ let el = this.$("input");
+ let value = el.value;
+ // TODO selectionStart/selectionEnd run ok,but always return 0
+ let start = el.xcall("selectionStart") || 0;
+ let end = el.xcall("selectionEnd");
+ this.componentUpdate({ visible: !this.visible });
+ setTimeout(() => {
+ let el = this.$("input");
view.focus = el;
el.value = value;
- el.xcall(#setSelection, start, end);
- });
+ el.xcall("setSelection", start, end);
+ }, 30)
}
}
-function isReasonableSize(r) {
- var x = r[0];
- var y = r[1];
+export function isReasonableSize(r) {
+ let x = r[0];
+ let y = r[1];
return !(x < -3200 || x > 3200 || y < -3200 || y > 3200);
}