without test! pre-change to js

This commit is contained in:
csf 2022-01-02 15:35:36 +08:00 committed by open-trade
parent d68edb9e1a
commit b41658138a
3 changed files with 217 additions and 224 deletions

View File

@ -4,11 +4,11 @@ body {
div.content {
flow: horizontal;
size: *;
size: "*";
}
div.left-panel {
size: *;
size: "*";
padding: 1em;
border-spacing: 1em;
overflow-x: scroll-indicator;
@ -38,7 +38,7 @@ div.chaticon:active {
div.right-panel {
background: white;
border-left: color(border) 1px solid;
size: *;
size: "*";
}
div.icon-and-id {
@ -71,7 +71,7 @@ div.permissions > div {
}
div.permissions icon {
margin: *;
margin: "*";
size: 32px;
background-size: cover;
background-repeat: no-repeat;
@ -99,7 +99,7 @@ icon.audio {
}
div.buttons {
width: *;
width: "*";
border-spacing: 0.5em;
text-align: center;
}
@ -120,14 +120,14 @@ button#disconnect:active {
opacity: 0.5;
}
@media platform != "OSX" {
@media not_osx {
header .window-toolbar {
left: 40px;
top: 8px;
}
}
@media platform == "OSX" {
@media is_osx {
header .tabs-wrapper {
margin-left: 80px;
margin-top: 8px;
@ -135,13 +135,13 @@ header .tabs-wrapper {
}
div.tabs-wrapper {
size: *;
size: "*";
position: relative;
overflow: hidden;
}
div.tabs {
size: *;
size: "*";
flow: horizontal;
white-space: nowrap;
overflow: hidden;
@ -156,7 +156,7 @@ div.border-bottom {
position: absolute;
bottom: 0;
left: 0;
width: *;
width: "*";
height: 1px;
background: color(border) 1px solid;
}
@ -213,7 +213,7 @@ div.tab-arrows {
div.tab-arrows span {
display: inline-block;
height: *;
height: "*";
margin: 0;
padding: 6px 2px;
}

View File

@ -1,20 +1,15 @@
<html>
<head>
<style>
@import url(common.css);
@import url(cm.css);
</style>
<script type="text/tiscript">
include "common.tis";
include "cm.tis";
</script>
</style><link rel="stylesheet" href="common.css">
</style><link rel="stylesheet" href="cm.css">
<script type="module" src="cm.js"></script>
</head>
<header>
<div.window-icon role="window-icon"><icon /></div>
<div class="window-icon" role="window-icon"><icon /></div>
<caption role="window-caption" />
<div.border-bottom />
<div.window-toolbar />
<div.window-buttons />
<div class="border-bottom" />
<div class="window-toolbar" />
<div class="window-buttons" />
</header>
<body #handler>
</body>

View File

@ -1,211 +1,211 @@
include "sciter:reactor.tis";
const view = Window.this;
export const handler = document.$("#handler") || view;
var handler = $(#handler) || view;
try { view.windowIcon = self.url(handler.get_icon()); } catch(e) {}
var OS = view.mediaVar("platform");
var is_osx = OS == "OSX";
var is_win = OS == "Windows";
var is_linux = OS == "Linux";
try { view.windowIcon = document.url(handler.xcall("get_icon")); } catch (e) { }
const OS = view.mediaVar("platform");
const is_osx = OS == "OSX";
const is_win = OS == "Windows";
const is_linux = OS == "Linux";
view.mediaVar("is_osx", is_osx);
view.mediaVar("not_osx", !is_osx);
var is_file_transfer;
var is_xfce = false;
try { is_xfce = handler.is_xfce(); } catch(e) {}
try { is_xfce = handler.xcall("is_xfce"); } catch (e) { }
function translate(name) {
export function translate(name) {
try {
return handler.t(name);
} catch(_) {
return handler.xcall("t", name);
} catch (_) {
return name;
}
}
function hashCode(str) {
var hash = 160 << 16 + 114 << 8 + 91;
for (var i = 0; i < str.length; i += 1) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash % 16777216;
export function hashCode(str) {
let hash = 160 << 16 + 114 << 8 + 91;
for (let i = 0; i < str.length; i += 1) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash % 16777216;
}
function intToRGB(i, a = 1) {
return 'rgba(' + ((i >> 16) & 0xFF) + ', ' + ((i >> 8) & 0x7F)
+ ',' + (i & 0xFF) + ',' + a + ')';
export function intToRGB(i, a = 1) {
return `rgba(${((i >> 16) & 0xFF)}, ${((i >> 8) & 0x7F)},${(i & 0xFF)},${a})`;
}
function string2RGB(s, a = 1) {
return intToRGB(hashCode(s), a);
export function string2RGB(s, a = 1) {
return intToRGB(hashCode(s), a);
}
function getTime() {
var now = new Date();
return now.valueOf();
export function getTime() {
return new Date().valueOf();
}
function platformSvg(platform, color) {
export function platformSvg(platform, color) {
platform = (platform || "").toLowerCase();
if (platform == "linux") {
return <svg viewBox="0 0 256 256">
<g transform="translate(0 256) scale(.1 -.1)" fill={color}>
<path d="m1215 2537c-140-37-242-135-286-278-23-75-23-131 1-383l18-200-54-60c-203-224-383-615-384-831v-51l-66-43c-113-75-194-199-194-300 0-110 99-234 244-305 103-50 185-69 296-69 100 0 156 14 211 54 26 18 35 19 78 10 86-18 233-24 335-12 85 10 222 38 269 56 9 4 19-7 29-35 20-50 52-64 136-57 98 8 180 52 282 156 124 125 180 244 180 380 0 80-28 142-79 179l-36 26 4 119c5 175-22 292-105 460-74 149-142 246-286 409-43 49-78 92-78 97 0 4-7 52-15 107-8 54-19 140-24 189-13 121-41 192-103 260-95 104-248 154-373 122zm172-112c62-19 134-80 163-140 15-31 28-92 41-193 27-214 38-276 57-304 9-14 59-74 111-134 92-106 191-246 236-334 69-137 115-339 101-451l-7-55-71 10c-100 13-234-5-265-36-54-55-85-207-82-412l1-141-51-17c-104-34-245-51-380-45-69 3-142 10-162 16-32 10-37 17-53 68-23 72-87 201-136 273-80 117-158 188-237 215-37 13-37 13-34 61 13 211 182 555 373 759 57 62 58 63 58 121 0 33-9 149-19 259-21 224-18 266 26 347 67 122 193 174 330 133zm687-1720c32-9 71-25 87-36 60-42 59-151-4-274-59-119-221-250-317-257-34-3-35-2-48 47-18 65-20 329-3 413 16 83 29 110 55 115 51 10 177 6 230-8zm-1418-80c79-46 187-195 247-340 41-99 43-121 12-141-39-25-148-30-238-10-142 32-264 112-307 202-20 41-21 50-10 87 24 83 102 166 192 207 54 25 53 25 104-5z"/>
<path d="m1395 1945c-92-16-220-52-256-70-28-15-29-18-29-89 0-247 165-397 345-312 60 28 77 46 106 111 54 123 0 378-80 374-9 0-47-7-86-14zm74-156c15-69 14-112-5-159s-55-70-111-70c-48 0-78 20-102 68-15 29-41 131-41 159 0 9 230 63 242 57 3-2 11-27 17-55z"/>
</g>
</svg>;
return (<svg viewBox="0 0 256 256">
<g transform="translate(0 256) scale(.1 -.1)" fill={color}>
<path d="m1215 2537c-140-37-242-135-286-278-23-75-23-131 1-383l18-200-54-60c-203-224-383-615-384-831v-51l-66-43c-113-75-194-199-194-300 0-110 99-234 244-305 103-50 185-69 296-69 100 0 156 14 211 54 26 18 35 19 78 10 86-18 233-24 335-12 85 10 222 38 269 56 9 4 19-7 29-35 20-50 52-64 136-57 98 8 180 52 282 156 124 125 180 244 180 380 0 80-28 142-79 179l-36 26 4 119c5 175-22 292-105 460-74 149-142 246-286 409-43 49-78 92-78 97 0 4-7 52-15 107-8 54-19 140-24 189-13 121-41 192-103 260-95 104-248 154-373 122zm172-112c62-19 134-80 163-140 15-31 28-92 41-193 27-214 38-276 57-304 9-14 59-74 111-134 92-106 191-246 236-334 69-137 115-339 101-451l-7-55-71 10c-100 13-234-5-265-36-54-55-85-207-82-412l1-141-51-17c-104-34-245-51-380-45-69 3-142 10-162 16-32 10-37 17-53 68-23 72-87 201-136 273-80 117-158 188-237 215-37 13-37 13-34 61 13 211 182 555 373 759 57 62 58 63 58 121 0 33-9 149-19 259-21 224-18 266 26 347 67 122 193 174 330 133zm687-1720c32-9 71-25 87-36 60-42 59-151-4-274-59-119-221-250-317-257-34-3-35-2-48 47-18 65-20 329-3 413 16 83 29 110 55 115 51 10 177 6 230-8zm-1418-80c79-46 187-195 247-340 41-99 43-121 12-141-39-25-148-30-238-10-142 32-264 112-307 202-20 41-21 50-10 87 24 83 102 166 192 207 54 25 53 25 104-5z" />
<path d="m1395 1945c-92-16-220-52-256-70-28-15-29-18-29-89 0-247 165-397 345-312 60 28 77 46 106 111 54 123 0 378-80 374-9 0-47-7-86-14zm74-156c15-69 14-112-5-159s-55-70-111-70c-48 0-78 20-102 68-15 29-41 131-41 159 0 9 230 63 242 57 3-2 11-27 17-55z" />
</g>
</svg>);
}
if (platform == "mac os") {
return <svg viewBox="0 0 384 512">
<path d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z" fill={color}/>
</svg>;
return (<svg viewBox="0 0 384 512">
<path d="M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z" fill={color} />
</svg>);
}
return <svg viewBox="0 0 448 512">
<path d="M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z" fill={color}/>
</svg>;
return (<svg viewBox="0 0 448 512">
<path d="M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z" fill={color} />
</svg>);
}
function centerize(w, h) {
var (sx, sy, sw, sh) = view.screenBox(#workarea, #rectw);
export function centerize(w, h) {
let [sx, sy, sw, sh] = view.screenBox("workarea", "rectw");
if (w > sw) w = sw;
if (h > sh) h = sh;
var x = (sx + sw - w) / 2;
var y = (sy + sh - h) / 2;
const x = (sx + sw - w) / 2;
const y = (sy + sh - h) / 2;
view.move(x, y, w, h);
}
function setWindowButontsAndIcon(only_min=false) {
// TODO CSS
export function setWindowButontsAndIcon(only_min = false) {
if (only_min) {
$(div.window-buttons).content(<div>
<button.window tabindex="-1" role="window-minimize" #minimize><div /></button>
</div>);
document.$("div.window-buttons").content(
<div>
<button class="window minimize" id="button-window" tabindex="-1" role="window-minimize" ><div /></button>
</div>
);
} else {
$(div.window-buttons).content(<div>
<button.window tabindex="-1" role="window-minimize" #minimize><div /></button>
<button.window tabindex="-1" role="window-maximize" #maximize><div /></button>
<button.window tabindex="-1" role="window-close" #close><div /></button>
document.$("div.window-buttons").content(<div>
<button class="window minimize" tabindex="-1" role="window-minimize" ><div /></button>
<button class="window maximize" tabindex="-1" role="window-maximize" ><div /></button>
<button class="window close" tabindex="-1" role="window-close" ><div /></button>
</div>);
}
$(div.window-icon>icon).style.set {
"background-image": "url('" + handler.get_icon() + "')",
};
document.$("div.window-icon>icon").style.setProperty(
"background-image", `url(${handler.xcall("get_icon")})`,
);
}
function adjustBorder() {
export function adjustBorder() {
if (is_osx) {
if (view.windowState == View.WINDOW_FULL_SCREEN) {
$(header).style.set {
display: "none",
};
let headerStyle = document.$("header").style;
if (view.state == Window.WINDOW_FULL_SCREEN) {
headerStyle.setProperty("display", "none",);
} else {
$(header).style.set {
display: "block",
padding: "0",
};
headerStyle.setProperty("display", "block",);
headerStyle.setProperty("padding", "0",);
}
return;
}
if (view.windowState == view.WINDOW_MAXIMIZED) {
self.style.set {
border: "window-frame-width solid transparent",
};
} else if (view.windowState == view.WINDOW_FULL_SCREEN) {
self.style.set {
border: "none",
};
if (view.state == Window.WINDOW_MAXIMIZED) {
document.style.setProperty("border", "window-frame-width solid transparent");
} else if (view.state == Window.WINDOW_FULL_SCREEN) {
document.style.setProperty("border", "none");
} else {
self.style.set {
border: "black solid 1px",
};
document.style.setProperty("border", "black solid 1px");
}
var el = $(button#maximize);
if (el) el.attributes.toggleClass("restore", view.windowState == View.WINDOW_MAXIMIZED);
el = $(span#fullscreen);
if (el) el.attributes.toggleClass("active", view.windowState == View.WINDOW_FULL_SCREEN);
let el = document.$("button#maximize");
if (el) el.classList.toggle("restore", view.state == Window.WINDOW_MAXIMIZED);
el = document.$("span#fullscreen");
if (el) el.classList.toggle("active", view.state == Window.WINDOW_FULL_SCREEN);
}
var svg_checkmark = <svg viewBox="0 0 492 492"><path d="M484 105l-16-17a27 27 0 00-38 0L204 315 62 173c-5-5-12-7-19-7s-14 2-19 7L8 189a27 27 0 000 38l160 160v1l16 16c5 5 12 8 19 8 8 0 14-3 20-8l16-16v-1l245-244a27 27 0 000-38z"/></svg>;
var svg_edit = <svg #edit viewBox="0 0 384 384">
<path d="M0 304v80h80l236-236-80-80zM378 56L328 6c-8-8-22-8-30 0l-39 39 80 80 39-39c8-8 8-22 0-30z"/>
</svg>;
var svg_eye = <svg viewBox="0 0 469.33 469.33">
<path d="m234.67 170.67c-35.307 0-64 28.693-64 64s28.693 64 64 64 64-28.693 64-64-28.694-64-64-64z"/>
<path d="m234.67 74.667c-106.67 0-197.76 66.346-234.67 160 36.907 93.653 128 160 234.67 160 106.77 0 197.76-66.347 234.67-160-36.907-93.654-127.89-160-234.67-160zm0 266.67c-58.88 0-106.67-47.787-106.67-106.67s47.787-106.67 106.67-106.67 106.67 47.787 106.67 106.67-47.787 106.67-106.67 106.67z"/>
</svg>;
var svg_send = <svg viewBox="0 0 448 448">
<polygon points="0.213 32 0 181.33 320 224 0 266.67 0.213 416 448 224"/>
</svg>;
var svg_chat = <svg viewBox="0 0 511.07 511.07">
<path d="m74.39 480.54h-36.213l25.607-25.607c13.807-13.807 22.429-31.765 24.747-51.246-36.029-23.644-62.375-54.751-76.478-90.425-14.093-35.647-15.864-74.888-5.121-113.48 12.89-46.309 43.123-88.518 85.128-118.85 45.646-32.963 102.47-50.387 164.33-50.387 77.927 0 143.61 22.389 189.95 64.745 41.744 38.159 64.734 89.63 64.734 144.93 0 26.868-5.471 53.011-16.26 77.703-11.165 25.551-27.514 48.302-48.593 67.619-46.399 42.523-112.04 65-189.83 65-28.877 0-59.01-3.855-85.913-10.929-25.465 26.123-59.972 40.929-96.086 40.929zm182-420c-124.04 0-200.15 73.973-220.56 147.28-19.284 69.28 9.143 134.74 76.043 175.12l7.475 4.511-0.23 8.727c-0.456 17.274-4.574 33.912-11.945 48.952 17.949-6.073 34.236-17.083 46.99-32.151l6.342-7.493 9.405 2.813c26.393 7.894 57.104 12.241 86.477 12.241 154.37 0 224.68-93.473 224.68-180.32 0-46.776-19.524-90.384-54.976-122.79-40.713-37.216-99.397-56.888-169.71-56.888z"/>
</svg>;
export const svg_checkmark = (<svg viewBox="0 0 492 492"><path d="M484 105l-16-17a27 27 0 00-38 0L204 315 62 173c-5-5-12-7-19-7s-14 2-19 7L8 189a27 27 0 000 38l160 160v1l16 16c5 5 12 8 19 8 8 0 14-3 20-8l16-16v-1l245-244a27 27 0 000-38z" /></svg>);
export const svg_edit = (<svg id="edit" viewBox="0 0 384 384">
<path d="M0 304v80h80l236-236-80-80zM378 56L328 6c-8-8-22-8-30 0l-39 39 80 80 39-39c8-8 8-22 0-30z" />
</svg>);
export const svg_eye = (<svg viewBox="0 0 469.33 469.33">
<path d="m234.67 170.67c-35.307 0-64 28.693-64 64s28.693 64 64 64 64-28.693 64-64-28.694-64-64-64z" />
<path d="m234.67 74.667c-106.67 0-197.76 66.346-234.67 160 36.907 93.653 128 160 234.67 160 106.77 0 197.76-66.347 234.67-160-36.907-93.654-127.89-160-234.67-160zm0 266.67c-58.88 0-106.67-47.787-106.67-106.67s47.787-106.67 106.67-106.67 106.67 47.787 106.67 106.67-47.787 106.67-106.67 106.67z" />
</svg>);
export const svg_send = (<svg viewBox="0 0 448 448">
<polygon points="0.213 32 0 181.33 320 224 0 266.67 0.213 416 448 224" />
</svg>);
export const svg_chat = (<svg viewBox="0 0 511.07 511.07">
<path d="m74.39 480.54h-36.213l25.607-25.607c13.807-13.807 22.429-31.765 24.747-51.246-36.029-23.644-62.375-54.751-76.478-90.425-14.093-35.647-15.864-74.888-5.121-113.48 12.89-46.309 43.123-88.518 85.128-118.85 45.646-32.963 102.47-50.387 164.33-50.387 77.927 0 143.61 22.389 189.95 64.745 41.744 38.159 64.734 89.63 64.734 144.93 0 26.868-5.471 53.011-16.26 77.703-11.165 25.551-27.514 48.302-48.593 67.619-46.399 42.523-112.04 65-189.83 65-28.877 0-59.01-3.855-85.913-10.929-25.465 26.123-59.972 40.929-96.086 40.929zm182-420c-124.04 0-200.15 73.973-220.56 147.28-19.284 69.28 9.143 134.74 76.043 175.12l7.475 4.511-0.23 8.727c-0.456 17.274-4.574 33.912-11.945 48.952 17.949-6.073 34.236-17.083 46.99-32.151l6.342-7.493 9.405 2.813c26.393 7.894 57.104 12.241 86.477 12.241 154.37 0 224.68-93.473 224.68-180.32 0-46.776-19.524-90.384-54.976-122.79-40.713-37.216-99.397-56.888-169.71-56.888z" />
</svg>);
function scrollToBottom(el) {
var y = el.box(#height, #content) - el.box(#height, #client);
export function scrollToBottom(el) {
// TODO .box()
let y = el.box(#height, #content) - el.box(#height, #client);
el.scrollTo(0, y);
}
function getNowStr() {
var now = new Date();
export function getNowStr() {
let now = new Date();
return String.printf("%02d:%02d:%02d", now.hour, now.minute, now.second);
}
/******************** start of chatbox ****************************************/
class ChatBox: Reactor.Component {
this var msgs = [];
this var callback;
function this(params) {
if (params) {
this.msgs = params.msgs || [];
this.callback = params.callback;
}
}
export class ChatBox extends Element {
msgs = [];
callback;
function renderMsg(msg) {
var cls = msg.name == "me" ? "right-side msg" : "left-side msg";
return <div class={cls}>
{msg.name == "me" ?
<div .name>{msg.time + " "} me</div> :
<div .name>{msg.name} {" " + msg.time}</div>
constructor(props) {
if (props) {
this.msgs = props.msgs || [];
this.callback = props.callback;
}
<div .text>{msg.text}</div>
</div>;
}
}
function render() {
var me = this;
var msgs = this.msgs.map(function(msg) { return me.renderMsg(msg); });
self.timer(1ms, function() {
scrollToBottom(me.msgs);
});
return <div .msgbox>
<htmlarea spellcheck="false" readonly .msgs @{this.msgs} >
{msgs}
</htmlarea>
<div .send>
<input|text .outline-focus />
<span>{svg_send}</span>
</div>
</div>;
}
renderMsg(msg) {
let cls = msg.name == "me" ? "right-side msg" : "left-side msg";
return (
<div class={cls}>
{msg.name == "me" ?
<div class="time">{msg.time + " "} me</div> :
<div class="name">{msg.name} {" " + msg.time}</div>
}
<div class="text">{msg.text}</div>
</div>
);
}
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:<htmlarea spellcheck="false" readonly .msgs @{this.msgs} >
return (<div class="msgbox">
<htmlarea spellcheck="false" readonly class="msg" >
{msgs}
</htmlarea>
<div class="send">
<input type="text" class="outline-focus" />
<span>{svg_send}</span>
</div>
</div >);
}
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 = <svg viewBox="0 -21 511.96 511">
<path d="m506.68 261.88c7.043-16.984 7.043-36.461 0-53.461-41.621-100.4-140.03-165.27-250.71-165.27-46.484 0-90.797 11.453-129.64 32.191l-68.605-68.609c-8.3438-8.3398-21.824-8.3398-30.168 0-8.3398 8.3398-8.3398 21.824 0 30.164l271.49 271.49 86.484 86.488 68.676 68.672c4.1797 4.1797 9.6406 6.2695 15.102 6.2695 5.4609 0 10.922-2.0898 15.082-6.25 8.3438-8.3398 8.3438-21.824 0-30.164l-62.145-62.145c36.633-27.883 66.094-65.109 84.438-109.38zm-293.91-100.1c12.648-7.5742 27.391-11.969 43.199-11.969 47.062 0 85.332 38.273 85.332 85.336 0 15.805-4.3945 30.547-11.969 43.199z"/>
<path d="m255.97 320.48c-47.062 0-85.336-38.273-85.336-85.332 0-3.0938 0.59766-6.0195 0.91797-9.0039l-106.15-106.16c-25.344 24.707-46.059 54.465-60.117 88.43-7.043 16.98-7.043 36.457 0 53.461 41.598 100.39 140.01 165.27 250.69 165.27 34.496 0 67.797-6.3164 98.559-18.027l-89.559-89.559c-2.9844 0.32031-5.9062 0.91797-9 0.91797z"/>
</svg>;
const svg_eye_cross = (<svg viewBox="0 -21 511.96 511">
<path d="m506.68 261.88c7.043-16.984 7.043-36.461 0-53.461-41.621-100.4-140.03-165.27-250.71-165.27-46.484 0-90.797 11.453-129.64 32.191l-68.605-68.609c-8.3438-8.3398-21.824-8.3398-30.168 0-8.3398 8.3398-8.3398 21.824 0 30.164l271.49 271.49 86.484 86.488 68.676 68.672c4.1797 4.1797 9.6406 6.2695 15.102 6.2695 5.4609 0 10.922-2.0898 15.082-6.25 8.3438-8.3398 8.3438-21.824 0-30.164l-62.145-62.145c36.633-27.883 66.094-65.109 84.438-109.38zm-293.91-100.1c12.648-7.5742 27.391-11.969 43.199-11.969 47.062 0 85.332 38.273 85.332 85.336 0 15.805-4.3945 30.547-11.969 43.199z" />
<path d="m255.97 320.48c-47.062 0-85.336-38.273-85.336-85.332 0-3.0938 0.59766-6.0195 0.91797-9.0039l-106.15-106.16c-25.344 24.707-46.059 54.465-60.117 88.43-7.043 16.98-7.043 36.457 0 53.461 41.598 100.39 140.01 165.27 250.69 165.27 34.496 0 67.797-6.3164 98.559-18.027l-89.559-89.559c-2.9844 0.32031-5.9062 0.91797-9 0.91797z" />
</svg>);
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 <div .password>
<input name={this.name} value={this.value} type={this.visible ? "text" : "password"} .outline-focus />
{this.visible ? svg_eye_cross : svg_eye}
</div>;
render() {
return (
<div class="password">
<input class="outline-focus" name={this.name} value={this.value} type={this.visible ? "text" : "password"} />
{this.visible ? svg_eye_cross : svg_eye}
</div>);
}
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);
}