var type, title, text, getParams, remember, hasRetry, callback;
function updateParams(params) {
type = params.type;
title = params.title;
text = params.text;
getParams = params.getParams;
remember = params.remember;
callback = params.callback;
hasRetry = type == "error" &&
title == "Connection Error" &&
text.toLowerCase().indexOf("offline") < 0 &&
text.toLowerCase().indexOf("exist") < 0 &&
text.toLowerCase().indexOf("handshake") < 0 &&
text.toLowerCase().indexOf("failed") < 0 &&
text.toLowerCase().indexOf("resolve") < 0 &&
text.toLowerCase().indexOf("manually") < 0;
if (hasRetry) {
self.timer(1s, function() {
view.close({ reconnect: true });
});
}
}
var params = view.parameters;
updateParams(params);
var svg_eye_cross = ;
class Password: Reactor.Component {
this var visible = false;
function 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 });
self.timer(30ms, function() {
var el = this.$(input);
view.focus = el;
el.value = value;
el.xcall(#setSelection, start, end);
});
}
}
var body;
class Body: Reactor.Component {
function this() {
body = this;
}
function getIcon(color) {
if (type == "input-password") {
return ;
}
if (type == "connecting") {
return ;
}
if (type == "success") {
return ;
}
if (type.indexOf("error") >= 0 || type == "re-input-password") {
return ;
}
return ;
}
function getInputPasswordContent() {
var ts = remember ? { checked: true } : {};
return
Please enter your password
;
}
function getContent() {
if (type == "input-password") {
return this.getInputPasswordContent();
}
return text;
}
function getColor() {
if (type == "input-password") {
return "#AD448E";
}
if (type == "success") {
return "#32bea6";
}
if (type.indexOf("error") >= 0 || type == "re-input-password") {
return "#e04f5f";
}
return "#2C8CFF";
}
function hasSkip() {
return type.indexOf("skip") >= 0;
}
function render() {
var color = this.getColor();
var icon = this.getIcon(color);
var content = this.getContent();
var hasCancel = type.indexOf("error") < 0 && type != "success" && type.indexOf("nocancel") < 0;
var hasOk = type != "connecting" && type.indexOf("nook") < 0;
var hasClose = type.indexOf("hasclose") >= 0;
var show_progress = type == "connecting";
self.style.set { border: color + " solid 1px" };
var me = this;
self.timer(1ms, function() {
if (typeof content == "string")
me.$(#content).html = content;
else
me.$(#content).content(content);
});
return (
{show_progress ?
: ""}
{hasCancel || hasRetry ?
: ""}
{this.hasSkip() ?
: ""}
{hasOk || hasRetry ?
: ""}
{hasClose ?
: ""}
);
}
event click $(.custom-event) (_, me) {
if (callback) callback(me);
}
}
$(body).content(