diff options
| -rw-r--r-- | website/index.html | 5 | ||||
| -rw-r--r-- | website/main.js | 22 |
2 files changed, 16 insertions, 11 deletions
diff --git a/website/index.html b/website/index.html index d6b2e58..89c3538 100644 --- a/website/index.html +++ b/website/index.html @@ -9,11 +9,6 @@ <body> <h1>apple option key convertor</h1> <textarea id="input" placeholder="Input Encrypt or Decrypt msg"></textarea> - <select id="mode"> - <option value="0">Normal</option> - <option value="1">Reverse</option> - </select> - <button id="convertBtn">convert</button> <p id="output"></p> <button id="copyBtn">copy result</button> </body> diff --git a/website/main.js b/website/main.js index 212e76e..184d2b3 100644 --- a/website/main.js +++ b/website/main.js @@ -1,9 +1,6 @@ -const modeBtn = document.getElementById("mode"); -const convertBtn = document.getElementById("convertBtn"); const input = document.getElementById("input"); const output = document.getElementById("output"); const copyBtn = document.getElementById("copyBtn"); -var mode = true; const match = `\`\` 1ยก @@ -122,12 +119,25 @@ function convert(input, mode) { return result; } -convertBtn.onclick = event => { - mode = modeBtn.value == "0" ? false : true; - var res = convert(input.value, mode); +function autoConvert() { + var mode = null; + var res = ""; + for (var i = 0; i < input.value.length; i++) { + if (mode != null) { + break; + } + for (var j = 0; j < match.length; j++) { + if (match[j][0] == input.value[i]) mode = true; + if (match[j][1] == input.value[i]) mode = false; + } + } + res = convert(input.value, mode); output.innerText = res; + window.requestAnimationFrame(autoConvert); } copyBtn.onclick = event => { navigator.clipboard.writeText(output.innerText); } + +autoConvert();
\ No newline at end of file |
