-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow.html
More file actions
222 lines (186 loc) · 8.6 KB
/
Copy pathwindow.html
File metadata and controls
222 lines (186 loc) · 8.6 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<html lang="en">
<head>
<title>Suey • Windows</title>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name='viewport' content='width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0'>
<link rel="icon" type="image/png" href="../files/logo/suey256.png" />
<link rel="stylesheet" href="./main.css" />
</head>
<body>
<script src="./imports.js"></script>
<img id="backgroundImage" src="../files/logo/suey256.png" style="position: absolute; margin: auto; left: 0; top: 0; right: 0; bottom: 0;">
<script type="module">
import {
ColorizeFilter,
ColorScheme,
Css,
Div,
Docker,
FlexBox,
FlexSpacer,
Floater,
Iris,
MainWindow,
Question,
ShadowBox,
Tabbed,
Titled,
ToolbarButton,
VectorBox,
} from 'suey';
import {
BUTTON_TYPES,
DOCK_SIDES,
IMAGE_ADD,
QUESTION_ICONS,
RESIZERS,
TAB_SIDES
} from 'suey';
/***** Main Window *****/
const mainWindow = new MainWindow()
document.body.appendChild(mainWindow.dom);
const docker = mainWindow.docker;
/***** Helper Functions *****/
function fontSizeChange(fontSize) {
if (fontSize === 'up' || fontSize === 'increase') {
let addSize = Math.floor((Css.fontSize() + 10.0) / 10.0);
fontSize = Math.min(30, Css.fontSize() + addSize);
} else if (fontSize === 'down' || fontSize === 'decrease') {
let addSize = Math.floor((Css.fontSize() + 10.0) / 10.0);
addSize = Math.floor((Css.fontSize() - addSize + 10.0) / 10.0);
fontSize = Math.max(10, Css.fontSize() - addSize);
} else {
fontSize = parseInt(fontSize);
}
Css.setVariable('--font-size', Css.toPx(fontSize));
}
document.addEventListener('keyup', (event) => {
if (event.key === 'c') docker.collapseTabs();
if (event.key === 'e') docker.expandTabs();
if (event.key === '-') fontSizeChange('down');
if (event.key === '=') fontSizeChange('up');
});
function isZero(odds) {
return (Math.floor(Math.random() * odds) === 0);
}
function randInt(max) {
return Math.floor(Math.random() * max);
}
function randomChars(min = 8, max = 2000, letters = false) {
const CHARACTERS = letters ? 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' : '.';
const CHANCE_ENTER = 10;
const length = randInt(max - min + 1) + min;
let word = '';
for (let i = 0; i < length; i++) {
if (isZero(CHANCE_ENTER)) word += '\n';
else word += CHARACTERS.charAt(randInt(CHARACTERS.length));
}
return word;
}
/***** Docks *****/
const dockLeft = docker.addDock(DOCK_SIDES.LEFT, '20%');
const dockRight = docker.addDock(DOCK_SIDES.RIGHT, '20%');
const dockBottom = docker.addDock(DOCK_SIDES.BOTTOM, '35%');
const tabby1 = dockLeft.enableTabs();
const howdy = new Floater('howdy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
const doody = new Floater('doody', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
tabby1.addFloater(howdy, doody);
const tabby2 = dockRight.enableTabs();
const handy = new Floater('handy', { icon: `../files/logo/suey.svg`, color: '#773399', shrink: 0.5 }).add(new Div(randomChars()));
const dandy = new Floater('dandy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
tabby2.addFloater(handy, dandy);
const tabby3 = dockBottom.enableTabs();
const hippy = new Floater('hippy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
const dippy = new Floater('dippy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
tabby3.addFloater(hippy, dippy);
const miniDock = dockLeft.addDock(DOCK_SIDES.BOTTOM, '30%');
const tabby5 = miniDock.enableTabs();
const huppy = new Floater('huppy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
const duppy = new Floater('duppy', { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()));
tabby5.addFloater(huppy, duppy);
// Force initial resizing
setTimeout(() => {
window.dispatchEvent(new Event('resize'));
}, 0);
/***** Windows *****/
function addWindow(qty = 1) {
const rect = mainWindow.dom.getBoundingClientRect();
for (let i = 0; i < qty; i++) {
const newWindow = mainWindow.addWindow({
title: 'Window',
height: '300px',
width: '300px',
left: `${randInt(rect.width - 300)}px`,
top: `${randInt(rect.height - 400) + 100}px`,
startCentered: false,
});
const windowName = randomChars(5, 9, true);
const floater = new Floater(windowName, { color: new Iris().setRandom().hexString() }).add(new Div(randomChars()).setStyle('overflow', 'auto'));
newWindow.addFloater(floater);
newWindow.focus();
}
}
addWindow(3);
/***** Toolbar *****/
const button1 = new ToolbarButton().add(new VectorBox(IMAGE_ADD));
button1.contents().evenShadow();
button1.contents().setColor('complement');
const button2 = new ToolbarButton().setColor('blue');
const button3 = new ToolbarButton().setColor('green');
const button4 = new ToolbarButton().setColor('yellow');
const button5 = new ToolbarButton().setColor('red');
const button6 = new ToolbarButton(null, 'left');
const button7 = new ToolbarButton(null, 'middle');
const button8 = new ToolbarButton(null, 'right');
button1.setAttribute('tooltip', 'Add Window');
button1.onPress(() => {
addWindow();
});
function alerted(button) {
console.log(`Pressed: ${button} ('${Question.buttonByValue(button)}')`);
}
let color = null;
button2.onPress(() => {
let text = 'This is a info box.';
// let color = 'blue';
// let color = 'cadetblue';
let color = '#005678';
const question = new Question({ icon: QUESTION_ICONS.INFO, color, text, buttons: [ BUTTON_TYPES.OKAY ] }).alert(alerted);
});
button3.onPress(() => {
let text = 'This is a question box?';
let color = 'green';
const question = new Question({ icon: QUESTION_ICONS.QUESTION, color, text, buttons: [ BUTTON_TYPES.NO, BUTTON_TYPES.YES ], defaultButton: BUTTON_TYPES.NO }).alert(alerted);
});
button4.onPress(() => {
let text = 'This is a warning box!';
// let color = 'yellow';
const question = new Question({ icon: QUESTION_ICONS.WARNING, color, text, buttons: [ BUTTON_TYPES.CANCEL, BUTTON_TYPES.NO, BUTTON_TYPES.YES], defaultButton: BUTTON_TYPES.CANCEL }).alert(alerted);
});
button5.onPress(() => {
let text = 'This is an error box!';
// let color = 'red';
const question = new Question({ icon: QUESTION_ICONS.ERROR, color, text, buttons: [ BUTTON_TYPES.OKAY ] }).alert(alerted);
});
button6.onPress(() => {
button6.toggleClass('suey-selected');
})
button7.onPress(() => {
button7.toggleClass('suey-selected');
})
button8.onPress(() => {
button8.toggleClass('suey-selected');
})
const toolbar = new FlexBox().setStyle('flex', '0 0 auto', 'pointerEvents', 'none');
toolbar.add(button1, new FlexSpacer(), button2, button3, button4, button5, new FlexSpacer(), button6, button7, button8);
mainWindow.addToSelf(toolbar);
toolbar.setStyle('padding', 'var(--pad-small)', 'padding-bottom', '0');
mainWindow.docker.setStyle(
'height', 'calc(100% - (var(--button-size) + (var(--pad-small) * 2)))',
'top', 'calc(var(--button-size) + (var(--pad-small) * 2))',
);
</script>
</body>
</html>