var type, title, text, getParams, remember, retry, callback, contentStyle;
var my_translate;
function updateParams(params) {
type = params.type;
title = params.title;
text = params.text;
getParams = params.getParams;
remember = params.remember;
callback = params.callback;
my_translate = params.translate;
retry = params.retry;
contentStyle = params.contentStyle;
try { text = translate_text(text); } catch (e) {}
if (retry > 0) {
self.timer(retry * 1000, function() {
view.close({ reconnect: true });
});
}
}
function translate_text(text) {
if (text.indexOf('Failed') == 0 && text.indexOf(': ') > 0) {
var fds = text.split(': ');
for (var i = 0; i < fds.length; ++i) {
fds[i] = my_translate(fds[i]);
}
text = fds.join(': ');
}
return text;
}
var params = view.parameters;
updateParams(params);
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
{my_translate('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 = my_translate(content);
else
me.$(#content).content(content);
});
return (
{hasCancel || hasRetry ?
: ""}
{this.hasSkip() ?
: ""}
{hasOk || hasRetry ?
: ""}
{hasClose ?
: ""}
);
}
event click $(.custom-event) (_, me) {
if (callback) callback(me);
}
}
$(body).content(