-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
79 lines (69 loc) · 2.46 KB
/
example.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
let testWindow;
document.getElementById('createWindow').addEventListener('click', () => {
testWindow = new Window('Test Window', '', [
{
icon: 'fas fa-cog',
onClick: () => alert('Settings button clicked')
}
], 'dark', '', (close) => {
new Alert('Confirm Close', 'Are you sure you want to close this window?', 'Yes', close);
});
});
document.getElementById('testShowHide').addEventListener('click', () => {
if (testWindow) {
if (testWindow.windowElement.style.display === 'none') {
testWindow.show();
} else {
testWindow.hide();
}
}
});
document.getElementById('testSetTitle').addEventListener('click', () => {
const newTitle = document.getElementById('testTitleInput').value;
if (testWindow) {
testWindow.setTitle(newTitle);
}
});
document.getElementById('testSetResource').addEventListener('click', () => {
const newResource = document.getElementById('testResourceInput').value;
if (testWindow) {
testWindow.setResource(newResource);
}
});
document.getElementById('testAddButton').addEventListener('click', () => {
const icon = document.getElementById('testButtonIcon').value;
if (testWindow) {
testWindow.addButton(icon, () => alert(`${icon} button clicked`));
}
});
document.getElementById('testRemoveButton').addEventListener('click', () => {
const icon = document.getElementById('testRemoveButtonIcon').value;
if (testWindow) {
testWindow.removeButton(icon);
}
});
document.getElementById('testSetIcon').addEventListener('click', () => {
const iconUrl = document.getElementById('testIconUrl').value;
if (testWindow) {
testWindow.setIcon(iconUrl);
}
});
document.getElementById('testRemoveIcon').addEventListener('click', () => {
if (testWindow) {
testWindow.removeIcon();
}
});
document.getElementById('testToggleTheme').addEventListener('click', () => {
if (testWindow) {
if (testWindow.theme === 'dark') {
testWindow.toggleTheme('light');
} else {
testWindow.toggleTheme('dark');
}
}
});
document.getElementById('launchAlert').addEventListener('click', () => {
new Alert('Alert Title', 'This is an alert message.', 'Close', () => {
document.querySelector('.alert').remove();
});
});