diff --git a/src/ui/ab.tis b/src/ui/ab.tis index 7363b1570..dc21f781a 100644 --- a/src/ui/ab.tis +++ b/src/ui/ab.tis @@ -304,12 +304,10 @@ class MultipleSessions: Reactor.Component { var nEle = 0; for (var el in this.$$(#sessions-type span)) { nEle += 1; - var n = el.text.length; - totalChars += n; + totalChars += el.text.length; } for (var el in this.$$(#sessions-type span)) { - var n = el.text.length; - var maxWidth = (w - nEle * 2 * 8) * n / totalChars; + var maxWidth = (w - nEle * 2 * 8) * el.text.length / totalChars; if (maxWidth < 0) maxWidth = 36; el.style.set{ "max-width": maxWidth + "px", diff --git a/src/ui/common.tis b/src/ui/common.tis index be9b99094..a6d003598 100644 --- a/src/ui/common.tis +++ b/src/ui/common.tis @@ -234,14 +234,14 @@ function msgbox(type, title, content, callback=null, height=180, width=500, hasR width += is_xfce ? 50 : 0; height += is_xfce ? 50 : 0; - if (type == "input-password") { + if (type.indexOf("input-password") >= 0) { callback = function (res) { if (!res) { view.close(); return; } handler.login(res.password, res.remember); - if (!is_port_forward) msgbox("connecting", "Connecting...", "Logging in..."); + if (!is_port_forward) handler.msgbox("connecting", "Connecting...", "Logging in..."); }; } else if (type.indexOf("custom") < 0 && !is_port_forward && !callback) { callback = function() { view.close(); } @@ -254,16 +254,16 @@ function connecting() { } handler.msgbox = function(type, title, text, hasRetry=false) { - msgbox(type, title, text, null, 180, 500, hasRetry); + // crash somehow (when input wrong password), even with small time, for example, 1ms + self.timer(30ms, function() { msgbox(type, title, text, null, 180, 500, hasRetry); }); } var reconnectTimeout = 1000; -var activeTimer = function() {}; handler.msgbox_retry = function(type, title, text, hasRetry) { handler.msgbox(type, title, text, hasRetry); if (hasRetry) { - self.timer(0, activeTimer); - activeTimer = self.timer(reconnectTimeout, retryConnect); + self.timer(0, retryConnect); + self.timer(reconnectTimeout, retryConnect); reconnectTimeout *= 2; } else { reconnectTimeout = 1000; @@ -271,9 +271,9 @@ handler.msgbox_retry = function(type, title, text, hasRetry) { } function retryConnect(cancelTimer=false) { + if (cancelTimer) self.timer(0, retryConnect); if (!is_port_forward) connecting(); handler.reconnect(); - if (cancelTimer) self.timer(0, activeTimer); } /******************** end of msgbox ****************************************/ diff --git a/src/ui/msgbox.tis b/src/ui/msgbox.tis index 1aa7e62c1..77d15ea33 100644 --- a/src/ui/msgbox.tis +++ b/src/ui/msgbox.tis @@ -9,7 +9,9 @@ function translate_text(text) { return text; } +var msgboxTimerFunc = function() {} function closeMsgbox() { + self.timer(0, msgboxTimerFunc); $(#msgbox).content(); } @@ -86,12 +88,14 @@ class MsgboxComponent: Reactor.Component { var hasClose = this.type.indexOf("hasclose") >= 0; var show_progress = this.type == "connecting"; var me = this; - self.timer(1ms, function() { + self.timer(0, msgboxTimerFunc); + msgboxTimerFunc = function() { if (typeof content == "string") me.$(#content).html = translate(content); else me.$(#content).content(content); - }); + }; + self.timer(3ms, msgboxTimerFunc); return (