whisper.cat/weboasis/js/index_search_button.min.js

1 line
1.8 KiB
JavaScript
Raw Normal View History

2023-10-05 23:28:32 +11:00
function is_touch_device(){if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)return!0;var a=["(",["","-webkit-","-moz-","-o-","-ms-",""].join("touch-enabled),("),"heartz",")"].join("");return function(a){return window.matchMedia(a).matches}(a)}(()=>{let a=is_touch_device()||!0;if(a){document.getElementById("searchContainer").classList.add("touchscreen"),document.getElementById("searchButton").addEventListener("click",function(){let a=document.getElementById("searchBar").value,b=a.split(" ");if(b[0].charAt(0)===cmdPrefix){for(var c="",d=0;d<searchSources.length;d++)if(c=cmdPrefix+searchSources[d][0],c===b[0]){ssi=d;break}1<b.length?(url=searchSources[ssi][1].replace("{Q}",encodeURIComponent(a.replace(c,""))).trim(),"true"===GetCookie("new-tab")?window.open(url,"_blank"):window.location=url):(event.preventDefault(),searchInput.placeholder=searchSources[ssi][2],searchInput.value="")}else url=searchSources[ssi][1].replace("{Q}",encodeURIComponent(a)),"true"===GetCookie("new-tab")?window.open(url,"_blank"):window.location=url}),document.getElementById("searchBar").addEventListener("focus",function(){document.getElementById("searchButton").classList.contains("searchbar-focused")||document.getElementById("searchButton").classList.add("searchbar-focused")}),document.getElementById("searchBar").addEventListener("blur",function(){document.getElementById("searchButton").classList.contains("searchbar-focused")&&document.getElementById("searchButton").classList.remove("searchbar-focused")}),document.getElementById("searchButton").style.height=document.getElementById("searchBar").offsetHeight+"px",function(){try{var a=window.getComputedStyle(document.getElementById("searchBar")).fontSize;document.getElementById("searchButton").style.fontSize=a}catch(a){}}()}})();