GUI search: minor code refactoring

This commit is contained in:
bergware
2023-11-13 11:23:12 +01:00
parent 2ad6b49479
commit 677c2c716f

View File

@@ -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>