generated from MuiseDestiny/zotero-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a807eb3
commit 508f408
Showing
5 changed files
with
515 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="Zotero-Style-Setting"> | ||
<ul class="history" style="display: none;"> | ||
<li class="line">set hhi.ddaD</li> | ||
<li class="line">get Zotero.XXX.aaa</li> | ||
<li class="line" selected>remove 标题 in jo</li> | ||
|
||
</ul> | ||
<div class="input-box"> | ||
<span>></span> | ||
<input type="text" placeholder="Enter your command here..."> | ||
</div> | ||
</div> | ||
</body> | ||
<style> | ||
#Zotero-Style-Setting { | ||
---radius---: 10px; | ||
position: fixed; | ||
left: 20%; | ||
bottom: 20%; | ||
width: 60%; | ||
min-height: 50px; | ||
/* height: 70px; */ | ||
border-radius: var(---radius---); | ||
border: 1px solid black; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
} | ||
input { | ||
width: 90%; | ||
height: 45px; | ||
/* border-bottom-left-radius: 10px; | ||
border-bottom-right-radius: 10px; */ | ||
border: 1px solid red; | ||
border: none; | ||
outline: none; | ||
border-radius: 5px; | ||
font-size: 20px; | ||
/* margin-bottom: 10px; */ | ||
} | ||
.history { | ||
width: 100%; | ||
/* border: 1px solid teal; */ | ||
margin-top: 0; | ||
padding: 0; | ||
background-color: rgba(248, 240, 240, .4); | ||
} | ||
.history .line { | ||
list-style-type: none; | ||
width: calc(100% - 40px); | ||
/* background-color: #eee; */ | ||
line-height: 2.5em; | ||
padding: auto 10px; | ||
display: inline-block; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
|
||
} | ||
.history .line:active { | ||
background-color: rgba(220, 240, 240, 1);; | ||
} | ||
.history .line[selected] { | ||
background-color: rgba(220, 240, 240, 1); | ||
} | ||
.history .line:first-child { | ||
border-radius: var(---radius---) var(---radius---) 0 0; | ||
} | ||
</style> | ||
<script> | ||
let settingNode = document.querySelector("#Zotero-Style-Setting") | ||
let inputNode = document.querySelector("input") | ||
let historyNode = settingNode.querySelector(".history") | ||
settingNode.addEventListener("keyup", (event)=>{ | ||
console.log(event) | ||
let isInit = false | ||
if (event.key=="ArrowUp") { | ||
// 鼠标键 | ||
// 如果没显示history | ||
if (historyNode.style.display=="none") { | ||
// 让他显示,并默认选择第一个 | ||
historyNode.style.display = "" | ||
isInit = true | ||
console.log("初始化") | ||
} | ||
} else if (event.key=="Enter") { | ||
// 回车则获取当前selected,填入input | ||
inputNode.value = historyNode.querySelector(".line[selected]").innerText | ||
// 并且收起historyNode | ||
historyNode.style.display = "none" | ||
} | ||
// 选择逻辑 | ||
if ((event.key=="ArrowUp" || event.key=="ArrowDown") && !isInit) { | ||
let lines = historyNode.querySelectorAll(".line") | ||
for (let i=0;i<lines.length;i++){ | ||
if (lines[i].hasAttribute("selected")) { | ||
lines[i].removeAttribute("selected") | ||
// 得到当前被选择索引,选择下一个/上一个 | ||
if (event.key=="ArrowUp") { | ||
i -= 1 | ||
} else if (event.key=="ArrowDown") { | ||
i += 1 | ||
} | ||
if (i==-1) { | ||
i = lines.length - 1 | ||
} | ||
if (i==lines.length) { | ||
i = 0 | ||
} | ||
lines[i].setAttribute("selected", "") | ||
break | ||
} | ||
} | ||
} | ||
}) | ||
</script> | ||
</html> |
Oops, something went wrong.