forked from IvanGav/ConmansGameOfLife
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog_modals.js
55 lines (44 loc) · 1.37 KB
/
dialog_modals.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
45
46
47
48
49
50
51
52
53
54
55
listenImportExport();
function openDialogImport() {
document.getElementById("importSettings").showModal();
document.getElementById("importSettingsInput").blur();
}
function openDialogExport() {
document.getElementById("exportSettings").showModal();
document.getElementById("exportSettingsOutput").value = exportRules();
// document.getElementById("exportSettingsOutput").innerHTML = exportRules();
}
function closeDialogImport() {
document.getElementById("importSettings").close();
}
function closeDialogExport() {
document.getElementById("exportSettings").close();
}
function listenImportExport() {
document.body.addEventListener('keydown', function (event) {
const key = event.key;
switch (key) {
case "[":
openDialogImport();
break;
case "]":
openDialogExport();
break;
}
});
}
function getImportSettings() {
return document.getElementById("importSettingsInput").value;
}
function dialogImportRules() {
importRules(getImportSettings());
closeDialogImport();
}
function copyExport() {
// Get the text field
var copyText = document.getElementById("exportSettingsOutput").value;
// Copy the text inside the text field
navigator.clipboard.writeText(copyText);
// Alert the copied text
alert("Copied!");
}