mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 09:39:58 -06:00
GUI search: minor code refactoring
This commit is contained in:
@@ -18,7 +18,7 @@ $guiSearchBoxSpan = "<span id='guiSearchBoxSpan'><input type='text' id='guiSear
|
||||
var languageVisible;
|
||||
var guiSearchSuggestions;
|
||||
|
||||
var browserName = (function (agent) {
|
||||
var browserName = (function(agent) {
|
||||
switch (true) {
|
||||
case agent.indexOf("edge") > -1: return "Edge"; // Edge
|
||||
case agent.indexOf("edg/") > -1: return "Edge"; // Edge Chromium Based
|
||||
@@ -33,20 +33,12 @@ var browserName = (function (agent) {
|
||||
|
||||
$(function() {
|
||||
<?if ($themes2):?>
|
||||
$(".nav-item.gui_search").hover(function(){
|
||||
gui_search();
|
||||
},function(){
|
||||
closeSearchBox();
|
||||
});
|
||||
$(".nav-item.gui_search").hover(function(){gui_search();},function(){closeSearchBox();});
|
||||
<?endif;?>
|
||||
$.post("/plugins/dynamix.gui.search/include/exec.php",function(data) {
|
||||
if (data) {
|
||||
try {
|
||||
guiSearchSuggestions = JSON.parse(data);
|
||||
setupGUIsearch();
|
||||
} catch(e) {
|
||||
console.log("Invalid JSON for GUI search autocomplete");
|
||||
}
|
||||
try {guiSearchSuggestions = JSON.parse(data); setupGUIsearch();}
|
||||
catch(e) {console.log("Invalid JSON for GUI search autocomplete");}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -131,16 +123,14 @@ function guiSearch() {
|
||||
var newPage = "<?=$currentUnraidPage?>/Settings/Tools".replace(searchInfo[0]+"/","");
|
||||
|
||||
if (newPage == "Dashboard/Settings/Tools") newPage = "Settings";
|
||||
|
||||
location.replace("/"+newPage+"/"+searchInfo[0]+scrollText);
|
||||
closeSearchBox();
|
||||
}
|
||||
|
||||
if (browserName != "Chrome" && browserName != "Edge") {
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var script = document.createElement('script');
|
||||
script.type = "text/javascript";
|
||||
script.src = "<?autov('/plugins/dynamix.gui.search/javascript/jquery.mark.js')?>";
|
||||
head.appendChild(script);
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user