Ramesh-vani commited on
Commit
a0d68c2
Β·
verified Β·
1 Parent(s): 2c9d056

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +770 -18
index.html CHANGED
@@ -1,19 +1,771 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Advanced Windows-like System with App Icons and Time</title>
7
+ <style>
8
+ /* Basic Reset & Fonts */
9
+ * { margin: 0; padding: 0; box-sizing: border-box; }
10
+ body, html { width: 100%; height: 100%; overflow: hidden; font-family: Arial, sans-serif; }
11
+
12
+ /* Desktop */
13
+ #desktop {
14
+ position: absolute;
15
+ width: 100%;
16
+ height: 100%;
17
+ background: url('background.jpg') no-repeat center center fixed;
18
+ background-size: cover;
19
+ }
20
+ #desktop-icons {
21
+ position: absolute;
22
+ top: 10px;
23
+ left: 10px;
24
+ display: flex;
25
+ flex-wrap: wrap;
26
+ }
27
+ .icon {
28
+ width: 80px;
29
+ height: 80px;
30
+ margin: 10px;
31
+ background: rgba(0,0,0,0.5);
32
+ color: #fff;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ text-align: center;
37
+ cursor: pointer;
38
+ border-radius: 5px;
39
+ font-size: 14px;
40
+ }
41
+
42
+ /* Taskbar */
43
+ #taskbar {
44
+ position: absolute;
45
+ bottom: 0;
46
+ left: 0;
47
+ right: 0;
48
+ height: 40px;
49
+ background: rgba(0,0,0,0.8);
50
+ z-index: 1000;
51
+ display: flex;
52
+ align-items: center;
53
+ padding: 0 5px;
54
+ }
55
+ /* Left side of Taskbar (Start button, pinned apps, running windows) */
56
+ #taskbar-left {
57
+ display: flex;
58
+ align-items: center;
59
+ flex: 1;
60
+ }
61
+ #start-button {
62
+ background: #0078d7;
63
+ color: white;
64
+ border: none;
65
+ padding: 5px 10px;
66
+ cursor: pointer;
67
+ margin-right: 10px;
68
+ }
69
+ /* Pinned Apps on Taskbar */
70
+ #taskbar-pinned {
71
+ display: flex;
72
+ align-items: center;
73
+ }
74
+ #taskbar-pinned button {
75
+ background: transparent;
76
+ border: none;
77
+ color: white;
78
+ margin-right: 5px;
79
+ font-size: 18px;
80
+ cursor: pointer;
81
+ }
82
+ /* Running Apps: each window gets its own tab (only icon) */
83
+ #taskbar-windows {
84
+ display: flex;
85
+ align-items: center;
86
+ margin-left: 10px;
87
+ }
88
+ #taskbar-windows button {
89
+ background: #555;
90
+ border: none;
91
+ color: white;
92
+ padding: 3px 8px;
93
+ margin: 0 2px;
94
+ cursor: pointer;
95
+ border-radius: 3px;
96
+ font-size: 13px;
97
+ }
98
+ .taskbar-icon {
99
+ font-size: 16px;
100
+ display: inline-block;
101
+ }
102
+ /* Right side of Taskbar: current time display */
103
+ #taskbar-right {
104
+ color: white;
105
+ font-size: 14px;
106
+ padding-right: 10px;
107
+ display: flex;
108
+ align-items: center;
109
+ }
110
+
111
+ /* Start Menu */
112
+ #start-menu {
113
+ position: absolute;
114
+ bottom: 45px;
115
+ left: 10px;
116
+ width: 200px;
117
+ background: #fff;
118
+ border: 1px solid #ccc;
119
+ display: none;
120
+ z-index: 1001;
121
+ }
122
+ #start-menu ul { list-style: none; }
123
+ #start-menu li {
124
+ padding: 10px;
125
+ cursor: pointer;
126
+ border-bottom: 1px solid #eee;
127
+ }
128
+ #start-menu li:hover { background: #f0f0f0; }
129
+
130
+ /* Window Styles */
131
+ .window {
132
+ position: absolute;
133
+ width: 400px;
134
+ height: 300px;
135
+ min-height: 200px;
136
+ background: #fff;
137
+ border: 1px solid #333;
138
+ box-shadow: 2px 2px 10px rgba(0,0,0,0.5);
139
+ z-index: 200;
140
+ overflow: hidden;
141
+ }
142
+ .window-header {
143
+ background: #0078d7;
144
+ color: #fff;
145
+ padding: 5px;
146
+ cursor: move;
147
+ display: flex;
148
+ align-items: center;
149
+ justify-content: space-between;
150
+ position: relative;
151
+ }
152
+ .window-header .app-icon {
153
+ font-size: 16px;
154
+ margin-right: 5px;
155
+ display: inline-block;
156
+ }
157
+ .window-header .title {
158
+ font-weight: bold;
159
+ display: inline-block;
160
+ }
161
+ .window-header .controls button {
162
+ background: transparent;
163
+ border: none;
164
+ color: #fff;
165
+ cursor: pointer;
166
+ margin-left: 5px;
167
+ font-size: 14px;
168
+ }
169
+ .window-content {
170
+ padding: 10px;
171
+ overflow-y: auto;
172
+ max-height: calc(100% - 40px);
173
+ }
174
+
175
+ /* Resizer Styles */
176
+ .resizer {
177
+ position: absolute;
178
+ background: transparent;
179
+ z-index: 10;
180
+ }
181
+ .resizer.top { top: -5px; left: 0; width: 100%; height: 10px; cursor: ns-resize; }
182
+ .resizer.right { right: -5px; top: 0; width: 10px; height: 100%; cursor: ew-resize; }
183
+ .resizer.bottom { bottom: -5px; left: 0; width: 100%; height: 10px; cursor: ns-resize; }
184
+ .resizer.left { left: -5px; top: 0; width: 10px; height: 100%; cursor: ew-resize; }
185
+ .resizer.top-left { top: -5px; left: -5px; width: 10px; height: 10px; cursor: nwse-resize; }
186
+ .resizer.top-right { top: -5px; right: -5px; width: 10px; height: 10px; cursor: nesw-resize; }
187
+ .resizer.bottom-left { bottom: -5px; left: -5px; width: 10px; height: 10px; cursor: nesw-resize; }
188
+ .resizer.bottom-right { bottom: -5px; right: -5px; width: 10px; height: 10px; cursor: nwse-resize; }
189
+
190
+ /* Custom Context Menu */
191
+ #custom-context-menu {
192
+ position: absolute;
193
+ display: none;
194
+ background: #fff;
195
+ border: 1px solid #ccc;
196
+ z-index: 5000;
197
+ box-shadow: 2px 2px 10px rgba(0,0,0,0.5);
198
+ }
199
+ #custom-context-menu ul { list-style: none; }
200
+ #custom-context-menu li {
201
+ padding: 8px 12px;
202
+ cursor: pointer;
203
+ }
204
+ #custom-context-menu li:hover {
205
+ background: #f0f0f0;
206
+ }
207
+
208
+ /* Customizer Form */
209
+ .customizer-form label {
210
+ display: block;
211
+ margin: 5px 0 2px;
212
+ }
213
+ .customizer-form input,
214
+ .customizer-form textarea {
215
+ width: 100%;
216
+ padding: 5px;
217
+ margin-bottom: 10px;
218
+ }
219
+ .customizer-form button {
220
+ padding: 5px 10px;
221
+ cursor: pointer;
222
+ }
223
+ </style>
224
+ </head>
225
+ <body>
226
+ <!-- A style element for custom CSS -->
227
+ <style id="custom-css"></style>
228
+
229
+ <!-- Desktop -->
230
+ <div id="desktop">
231
+ <div id="desktop-icons">
232
+ <!-- Built-In App Icons (updated via JS) -->
233
+ </div>
234
+ </div>
235
+
236
+ <!-- Taskbar -->
237
+ <div id="taskbar">
238
+ <div id="taskbar-left">
239
+ <button id="start-button">Start</button>
240
+ <div id="taskbar-pinned">
241
+ <!-- Built-In Pinned Apps -->
242
+ </div>
243
+ <div id="taskbar-windows">
244
+ <!-- Running windows: each window gets its own tab (only icon) -->
245
+ </div>
246
+ </div>
247
+ <div id="taskbar-right">
248
+ <!-- Current Time Display -->
249
+ </div>
250
+ </div>
251
+
252
+ <!-- Start Menu -->
253
+ <div id="start-menu">
254
+ <ul id="start-menu-list">
255
+ <!-- Built-In Start Menu Items -->
256
+ </ul>
257
+ </div>
258
+
259
+ <!-- Custom Context Menu (Right-Click on Desktop) -->
260
+ <div id="custom-context-menu">
261
+ <ul>
262
+ <li data-custom="openCustomizer">Open Customizer</li>
263
+ <li data-custom="reset">Reset Customizations</li>
264
+ </ul>
265
+ </div>
266
+
267
+ <script>
268
+ /***** Global Variables *****/
269
+ let windowCounter = 1;
270
+ let runningWindows = {}; // Mapping windowId -> window element
271
+ let zIndexCounter = 300; // For layering windows
272
+
273
+ // Built-In Apps Array (always present)
274
+ const builtInApps = [
275
+ { id: "appInstaller", name: "App Installer", icon: "πŸ› " },
276
+ { id: "customizer", name: "Customizer", icon: "🎨" }
277
+ ];
278
+
279
+ /***** Utility Functions *****/
280
+ // Retrieve installed apps from localStorage (excluding built-ins)
281
+ function getInstalledApps() {
282
+ let apps = [];
283
+ for (let i = 0; i < localStorage.length; i++) {
284
+ let key = localStorage.key(i);
285
+ if (key.startsWith("app_")) {
286
+ try { apps.push(JSON.parse(localStorage.getItem(key))); }
287
+ catch(e) { console.error(e); }
288
+ }
289
+ }
290
+ return apps;
291
+ }
292
+
293
+ // Update Desktop Icons: built-in apps first, then installed apps
294
+ function updateDesktopIcons() {
295
+ const container = document.getElementById("desktop-icons");
296
+ container.innerHTML = "";
297
+ builtInApps.forEach(app => {
298
+ let icon = document.createElement("div");
299
+ icon.className = "icon";
300
+ icon.setAttribute("data-app", app.id);
301
+ icon.innerHTML = `${app.icon}<br>${app.name}`;
302
+ icon.onclick = () => openApp(app.id);
303
+ container.appendChild(icon);
304
+ });
305
+ let apps = getInstalledApps();
306
+ apps.forEach(app => {
307
+ if (!builtInApps.find(b => b.id === app.id)) {
308
+ let icon = document.createElement("div");
309
+ icon.className = "icon";
310
+ icon.setAttribute("data-app", app.id);
311
+ icon.innerHTML = `${app.icon || 'πŸ”³'}<br>${app.name}`;
312
+ icon.onclick = () => launchInstalledApp(app.id);
313
+ container.appendChild(icon);
314
+ }
315
+ });
316
+ }
317
+
318
+ // Update Start Menu Items
319
+ function updateStartMenuApps() {
320
+ const list = document.getElementById("start-menu-list");
321
+ list.innerHTML = "";
322
+ builtInApps.forEach(app => {
323
+ let li = document.createElement("li");
324
+ li.setAttribute("data-app", app.id);
325
+ li.innerHTML = `${app.icon} ${app.name}`;
326
+ li.onclick = () => { openApp(app.id); hideStartMenu(); };
327
+ list.appendChild(li);
328
+ });
329
+ let apps = getInstalledApps();
330
+ apps.forEach(app => {
331
+ if (!builtInApps.find(b => b.id === app.id)) {
332
+ let li = document.createElement("li");
333
+ li.setAttribute("data-app", app.id);
334
+ li.innerHTML = `${app.icon || 'πŸ”³'} ${app.name}`;
335
+ li.onclick = () => { launchInstalledApp(app.id); hideStartMenu(); };
336
+ list.appendChild(li);
337
+ }
338
+ });
339
+ }
340
+
341
+ // Update Pinned Apps in Taskbar (built-in apps)
342
+ function updateTaskbarPinned() {
343
+ const container = document.getElementById("taskbar-pinned");
344
+ container.innerHTML = "";
345
+ builtInApps.forEach(app => {
346
+ let btn = document.createElement("button");
347
+ btn.setAttribute("data-app", app.id);
348
+ btn.title = app.name;
349
+ btn.innerHTML = `${app.icon}`;
350
+ btn.onclick = () => openApp(app.id);
351
+ container.appendChild(btn);
352
+ });
353
+ }
354
+
355
+ // Update all system apps UI
356
+ function updateSystemAppsUI() {
357
+ updateDesktopIcons();
358
+ updateStartMenuApps();
359
+ updateTaskbarPinned();
360
+ }
361
+
362
+ function hideStartMenu() {
363
+ document.getElementById("start-menu").style.display = "none";
364
+ }
365
+
366
+ /***** Start Menu Toggle *****/
367
+ const startButton = document.getElementById("start-button");
368
+ const startMenu = document.getElementById("start-menu");
369
+ startButton.addEventListener("click", (e) => {
370
+ e.stopPropagation();
371
+ startMenu.style.display = startMenu.style.display === "block" ? "none" : "block";
372
+ });
373
+ document.addEventListener("click", (e) => {
374
+ if (!startMenu.contains(e.target) && e.target !== startButton) {
375
+ hideStartMenu();
376
+ }
377
+ document.getElementById("custom-context-menu").style.display = "none";
378
+ });
379
+
380
+ /***** Window Creation, Resizing & Controls *****/
381
+ function createWindow(title, contentHTML = "", customControls = null) {
382
+ const win = document.createElement("div");
383
+ win.classList.add("window");
384
+ win.style.top = "100px";
385
+ win.style.left = "100px";
386
+ win.style.width = "400px";
387
+ win.style.height = "300px";
388
+ win.dataset.windowId = windowCounter++;
389
+ win.dataset.maximized = "false";
390
+
391
+ const header = document.createElement("div");
392
+ header.classList.add("window-header");
393
+ let iconHTML = "";
394
+ if(win.dataset.appIcon) {
395
+ iconHTML = `<span class="app-icon">${win.dataset.appIcon}</span>`;
396
+ }
397
+ let controlsHTML = customControls ? customControls : "<button class='minimize-btn'>_</button><button class='maximize-btn'>[ ]</button><button class='close'>X</button>";
398
+ header.innerHTML = `${iconHTML}<span class="title">${title}</span><span class="controls">${controlsHTML}</span>`;
399
+ win.appendChild(header);
400
+
401
+ const content = document.createElement("div");
402
+ content.classList.add("window-content");
403
+ content.innerHTML = contentHTML;
404
+ win.appendChild(content);
405
+
406
+ // Add resizers for all edges/corners
407
+ makeResizable(win);
408
+
409
+ document.body.appendChild(win);
410
+ win.addEventListener("mousedown", () => bringToFront(win));
411
+ makeDraggable(win, header);
412
+ bringToFront(win);
413
+
414
+ const minimizeBtn = header.querySelector(".minimize-btn");
415
+ if(minimizeBtn) { minimizeBtn.addEventListener("click", () => minimizeWindow(win)); }
416
+ const maximizeBtn = header.querySelector(".maximize-btn");
417
+ if(maximizeBtn) { maximizeBtn.addEventListener("click", () => toggleMaximizeWindow(win, maximizeBtn)); }
418
+ const closeBtn = header.querySelector(".close");
419
+ if(closeBtn) { closeBtn.addEventListener("click", () => closeWindow(win)); }
420
+
421
+ // Create taskbar button after appIcon is set (if not already created)
422
+ createTaskbarWindowButton(win);
423
+ runningWindows[win.dataset.windowId] = win;
424
+ return win;
425
+ }
426
+
427
+ function makeDraggable(win, handle) {
428
+ let offsetX = 0, offsetY = 0;
429
+ handle.addEventListener("mousedown", function(e) {
430
+ if(win.dataset.maximized === "true") return;
431
+ offsetX = e.clientX - win.offsetLeft;
432
+ offsetY = e.clientY - win.offsetTop;
433
+ document.addEventListener("mousemove", mouseMove);
434
+ document.addEventListener("mouseup", mouseUp);
435
+ });
436
+ function mouseMove(e) {
437
+ let newLeft = e.clientX - offsetX;
438
+ let newTop = e.clientY - offsetY;
439
+ const desktopRect = document.getElementById("desktop").getBoundingClientRect();
440
+ if(newLeft < 0) newLeft = 0;
441
+ if(newTop < 0) newTop = 0;
442
+ if(newLeft + win.offsetWidth > desktopRect.width) newLeft = desktopRect.width - win.offsetWidth;
443
+ if(newTop + win.offsetHeight > desktopRect.height) newTop = desktopRect.height - win.offsetHeight;
444
+ win.style.left = newLeft + "px";
445
+ win.style.top = newTop + "px";
446
+ }
447
+ function mouseUp() {
448
+ document.removeEventListener("mousemove", mouseMove);
449
+ document.removeEventListener("mouseup", mouseUp);
450
+ }
451
+ }
452
+
453
+ function makeResizable(win) {
454
+ const directions = ["top", "right", "bottom", "left", "top-left", "top-right", "bottom-left", "bottom-right"];
455
+ directions.forEach(direction => {
456
+ const resizer = document.createElement("div");
457
+ resizer.classList.add("resizer", direction);
458
+ win.appendChild(resizer);
459
+ resizer.addEventListener("mousedown", initResize);
460
+ function initResize(e) {
461
+ e.preventDefault();
462
+ e.stopPropagation();
463
+ const startX = e.clientX;
464
+ const startY = e.clientY;
465
+ const startWidth = parseInt(document.defaultView.getComputedStyle(win).width, 10);
466
+ const startHeight = parseInt(document.defaultView.getComputedStyle(win).height, 10);
467
+ const startLeft = win.offsetLeft;
468
+ const startTop = win.offsetTop;
469
+ const desktopRect = document.getElementById("desktop").getBoundingClientRect();
470
+ function doResize(e) {
471
+ let dx = e.clientX - startX;
472
+ let dy = e.clientY - startY;
473
+ let newWidth = startWidth;
474
+ let newHeight = startHeight;
475
+ let newLeft = startLeft;
476
+ let newTop = startTop;
477
+ if(direction.includes("right")) {
478
+ newWidth = startWidth + dx;
479
+ }
480
+ if(direction.includes("left")) {
481
+ newWidth = startWidth - dx;
482
+ newLeft = startLeft + dx;
483
+ }
484
+ if(direction.includes("bottom")) {
485
+ newHeight = startHeight + dy;
486
+ }
487
+ if(direction.includes("top")) {
488
+ newHeight = startHeight - dy;
489
+ newTop = startTop + dy;
490
+ }
491
+ if(newLeft < 0) { newWidth += newLeft; newLeft = 0; }
492
+ if(newTop < 0) { newHeight += newTop; newTop = 0; }
493
+ if(newLeft + newWidth > desktopRect.width) newWidth = desktopRect.width - newLeft;
494
+ if(newTop + newHeight > desktopRect.height) newHeight = desktopRect.height - newTop;
495
+ const minWidth = 100, minHeight = 50;
496
+ if(newWidth < minWidth) {
497
+ newWidth = minWidth;
498
+ if(direction.includes("left")) { newLeft = startLeft + (startWidth - minWidth); }
499
+ }
500
+ if(newHeight < minHeight) {
501
+ newHeight = minHeight;
502
+ if(direction.includes("top")) { newTop = startTop + (startHeight - minHeight); }
503
+ }
504
+ win.style.width = newWidth + "px";
505
+ win.style.height = newHeight + "px";
506
+ win.style.left = newLeft + "px";
507
+ win.style.top = newTop + "px";
508
+ }
509
+ function stopResize() {
510
+ document.removeEventListener("mousemove", doResize);
511
+ document.removeEventListener("mouseup", stopResize);
512
+ }
513
+ document.addEventListener("mousemove", doResize);
514
+ document.addEventListener("mouseup", stopResize);
515
+ }
516
+ });
517
+ }
518
+
519
+ function bringToFront(win) {
520
+ zIndexCounter++;
521
+ win.style.zIndex = zIndexCounter;
522
+ }
523
+
524
+ function minimizeWindow(win) {
525
+ win.style.display = "none";
526
+ }
527
+
528
+ function restoreWindow(win) {
529
+ win.style.display = "block";
530
+ bringToFront(win);
531
+ }
532
+
533
+ function toggleMaximizeWindow(win, btn) {
534
+ if(win.dataset.maximized === "true") {
535
+ win.style.top = win.dataset.originalTop;
536
+ win.style.left = win.dataset.originalLeft;
537
+ win.style.width = win.dataset.originalWidth;
538
+ win.style.height = win.dataset.originalHeight;
539
+ win.dataset.maximized = "false";
540
+ } else {
541
+ win.dataset.originalTop = win.style.top;
542
+ win.dataset.originalLeft = win.style.left;
543
+ win.dataset.originalWidth = win.style.width;
544
+ win.dataset.originalHeight = win.style.height;
545
+ win.style.top = "0";
546
+ win.style.left = "0";
547
+ win.style.width = "100%";
548
+ win.style.height = "100%";
549
+ win.dataset.maximized = "true";
550
+ }
551
+ }
552
+
553
+ function closeWindow(win) {
554
+ const winId = win.dataset.windowId;
555
+ const taskbarWindows = document.getElementById("taskbar-windows");
556
+ const btn = taskbarWindows.querySelector(`button[data-window-id="${winId}"]`);
557
+ if(btn) { btn.remove(); }
558
+ delete runningWindows[winId];
559
+ win.remove();
560
+ }
561
+
562
+ // Create a taskbar button for each running window – only icon is shown
563
+ function createTaskbarWindowButton(win) {
564
+ const taskbarWindows = document.getElementById("taskbar-windows");
565
+ let btn = document.createElement("button");
566
+ btn.classList.add("taskbar-window-btn");
567
+ btn.setAttribute("data-window-id", win.dataset.windowId);
568
+ let icon = win.dataset.appIcon || 'πŸ”³';
569
+ btn.innerHTML = `<span class="taskbar-icon">${icon}</span>`;
570
+ btn.onclick = () => {
571
+ if(win.style.display === "none") { restoreWindow(win); }
572
+ else { bringToFront(win); }
573
+ };
574
+ taskbarWindows.appendChild(btn);
575
+ }
576
+
577
+ // Update window header to include app icon if available
578
+ function updateWindowHeaderIcon(win) {
579
+ const header = win.querySelector('.window-header');
580
+ if(header && win.dataset.appIcon) {
581
+ if(!header.querySelector('.app-icon')) {
582
+ let iconSpan = document.createElement("span");
583
+ iconSpan.className = "app-icon";
584
+ iconSpan.style.marginRight = "5px";
585
+ iconSpan.innerText = win.dataset.appIcon;
586
+ const titleElem = header.querySelector(".title");
587
+ if(titleElem) { header.insertBefore(iconSpan, titleElem); }
588
+ }
589
+ }
590
+ }
591
+
592
+ /***** Built-In Apps & Open Functions *****/
593
+ function openApp(appId) {
594
+ if(appId === "appInstaller") {
595
+ createAppInstaller();
596
+ } else if(appId === "customizer") {
597
+ createCustomizerApp();
598
+ } else {
599
+ launchInstalledApp(appId);
600
+ }
601
+ }
602
+
603
+ // Built-In App: App Installer
604
+ function createAppInstaller() {
605
+ const win = createWindow("App Installer", "");
606
+ win.dataset.appId = "appInstaller";
607
+ win.dataset.appIcon = "πŸ› ";
608
+ updateWindowHeaderIcon(win);
609
+ createTaskbarWindowButton(win);
610
+ const content = document.createElement("div");
611
+ content.innerHTML = `
612
+ <h3>Install App</h3>
613
+ <textarea id="app-json" placeholder="Paste App JSON here"></textarea><br>
614
+ <button id="install-app-btn">Install</button>
615
+ <hr>
616
+ <h3>Installed Apps (LocalStorage)</h3>
617
+ <div id="installed-apps-list"></div>
618
+ `;
619
+ win.querySelector(".window-content").appendChild(content);
620
+ win.querySelector("#install-app-btn").addEventListener("click", () => {
621
+ installApp();
622
+ updateSystemAppsUI();
623
+ loadInstalledAppsList();
624
+ });
625
+ loadInstalledAppsList();
626
+ }
627
+
628
+ // Built-In App: Customizer
629
+ function createCustomizerApp() {
630
+ const win = createWindow("Customizer", "");
631
+ win.dataset.appId = "customizer";
632
+ win.dataset.appIcon = "🎨";
633
+ updateWindowHeaderIcon(win);
634
+ createTaskbarWindowButton(win);
635
+ const content = document.createElement("div");
636
+ content.innerHTML = `
637
+ <h3>Customize System</h3>
638
+ <div class="customizer-form">
639
+ <label for="desktop-bg-color">Desktop Background Color:</label>
640
+ <input type="color" id="desktop-bg-color" value="#ffffff">
641
+ <label for="desktop-bg-image">Desktop Background Image URL:</label>
642
+ <input type="text" id="desktop-bg-image" placeholder="Image URL">
643
+ <hr>
644
+ <label for="taskbar-bg-color">Taskbar Background Color:</label>
645
+ <input type="color" id="taskbar-bg-color" value="#0078d7">
646
+ <label for="taskbar-height">Taskbar Height (px):</label>
647
+ <input type="number" id="taskbar-height" value="40">
648
+ <hr>
649
+ <label for="startmenu-bg-color">Start Menu Background Color:</label>
650
+ <input type="color" id="startmenu-bg-color" value="#ffffff">
651
+ <label for="startmenu-text-color">Start Menu Text Color:</label>
652
+ <input type="color" id="startmenu-text-color" value="#000000">
653
+ <hr>
654
+ <label for="custom-css-input">Custom CSS:</label>
655
+ <textarea id="custom-css-input" placeholder="Enter your custom CSS here"></textarea><br>
656
+ <button onclick="applyAllCustomizations()">Apply Customizations</button>
657
+ </div>
658
+ `;
659
+ win.querySelector(".window-content").appendChild(content);
660
+ }
661
+
662
+ // Apply all customizations from Customizer app
663
+ function applyAllCustomizations() {
664
+ const desktopBgColor = document.getElementById("desktop-bg-color").value;
665
+ const desktopBgImage = document.getElementById("desktop-bg-image").value;
666
+ let desktopBgStyle = desktopBgColor;
667
+ if(desktopBgImage.trim() !== "") { desktopBgStyle = `url('${desktopBgImage}')`; }
668
+ document.getElementById("desktop").style.background = desktopBgStyle;
669
+ document.getElementById("desktop").style.backgroundSize = "cover";
670
+
671
+ const taskbarBgColor = document.getElementById("taskbar-bg-color").value;
672
+ const taskbarHeight = document.getElementById("taskbar-height").value;
673
+ document.getElementById("taskbar").style.background = taskbarBgColor;
674
+ document.getElementById("taskbar").style.height = taskbarHeight + "px";
675
+
676
+ const startmenuBgColor = document.getElementById("startmenu-bg-color").value;
677
+ const startmenuTextColor = document.getElementById("startmenu-text-color").value;
678
+ document.getElementById("start-menu").style.background = startmenuBgColor;
679
+ document.getElementById("start-menu").style.color = startmenuTextColor;
680
+
681
+ const customCss = document.getElementById("custom-css-input").value;
682
+ document.getElementById("custom-css").innerHTML = customCss;
683
+
684
+ alert("Customizations applied!");
685
+ }
686
+
687
+ // Launch Installed App (from localStorage)
688
+ function launchInstalledApp(appId) {
689
+ const key = "app_" + appId;
690
+ let appData = JSON.parse(localStorage.getItem(key));
691
+ if (!appData) return;
692
+ const win = createWindow(appData.name, appData.ui, appData.windowControls);
693
+ win.dataset.appId = appData.id;
694
+ win.dataset.appIcon = appData.icon || 'πŸ”³';
695
+ updateWindowHeaderIcon(win);
696
+ createTaskbarWindowButton(win);
697
+ if(appData.methods) {
698
+ let appMethods = {};
699
+ for(let method in appData.methods) {
700
+ try {
701
+ appMethods[method] = new Function("return " + appData.methods[method])();
702
+ } catch(e) {
703
+ console.error("Error in method", method, e);
704
+ }
705
+ }
706
+ window.app = { methods: appMethods };
707
+ }
708
+ }
709
+
710
+ // Load Installed Apps List in App Installer
711
+ function loadInstalledAppsList() {
712
+ const container = document.getElementById("installed-apps-list");
713
+ if(container) {
714
+ let apps = getInstalledApps();
715
+ container.innerHTML = apps.map(app => `<div>${app.icon || 'πŸ”³'} ${app.name}</div>`).join("");
716
+ }
717
+ }
718
+
719
+ // Install App from JSON input in App Installer
720
+ function installApp() {
721
+ let appData;
722
+ const jsonText = document.getElementById("app-json").value;
723
+ try { appData = JSON.parse(jsonText); }
724
+ catch (error) { alert("Invalid JSON. Please check your syntax."); return; }
725
+ if (!appData.id) { alert("App JSON must contain an 'id' property."); return; }
726
+ localStorage.setItem("app_" + appData.id, JSON.stringify(appData));
727
+ alert("App installed successfully!");
728
+ document.getElementById("app-json").value = "";
729
+ }
730
+
731
+ /***** Custom Context Menu & Shortcut *****/
732
+ const customContextMenu = document.getElementById("custom-context-menu");
733
+ document.getElementById("desktop").addEventListener("contextmenu", function(e) {
734
+ e.preventDefault();
735
+ customContextMenu.style.display = "block";
736
+ customContextMenu.style.top = e.clientY + "px";
737
+ customContextMenu.style.left = e.clientX + "px";
738
+ });
739
+ customContextMenu.addEventListener("click", function(e) {
740
+ const option = e.target.getAttribute("data-custom");
741
+ if(option === "openCustomizer") {
742
+ openApp("customizer");
743
+ } else if(option === "reset") {
744
+ document.getElementById("desktop").style.background = "url('background.jpg') no-repeat center center fixed";
745
+ document.getElementById("desktop").style.backgroundSize = "cover";
746
+ document.getElementById("taskbar").style.background = "rgba(0,0,0,0.8)";
747
+ document.getElementById("taskbar").style.height = "40px";
748
+ document.getElementById("start-menu").style.background = "#fff";
749
+ document.getElementById("start-menu").style.color = "#000";
750
+ document.getElementById("custom-css").innerHTML = "";
751
+ alert("Customizations reset to default!");
752
+ }
753
+ customContextMenu.style.display = "none";
754
+ });
755
+
756
+ /***** Current Time Display *****/
757
+ function updateTime() {
758
+ const timeElem = document.getElementById("taskbar-right");
759
+ const now = new Date();
760
+ timeElem.innerText = now.toLocaleTimeString();
761
+ }
762
+ setInterval(updateTime, 1000);
763
+ updateTime();
764
+
765
+ /***** Attach Static Events for Built-In Apps *****/
766
+ document.addEventListener("DOMContentLoaded", () => {
767
+ updateSystemAppsUI();
768
+ });
769
+ </script>
770
+ </body>
771
  </html>