fix filter refilling in chrome and safari (#6209)

Signed-off-by: si458 <simonsmith5521@gmail.com>

Simon Smith committed Jun 27, 2024 at 16:07 UTC 57442e49884a8834b548bfd64d1911ed0cb0d6d9
1 file changed +14 -7
views/default.handlebars
+14 -7
@@ -318,7 +318,7 @@
318 <input type=button id=SelectAllButton onclick="selectallButtonFunction();" value="Select All" />&nbsp;
319 <input type=button id=GroupActionButton disabled="disabled" value="Group Action" onclick=groupActionFunction() />&nbsp;
320 <input type=button id=ScrollToTopButton onclick="onDevicesScroll(true);" style="display:none;margin-right:4px" value="Scroll To Top" />
321 - <input id=SearchInput type=search autocomplete=off placeholder=Filter onchange=onDeviceSearchChanged(event) onclick=onDeviceSearchChanged(event) onkeyup=onDeviceSearchChanged(event) onfocus=onSearchFocus(1) onblur=onSearchFocus(0) title="Filter: user:xxx or u:xxx ip:xxx group:xxx or g:xxx tag:xxx or t: xxx atag:xxx or a:xxx os:xxx amt:xxx desc:xxx wsc:ok wsc:noav wsc:noupdate wsc:nofirewall wsc:any"/>&nbsp;
321 + <input id=SearchInput type=input autocomplete=off placeholder=Filter onchange=onDeviceSearchChanged(event) onclick=onDeviceSearchChanged(event) onkeyup=onDeviceSearchChanged(event) onfocus=onSearchFocus(1) onblur=onSearchFocus(0) title="Filter: user:xxx or u:xxx ip:xxx group:xxx or g:xxx tag:xxx or t: xxx atag:xxx or a:xxx os:xxx amt:xxx desc:xxx wsc:ok wsc:noav wsc:noupdate wsc:nofirewall wsc:any"/>&nbsp;
322 <span id=SearchInputClearButton style="display:none;position:relative"><img src="images/x16.png" type="button" onclick="clearDeviceSearch()" style="position:absolute;cursor:pointer;left:-18px;top:-8px" srcset="images/x32.png 2x"/></span>
323 <select id=DevFilterSelect onchange=onOnlineCheckBox(event) title="Device Filter">
324 <option value=0>All</option>
@@ -5135,14 +5135,21 @@
5135 function onMultiDesktopStateChange(desk, state) { try { QH('skvmid_' + desk.shortid, ["Disconnected", "Connecting...", "Setup...", '', ''][state]); } catch (ex) {} }
5136 function onDeviceSearchChanged(e) {
5137 var url = new URL(window.location.href);
5138 - if ((e != null) && (e.target.value != '')) {
5138 + if ((e != null) && ((e.target.id == 'SearchInput') || (e.target.id == 'KvmSearchInput'))){ // search box changed or cleared
5139 if (e.target.id == 'SearchInput') {
5140 Q('KvmSearchInput').value = Q('SearchInput').value;
5141 } else {
5142 Q('SearchInput').value = Q('KvmSearchInput').value;
5143 }
5144 - url.searchParams.set('filter', e.target.value);
5145 - if (urlargs.filter) { urlargs.filter = e.target.value; }
5144 + if (e.target.value != '') {
5145 + url.searchParams.set('filter', e.target.value);
5146 + if (urlargs.filter) { urlargs.filter = e.target.value; }
5147 + } else {
5148 + url.searchParams.delete('filter');
5149 + if (urlargs.filter) { delete urlargs.filter; }
5150 + }
5151 + } else if ((e != null) && (e.target.id == 'DevFilterSelect')){ // devfilter box changed
5152 + // DO NOTHING
5153 } else {
5154 url.searchParams.delete('filter');
5155 if (urlargs.filter) { delete urlargs.filter; }
@@ -6199,7 +6206,7 @@
6206 function lastConnectSort(a, b) { var aa = a.lastconnect, bb = b.lastconnect; if (aa == null) { aa = 99999999999999; } if (bb == null) { bb = 99999999999999; } if (a.conn > 0) { aa = 99999999999998; } if (b.conn > 0) { bb = 99999999999998; } if (aa == bb) { return nameSort(a, b); } return (aa - bb); }
6207
6208 function onSearchFocus(x) { searchFocus = x; }
6202 - function clearDeviceSearch() { Q('KvmSearchInput').value = Q('SearchInput').value = ''; Q('DevFilterSelect').value = 0; onOnlineCheckBox(); mainUpdate(1); }
6209 + function clearDeviceSearch() { Q('KvmSearchInput').value = Q('SearchInput').value = ''; onOnlineCheckBox(); mainUpdate(1); }
6210 function onMapSearchFocus(x) { mapSearchFocus = x; }
6211 function onUserSearchFocus(x) { userSearchFocus = x; }
6212 function onConsoleFocus(x) { consoleFocus = x; }
@@ -6323,8 +6330,8 @@
6330 function onSearchInputChanged() {
6331 var x = Q('SearchInput').value.toLowerCase().trim(); putstore('_search', Q('SearchInput').value);
6332 QS('SearchInput')['background-color'] = QS('KvmSearchInput')['background-color'] = (x == '')?null:'#FDFFBE';
6326 - QV('SearchInputClearButton', (x != '') && (navigator.userAgent.indexOf('Firefox') >= 0));
6327 - QV('KvmSearchInputClearButton', (x != '') && (navigator.userAgent.indexOf('Firefox') >= 0));
6333 + QV('SearchInputClearButton', (x != ''));
6334 + QV('KvmSearchInputClearButton', (x != ''));
6335
6336 var r = parseSearchOrInput(x);
6337 for (var d in nodes) { nodes[d].v = (r.indexOf(d) >= 0) }