Skip to content

Commit

Permalink
添加清空按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
Fancyflame committed Sep 6, 2024
1 parent 605835a commit 109cc3d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions web/fg2-app/dist/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body h1 {
font-weight: bold;
padding: 5px 10px;
background: rgba(255,255,255,0.627);
user-select: none;
}
#dialog #btn-field {
flex: 1 1 40px;
Expand Down
2 changes: 1 addition & 1 deletion web/fg2-app/dist/src_index_js.bootstrap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/fg2-app/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ colorBtn(prim-color)
font-weight bold
padding 5px 10px
background #ffffffa0
user-select none

#btn-field
flex 1 1 40px
Expand Down
20 changes: 18 additions & 2 deletions web/fg2-app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ const [inputArea, outputArea, encBtn, decBtn, pasteBtn, copyBtn] = [
"input", "output", "enc-btn", "dec-btn", "paste", "copy"
].map(id => document.getElementById(id));

inputArea.oninput = setPasteBtnText;

function setPasteBtnText() {
if (inputArea.value == "") {
pasteBtn.innerText = "粘贴"
} else {
pasteBtn.innerText = "清空"
}
}
setPasteBtnText();

encBtn.onclick = () => {
let out = GLOBAL_LIB.encode(inputArea.value);
outputArea.style.color = "";
Expand All @@ -25,8 +36,13 @@ decBtn.onclick = () => {
};

pasteBtn.onclick = async function () {
let txt = await navigator.clipboard.readText();
inputArea.value = txt;
if (inputArea.value == "") {
let txt = await navigator.clipboard.readText();
inputArea.value = txt;
} else {
inputArea.value = "";
}
setPasteBtnText();
}

copyBtn.onclick = async function () {
Expand Down

0 comments on commit 109cc3d

Please sign in to comment.