var pi = handler.get_default_pi(); // peer information
var chat_msgs = [];
var svg_fullscreen = ;
var svg_action = ;
var svg_display = ;
var svg_secure = ;
var svg_insecure = ;
var svg_insecure_relay = ;
var svg_secure_relay = ;
var cur_window_state = view.windowState;
function check_state_change() {
if (view.windowState != cur_window_state) {
stateChanged();
}
self.timer(30ms, check_state_change);
}
if (is_linux) {
check_state_change();
} else {
view << event statechange {
stateChanged();
}
}
function get_id() {
return handler.get_option('alias') || handler.get_id()
}
function stateChanged() {
stdout.println('state changed from ' + cur_window_state + ' -> ' + view.windowState);
cur_window_state = view.windowState;
adjustBorder();
adaptDisplay();
if (cur_window_state != View.WINDOW_MINIMIZED) {
view.focus = handler; // to make focus away from restore/maximize button, so that enter key work
}
var fs = view.windowState == View.WINDOW_FULL_SCREEN;
var el = $(#fullscreen);
if (el) el.attributes.toggleClass("active", fs);
el = $(#maximize);
if (el) {
el.state.disabled = fs;
}
if (fs) {
$(header).style.set {
display: "none",
};
}
}
var header;
var old_window_state = View.WINDOW_SHOWN;
var is_edit_os_password;
class EditOsPassword: Reactor.Component {
function render() {
return {svg_edit};
}
function onMouse(evt) {
if (evt.type == Event.MOUSE_DOWN) {
is_edit_os_password = true;
editOSPassword();
}
}
}
function editOSPassword(login=false) {
var p0 = handler.get_option('os-password');
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();
var a = res.auto_login || false;
if (p == p0 && a == a0) return;
if (p != p0) handler.set_option('os-password', p);
if (a != a0) handler.set_option('auto-login', a ? 'Y' : '');
if (p && login) {
handler.input_os_password(p, true);
}
});
}
class Header: Reactor.Component {
this var conn_note = "";
function this() {
header = this;
}
function render() {
var icon_conn;
var title_conn;
if (this.secure_connection && this.direct_connection) {
icon_conn = svg_secure;
title_conn = translate("Direct and encrypted connection");
} else if (this.secure_connection && !this.direct_connection) {
icon_conn = svg_secure_relay;
title_conn = translate("Relayed and encrypted connection");
} else if (!this.secure_connection && this.direct_connection) {
icon_conn = svg_insecure;
title_conn = translate("Direct and unencrypted connection");
} else {
icon_conn = svg_insecure_relay;
title_conn = translate("Relayed and unencrypted connection");
}
var title = get_id();
if (pi.hostname) title += "(" + pi.username + "@" + pi.hostname + ")";
if ((pi.displays || []).length == 0) {
return
{title}
;
}
var screens = pi.displays.map(function(d, i) {
return
{i+1}
;
});
updateWindowToolbarPosition();
var style = "flow:horizontal;";
if (is_osx) style += "margin:*";
self.timer(1ms, updatePrivacyMode);
self.timer(1ms, toggleMenuState);
return