diff --git a/src/ui/ab.js b/src/ui/ab.js index c343b40c9..c72d475df 100644 --- a/src/ui/ab.js +++ b/src/ui/ab.js @@ -16,30 +16,22 @@ export function getSessionsStyle(type) { return v; } -// Fixed -// function stupidUpdate(me) { -// /* hidden is workaround of stupid sciter bug */ -// me.hidden = true; -// me.componentUpdate(); -// self.timer(60ms, function() { -// me.hidden = false; -// me.componentUpdate(); -// }); -// } +var searchPatterns = {}; export class SearchBar extends Element { - parent; - value = ""; this(props) { - this.parent = props.parent; + this.type = (props || {}).type || ""; } render() { + + let value = searchPatterns[this.type] || ""; + setTimeout(() => { this.$("input").value = value; }, 1); return (
- {search_icon} + {search_icon} - {this.value && {clear_icon}} + {value && {clear_icon}}
); } @@ -53,9 +45,8 @@ export class SearchBar extends Element { } onChange(v) { - this.value = v; - this.componentUpdate(); - this.parent.filter(v); + searchPatterns[this.type] = v; + app.multipleSessions.update(); } } @@ -63,12 +54,12 @@ export class SessionStyle extends Element { type = ""; this(props) { - this.type = (props || {}).type; + this.type = (props || {}).type || ""; } render() { let sessionsStyle = getSessionsStyle(this.type); - return (
+ return (
{svg_tile} {svg_list}
); @@ -78,7 +69,6 @@ export class SessionStyle extends Element { let option = getSessionsStyleOption(this.type); let sessionsStyle = getSessionsStyle(this.type); handler.xcall("set_option", option, sessionsStyle == "tile" ? "list" : "tile"); - //stupidUpdate(app); // seems fixed in new sciter app.componentUpdate(); } } @@ -87,7 +77,7 @@ export class SessionList extends Element { sessions = []; type = ""; style; - filterPattern = ""; + this(props) { this.sessions = props.sessions; @@ -95,16 +85,11 @@ export class SessionList extends Element { this.style = getSessionsStyle(props.type); } - filter(v) { - this.filterPattern = v; - this.componentUpdate(); - } - getSessions() { - let p = this.filterPattern; + let p = searchPatterns[this.type]; if (!p) return this.sessions; let tmp = []; - this.sessions.map(function (s) { + this.sessions.map( (s) => { let name = s[4] || s.alias || s[0] || s.id || ""; if (name.indexOf(p) >= 0) tmp.push(s); }); @@ -113,20 +98,22 @@ export class SessionList extends Element { render() { let sessions = this.getSessions(); - if (sessions.length == 0) return ; + if (sessions.length == 0) return
{translate("Empty")}
; sessions = sessions.map((x) => this.getSession(x)); - // TODO is_win - // TODO
  • RDP
  • return
  • {translate('Connect')}
  • {translate('Transfer File')}
  • {translate('TCP Tunneling')}
  • - +
  • RDP
  • +
  • {translate('Rename')}
  • -
  • {translate('Remove')}
  • - {is_win &&
  • {translate('Create Desktop Shortcut')}
  • } + {this.type != "fav" &&
  • {translate('Remove')}
  • } + {is_win &&
  • {translate('Create Desktop Shortcut')}
  • } +
  • {translate('Unremember Password')}
  • + {(!this.type || this.type == "fav") &&
  • {translate('Add to Favorites')}
  • } + {(!this.type || this.type == "fav") &&
  • {translate('Remove from Favorites')}
  • }
    {sessions} @@ -142,7 +129,7 @@ export class SessionList extends Element { if (this.style == "list") { return (