主页增加点击背景

This commit is contained in:
sonichy 2024-03-17 13:24:45 +08:00
parent 2ce86fae22
commit c0725c5b20
2 changed files with 14 additions and 3 deletions

BIN
app.apk

Binary file not shown.

View File

@ -25,7 +25,7 @@ img { vertical-align:middle; }
<option value="https://www.sogou.com/tx?query=%s">搜搜</option>
<option value="https://www.so.com/s?q=%s">360搜索</option>
</select>
<input type="text" id="search_word">
<input type="text" id="text_search">
<button id="button_search">搜索</button>
</div>
<div id="list"></div>
@ -75,6 +75,7 @@ function genList() {
(function(i){
img.addEventListener('mousedown', function(e){
timer = setTimeout(function(){
e.target.style.background = '#eee';
menu.style.display = 'block';
menu.style.left = e.pageX + 'px';
menu.style.top = e.pageY + 'px';
@ -85,11 +86,13 @@ function genList() {
});
var t, time;
img.addEventListener('touchstart', function(e){
e.target.style.background = '#eee';
e.preventDefault();
t = e.touches[0];
time = Date.now();
});
img.addEventListener('touchend', function(e){
img.addEventListener('touchend', function(e){
e.target.style.background = 'none';
var dt = Date.now() - time;
if (dt < 300)
window.location.href = json[i].website;
@ -104,6 +107,7 @@ function genList() {
});
})(i);
img.addEventListener('mouseup', function(e){
e.target.style.background = 'none';
clearTimeout(timer);
});
a.appendChild(img);
@ -121,8 +125,15 @@ function genList() {
list.appendChild(button);
}
text_search.addEventListener('keypress', function(e){
if (e.keyCode == 13) {
var url = search_engine.options[search_engine.selectedIndex].value.replace('%s', text_search.value);
window.open(url, "_blank");
}
});
button_search.addEventListener('click', function(){
var url = search_engine.options[search_engine.selectedIndex].value.replace('%s', search_word.value);
var url = search_engine.options[search_engine.selectedIndex].value.replace('%s', text_search.value);
window.open(url, "_blank");
});