forked from ShineWebOS/ShineOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshineos.html
More file actions
367 lines (307 loc) · 13.4 KB
/
Copy pathshineos.html
File metadata and controls
367 lines (307 loc) · 13.4 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Permissions-Policy" content="interest-cohort=()">
<title>ShineOS</title>
<link id="theme-style" rel="stylesheet" href="xenv.css"> <!-- Ïî óìîë÷àíèþ EnviX -->
</head>
<body>
<div id="icons">
<div class="icon" onclick="openApp('Eaglercraft', '<iframe class="iframe-content" src="https://eaglercraft.com/mc/1.8.8/" sandbox="allow-scripts allow-same-origin allow-pointer-lock"></iframe>')">
<img src="assets/apps/eagler.png" class="icon-image">
<span class="icon-label">Eaglercraft</span>
</div>
<div class="icon" onclick="openApp('DOOM (WARNING: VERY LOUD)', '<iframe class="iframe-content" src="https://thedoggybrad.github.io/doom_on_js-dos/" sandbox="allow-scripts allow-same-origin allow-pointer-lock"></iframe>')">
<img src="assets/apps/doom.png" class="icon-image">
<span class="icon-label">DOOM</span>
</div>
<div class="icon" onclick="openApp('uTorrent', '<iframe class="iframe-content" src="https://lite.utorrent.com/" sandbox="allow-scripts allow-same-origin"></iframe>')">
<img src="assets/apps/torrent.png" class="icon-image">
<span class="icon-label">uTorrent</span>
</div>
<div class="icon" onclick="openApp('Photopea', '<iframe class="iframe-content" src="https://www.photopea.com/" sandbox="allow-scripts allow-same-origin"></iframe>')">
<img src="assets/apps/pea.png" class="icon-image">
<span class="icon-label">Photopea</span>
</div>
<div class="icon" onclick="openApp('Virtual Desktops', '<iframe class="iframe-content" src="emulator.html" sandbox="allow-scripts allow-pointer-lock allow-same-origin"></iframe>')">
<img src="assets/apps/emu.png" class="icon-image">
<span class="icon-label">Virtual Desktops</span>
</div>
<div class="icon" onclick="openApp('Calculator', '<iframe class="iframe-content" src="https://forbirdden.github.io/SimpleCalculator/calc.html" sandbox="allow-scripts allow-same-origin"></iframe>')">
<img src="assets/apps/calc.png" class="icon-image">
<span class="icon-label">Calculator</span>
</div>
<div class="icon" onclick="openApp('Terminal', '<iframe class="iframe-content" src="cmd.html" sandbox="allow-scripts allow-modals allow-same-origin"></iframe>')">
<img src="assets/apps/cmd.png" class="icon-image">
<span class="icon-label">Terminal</span>
</div>
</div>
<div id="desktop"></div>
<div class="taskbar">
<div class="dropdown">
<img src="assets/system/logo.png" class="start" alt="Shiny Button" onclick="toggleMenu()" style="cursor:pointer;">
<div id="dropdownMenu" class="dropdown-content">
<a href="#" id="menuItem1">Button placeholder</a>
<a href="#" id="menuItem2">Settings</a>
<a href="#" id="menuItem3">Power options</a>
</div>
</div>
<div id="taskbar-apps" style="display: flex; gap: 10px"></div>
<div style="flex-grow: 1"></div>
<div class="datetime-container">
<div id="time" class="taskbar-item"></div>
<div id="date" class="taskbar-item"></div>
</div>
<div style="flex-grow: 1"></div>
<div class="taskbar-item">ShineOS Beta 2.2</div>
</div>
<div id="powerOptions" class="dropdown-content-power-options">
<a href="#" id="poweroptionsmenuItem1">Restart</a>
<a href="#" id="poweroptionsmenuItem2">Shutdown</a>
</div>
<audio id="startup" src="assets/system/startup_sound.mp3"></audio>
<script>
let windowCount = 0;
let zIndexCounter = 1000;
let isResizing = false;
let currentWindow = null;
let startX, startY, startWidth, startHeight;
let minimizedWindows = {};
function openApp(title, content) {
const id = `window-${windowCount++}`;
const windowElement = document.createElement('div');
windowElement.className = 'window';
windowElement.id = id;
windowElement.style.zIndex = zIndexCounter++;
windowElement.style.left = `${Math.random() * 100}px`;
windowElement.style.top = `${Math.random() * 100}px`;
const titleBar = document.createElement('div');
titleBar.className = 'title-bar';
const minimizeBtn = document.createElement('button');
minimizeBtn.className = 'minimize-btn';
minimizeBtn.innerHTML = '?';
minimizeBtn.onclick = () => minimizeWindow(id, title);
const closeBtn = document.createElement('button');
closeBtn.className = 'close-btn';
closeBtn.innerHTML = '?';
closeBtn.onclick = () => closeWindow(id);
titleBar.appendChild(minimizeBtn);
titleBar.appendChild(closeBtn);
titleBar.appendChild(titleText);
document.getElementById('desktop').appendChild(windowElement);
return windowElement;
}
function minimizeWindow(id, title) {
const windowElement = document.getElementById(id);
windowElement.style.display = 'none';
const isBlueSky = document.body.classList.contains('busenv');
const container = isBlueSky ?
document.querySelector('.taskbar') :
document.getElementById('icons');
const appElement = document.createElement('div');
appElement.className = isBlueSky ? 'taskbar-app minimized' : 'dock-app minimized';
appElement.textContent = isBlueSky ? title : '';
appElement.innerHTML = isBlueSky ? title : `<img src="assets/apps/${title.toLowerCase()}.png" width="32">`;
appElement.onclick = () => restoreWindow(id);
minimizedWindows[id] = appElement;
if(isBlueSky) {
document.querySelector('.taskbar').insertBefore(appElement, document.querySelector('.datetime-container'));
} else {
document.getElementById('icons').appendChild(appElement);
}
}
function restoreWindow(id) {
const windowElement = document.getElementById(id);
windowElement.style.display = 'block';
windowElement.style.zIndex = zIndexCounter++;
if(minimizedWindows[id]) {
minimizedWindows[id].remove();
delete minimizedWindows[id];
}
}
function closeWindow(id) {
const windowElement = document.getElementById(id);
if (windowElement) windowElement.remove();
if(minimizedWindows[id]) {
minimizedWindows[id].remove();
delete minimizedWindows[id];
}
}
function startDrag(event, id) {
if (isResizing) return;
draggedElement = document.getElementById(id);
if (!draggedElement) return;
draggedElement.style.zIndex = zIndexCounter++;
const rect = draggedElement.getBoundingClientRect();
offsetX = event.clientX - rect.left;
offsetY = event.clientY - rect.top;
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
}
function onMouseMove(event) {
if (draggedElement && !isResizing) {
draggedElement.style.left = `${event.clientX - offsetX}px`;
draggedElement.style.top = `${event.clientY - offsetY}px`;
}
}
function onMouseUp() {
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', onMouseUp);
draggedElement = null;
}
function startResize(e, id) {
e.preventDefault();
isResizing = true;
currentWindow = document.getElementById(id);
startX = e.clientX;
startY = e.clientY;
startWidth = parseInt(document.defaultView.getComputedStyle(currentWindow).width, 10);
startHeight = parseInt(document.defaultView.getComputedStyle(currentWindow).height, 10);
document.addEventListener('mousemove', resize);
document.addEventListener('mouseup', stopResize);
}
function resize(e) {
if (isResizing && currentWindow) {
const width = startWidth + (e.clientX - startX);
const height = startHeight + (e.clientY - startY);
currentWindow.style.width = `${width}px`;
currentWindow.style.height = `${height}px`;
const content = currentWindow.querySelector('.content');
if (content) {
content.style.width = '100%';
content.style.height = 'calc(100% - 40px)';
}
}
}
function stopResize() {
isResizing = false;
currentWindow = null;
document.removeEventListener('mousemove', resize);
document.removeEventListener('mouseup', stopResize);
}
function updateDateTime() {
const now = new Date();
document.getElementById('time').textContent = now.toLocaleTimeString('ru-RU', {
hour: '2-digit',
minute: '2-digit'
});
}
const savedTheme = localStorage.getItem('shineos-theme') || 'busenv';
document.getElementById('theme-style').href = `${savedTheme}.css`;
function toggleMenu() {
const menu = document.getElementById("dropdownMenu");
menu.style.display = menu.style.display === "block" ? "none" : "block";
}
window.onload = function() {
updateDateTime();
setInterval(updateDateTime, 1000);
setTimeout(() => {
const audio = document.getElementById('startup');
audio.play().catch(e => console.error('Audio playback error:', e));
}, 1000);
};
document.getElementById("menuItem1").addEventListener("click", () => alert("This is placeholder!"));
document.getElementById("menuItem2").addEventListener("click", function(e) {
e.preventDefault();
toggleMenu();
openApp('ShineOS Settings', `
<iframe class="iframe-content"
src="settings.html"
style="border:none; width:100%; height:100%">
</iframe>
`);
});
document.getElementById("menuItem3").addEventListener("click", () => {
document.getElementById("powerOptions").style.display = "block";
});
document.getElementById("poweroptionsmenuItem1").addEventListener("click", function() {
location.reload();
});
document.getElementById("poweroptionsmenuItem2").addEventListener("click", () => window.location.href = "blank.html");
window.addEventListener('message', function(event) {
if (event.source === document.getElementById('settings-iframe').contentWindow) {
if (event.data === 'reload') {
window.location.reload();
}
}
});
let lockedIframe = null;
function openApp(title, content) {
const id = `window-${windowCount++}`;
const windowElement = document.createElement('div');
windowElement.className = 'window';
windowElement.id = id;
windowElement.style.zIndex = zIndexCounter++;
windowElement.style.left = `${Math.random() * 100}px`;
windowElement.style.top = `${Math.random() * 100}px`;
const titleBar = document.createElement('div');
titleBar.className = 'title-bar';
titleBar.onmousedown = (e) => startDrag(e, id);
const titleText = document.createElement('h1');
titleText.textContent = title;
const closeBtn = document.createElement('button');
closeBtn.className = 'close-btn';
closeBtn.textContent = 'X';
closeBtn.onclick = () => {
if (lockedIframe === windowElement) unlockPointer();
closeWindow(id);
};
const contentDiv = document.createElement('div');
contentDiv.className = 'content';
contentDiv.innerHTML = content;
const resizeHandle = document.createElement('div');
resizeHandle.className = 'resize-handle';
resizeHandle.onmousedown = (e) => startResize(e, id);
titleBar.appendChild(titleText);
titleBar.appendChild(closeBtn);
windowElement.appendChild(titleBar);
windowElement.appendChild(contentDiv);
windowElement.appendChild(resizeHandle);
document.getElementById('desktop').appendChild(windowElement);
if (title === 'Eaglercraft') {
const iframe = windowElement.querySelector('iframe');
if (iframe) {
iframe.addEventListener('click', () => {
if (!lockedIframe) {
lockPointer(iframe);
}
});
iframe.style.cursor = 'none';
iframe.title = 'Click to lock pointer (Escape to unlock)';
}
}
return windowElement;
}
function lockPointer(iframe) {
iframe.requestPointerLock = iframe.requestPointerLock || iframe.mozRequestPointerLock;
iframe.requestPointerLock();
lockedIframe = iframe;
document.addEventListener('keydown', handleEscape);
}
function unlockPointer() {
document.exitPointerLock();
lockedIframe = null;
document.removeEventListener('keydown', handleEscape);
}
function handleEscape(event) {
if (event.key === 'Escape' && lockedIframe) {
unlockPointer();
}
}
document.addEventListener('click', (e) => {
const powerOptions = document.getElementById('powerOptions');
if (!e.target.closest('.dropdown') && !e.target.closest('.dropdown-content-power-options')) {
powerOptions.style.display = 'none';
document.getElementById('dropdownMenu').style.display = 'none';
}
});
document.addEventListener('pointerlockchange', () => {
if (!document.pointerLockElement) {
lockedIframe = null;
}
});
</script>
</body>
</html>