forked from homa31/CSE134B-HW4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customdialog.js
44 lines (36 loc) · 1.33 KB
/
customdialog.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { buttonEl, dialogEl, closeEl } from './alert-button-module.js';
import { confirmButtonEl, confirmDialogEl, confirmCancelEl, confirmOkEl} from './confirm-button-module.js';
import { promptButtonEl, promptDialogEl, promptCancelEl, promptOkEl, promptInputEl, promptOutputEl} from './prompt-button-module.js';
const confirmOutput = document.getElementById("confirm-output");
buttonEl.addEventListener('click', () => {
dialogEl.showModal();
});
closeEl.addEventListener('click', () => {
dialogEl.close();
});
confirmButtonEl.addEventListener('click', () => {
confirmDialogEl.showModal();
});
confirmCancelEl.addEventListener('click', () => {
confirmDialogEl.close();
let result = false;
confirmOutput.innerHTML = `Confirm Result: ${result}`;
});
confirmOkEl.addEventListener('click', () => {
let result = true;
confirmOutput.innerHTML = `Confirm Result: ${result}`;
confirmDialogEl.close();
});
promptButtonEl.addEventListener('click', () => {
promptDialogEl.showModal();
});
promptCancelEl.addEventListener('click', () => {
promptDialogEl.innerHTML = `User did not enter anything`;
promptDialogEl.close();
});
promptOkEl.addEventListener('click', () => {
let result = promptInputEl.value;
let cleanResult = DOMPurify.sanitize(result);
confirmOutput.innerHTML = `Prompt Result: ${cleanResult}`;
promptDialogEl.close();
});