-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaesar.js
25 lines (22 loc) · 824 Bytes
/
caesar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function caesarRenderer() {
const form = document.querySelector("#caesar");
form.addEventListener("submit", (event) => {
event.preventDefault();
const input = event.target["caesar-input"].value;
const direction = event.target["caesar-options"].value;
const shift = event.target["caesar-shift"].value;
const result =
direction === "encode"
? caesarModule.caesar(input, Number(shift))
: caesarModule.caesar(input, Number(shift), false);
const alert = document.querySelector("#caesar-alert");
if (result) {
alert.classList.add("d-none");
const output = document.querySelector("#caesar-output");
output.innerHTML = result;
} else {
alert.classList.remove("d-none");
}
});
}
document.addEventListener("DOMContentLoaded", caesarRenderer);