Current File : /home/escuelai/public_html/it/js/fuzzysearch.min.js |
/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2022 Teclib' and contributors.
* @copyright 2003-2014 by the INDEPNET Development Team.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/
$((function(){var e=[];var t={pre:"<b>",post:"</b>",extract:function(e){return e.title}};hotkeys("ctrl+alt+g, option+command+g",(function(){a()}));$(document).on("click",".trigger-fuzzy",(function(){a()}));var r=false;var a=function(){c();$.get(CFG_GLPI.root_doc+"/ajax/fuzzysearch.php",{action:"getHtml"},(function(t){$(document.body).append(t);$("#fuzzysearch").modal("show");$.getJSON(CFG_GLPI.root_doc+"/ajax/fuzzysearch.php",{action:"getList"},(function(t){e=t;setTimeout((function(){if($("#fuzzysearch .results li").length==0){s()}}),100)}));$("#fuzzysearch input").trigger("focus");if(r){return}r=true;$(document).on("keyup",(function(e){switch(e.key){case"Escape":c();break;case"ArrowUp":o();break;case"ArrowDown":u();break;case"Enter":var t=$("#fuzzysearch .results .active a").attr("href");if(t==undefined){t=$("#fuzzysearch .results li:first a").attr("href")}if(t!=undefined){document.location=t}break}}));$(document).on("keyup","#fuzzysearch input",(function(e){if(e.key!="Escape"&&e.key!="ArrowUp"&&e.key!="ArrowDown"&&e.key!="Enter"){s()}}))}))};var s=function(){var r=$("#fuzzysearch input").val();$("#fuzzysearch .results").empty();var a=fuzzy.filter(r,e,t);a.map((function(e){$("#fuzzysearch .results").append("<li class='list-group-item'><a href='"+CFG_GLPI.root_doc+e.original.url+"'>"+e.string+"</a></li>")}));i()};var c=function(){$("#fuzzysearch").remove()};var i=function(){$("#fuzzysearch .results li:first()").addClass("active");f()};var n=function(){$("#fuzzysearch .results li:last()").addClass("active");f()};var u=function(){if($("#fuzzysearch .results .active").length==0){i()}else{$("#fuzzysearch .results .active:not(:last-child)").removeClass("active").next().addClass("active");f()}};var o=function(){if($("#fuzzysearch .results .active").length==0){n()}else{$("#fuzzysearch .results .active:not(:first-child)").removeClass("active").prev().addClass("active");f()}};var f=function(){var e=$("#fuzzysearch .results");var t=e.find(".active");if(t.length){e.scrollTop(e.scrollTop()+t.position().top-e.height()/2+t.height()/2-25)}}}));