-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
323 lines (263 loc) · 12.2 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>validOS</title>
<link rel="stylesheet" href="./style.css">
<link rel="preload" href="./assets/frameworks/winbox.bundle.min.js" as="script">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
<!-- used for preprocessing css -->
<script src="https://cdn.tailwindcss.com"></script>
<style type="text/tailwindcss">
._app {
@apply hover:scale-125 duration-100 rounded-full top-0 transition-transform
transform hover:-translate-y-1;
}
</style>
</head>
<body>
<div id="splash-screen">
<div class="splash-content">
<h1 class="rounded-xl px-4 py-2 text-6xl font-bold text-white bg-gradient-to-tr from-10% from-sky-500 to-emerald-500
text-transparent">
validOS
</h1>
<p class="text-lg text-white mt-2">Continuation of nullOS</p>
<p class="text-sm text-white">Version 1.1.4</p>
</div>
</div>
<div class="topnav">
<div id="clock" class="__box_dark text-center duration-500" onclick="toggleTimeMode()" style="cursor: pointer;">
<span id="clock-data" class="text-center">...</span>
</div>
<div class="__box_dark duration-500" id="battery_container">
<span class="material-symbols-outlined text-base">battery_full</span>
<span id="battery" class="text-base">...</span>
</div>
<div class="__box_dark duration-500" id="wifi_container">
<span class="material-symbols-outlined text-base px-2" id="wifi">help</span>
</div>
</div>
<div id="taskbar" class="taskbar_dark duration-500"></div>
<script src="./assets/frameworks/winbox.bundle.min.js" async></script>
<script>
async function drawTaskbar() {
const res = await fetch("./apps.json");
const apps = await res.json();
apps.map((app) => {
const tb = document.getElementById("taskbar");
const node = document.createElement("div");
node.classList.add("app-icon")
node.onclick = () => { openApp(app.aurl, app.name) };
const img = document.createElement('img')
img.setAttribute('src', `./assets/images/${app.icon}`)
img.setAttribute('alt', app.name)
img.classList.add('_app')
node.appendChild(img)
const span = document.createElement('span')
span.classList.add('app-name')
span.innerText = app.name
node.appendChild(span)
tb.appendChild(node);
})
}
(async () => {
await drawTaskbar();
})();
// Function to open apps
function openApp(url, appName) {
// Create a new WinBox window for other apps
const win = new WinBox({
title: appName,
url: url,
width: '80%',
height: '80%',
border: '0.1em',
minheight: 350,
minwidth: 350,
background: "#363636"
});
// Optional: You can focus on the new window if desired
win.focus();
}
// Function to handle drag start
function drag(event) {
event.dataTransfer.setData('text/plain', event.target.id);
}
// Function to handle drag over and drop
function allowDrop(event) {
event.preventDefault();
}
// Function to handle drop
function drop(event) {
event.preventDefault();
const draggedAppId = event.dataTransfer.getData('text/plain');
const draggedApp = document.getElementById(draggedAppId);
const taskbar = document.getElementById('taskbar');
// Insert the dragged element before the drop target
taskbar.insertBefore(draggedApp, event.target);
// Update the order and save to localStorage
updateOrder();
}
// Function to get the order of icons from localStorage
function getOrder() {
const order = localStorage.getItem('appOrder');
return order ? JSON.parse(order) : [];
}
// Function to set the order of icons in localStorage
function setOrder(order) {
localStorage.setItem('appOrder', JSON.stringify(order));
}
// Function to update the order of icons
function updateOrder() {
const appOrder = Array.from(document.querySelectorAll('.app-icon')).map(icon => icon.id);
setOrder(appOrder);
}
// Set initial order or load from localStorage
const appOrder = getOrder();
// Set the order of icons
function setIconOrder() {
appOrder.forEach((appId, index) => {
const appIcon = document.getElementById(appId);
if (appIcon) {
appIcon.style.order = index;
}
});
}
// Set the initial order
setIconOrder();
// Function to load customCSS from localStorage and set it as background
function loadCustomCSS() {
const customCSS = localStorage.getItem('customCSS');
if (customCSS) {
document.body.style.backgroundImage = customCSS;
} else {
document.body.style.backgroundImage = "./assets/wallpaper/Bluesdark.png";
}
}
// Load customCSS on page load
loadCustomCSS();
// Add a class to the body to make it unclickable during the loading period
document.body.classList.add('unclickable');
// Simulate a loading time and hide the splash screen after 2 seconds (adjust as needed)
setTimeout(function () {
const splashScreen = document.getElementById('splash-screen');
splashScreen.style.transition = "opacity 1s ease-in-out";
splashScreen.style.opacity = 0;
// TODO: make this better or something
setTimeout(function () {
document.getElementById("splash-screen").style.display = 'none';
}, 1000)
// Remove the unclickable class to make the body clickable again
document.body.classList.remove('unclickable');
}, 2500); // 5000 milliseconds = 5 seconds
function updateClock() {
// Thanks https://stackoverflow.com/questions/8888491/how-do-you-display-javascript-datetime-in-12-hour-am-pm-format
const clock = document.getElementById('clock-data');
const date = new Date();
let strTime;
if (localStorage.getItem("timeMode") === "standard") {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
strTime = hours + ':' + minutes + ' ' + ampm;
clock.innerText = strTime;
clock.title = "Standard Time"
return
}
const hrs = date.getHours().toString().padStart(2, '0');
const mins = date.getMinutes().toString().padStart(2, '0');
strTime = `${hrs}:${mins}`;
clock.innerText = strTime;
clock.title = "Military Time"
}
function toggleTimeMode() {
if (localStorage.getItem("timeMode") === "standard") {
localStorage.setItem("timeMode", "military");
updateClock();
} else {
localStorage.setItem("timeMode", "standard");
updateClock();
}
}
function updateUI() {
const clockShown = localStorage.getItem("showClock")
const batteryShown = localStorage.getItem("showBattery")
const wifiShown = localStorage.getItem("showWifi")
if (clockShown == "true") {
document.getElementById("clock").style.display = "flex"
} else {
document.getElementById("clock").style.display = "none"
}
if (batteryShown == "true") {
document.getElementById("battery_container").style.display = "flex"
} else {
document.getElementById("battery_container").style.display = "none"
}
if (wifiShown == "true") {
document.getElementById("wifi_container").style.display = "flex"
} else {
document.getElementById("wifi_container").style.display = "none"
}
}
updateUI();
if (!localStorage.getItem("timeMode")) {
localStorage.setItem("timeMode", "standard");
}
setInterval(updateClock, 60000);
updateClock();
navigator.getBattery().then((battery) => {
battery.addEventListener('levelchange', () => {
document.getElementById("battery").innerText = `${Math.floor(battery.level * 100)}%`
})
document.getElementById("battery").innerText = `${Math.floor(battery.level * 100)}%`
})
if (window.navigator.onLine) {
document.getElementById("wifi").innerText = "wifi"
} else {
document.getElementById("wifi").innerText = "wifi_off"
}
window.addEventListener('online', () => document.getElementById("wifi").innerText = "wifi");
window.addEventListener('offline', () => document.getElementById("wifi").innerText = "wifi_off");
function applyTheme() {
const theme = localStorage.getItem("theme");
// TODO: clean up this disastrous shit
if (theme === "light") {
document.getElementById("taskbar").classList.remove("taskbar_dark")
document.getElementById("taskbar").classList.add("taskbar_light") // Light theme background color
document.getElementById("wifi_container").classList.add("__box_light")
document.getElementById("wifi_container").classList.remove("__box_dark")
document.getElementById("clock").classList.add("__box_light")
document.getElementById("clock").classList.remove("__box_dark")
document.getElementById("battery_container").classList.add("__box_light")
document.getElementById("battery_container").classList.remove("__box_dark")
} else {
document.getElementById("taskbar").classList.remove("taskbar_light")
document.getElementById("taskbar").classList.add("taskbar_dark") // Light theme background color
document.getElementById("wifi_container").classList.add("__box_dark")
document.getElementById("wifi_container").classList.remove("__box_light")
document.getElementById("clock").classList.add("__box_dark")
document.getElementById("clock").classList.remove("__box_light")
document.getElementById("battery_container").classList.add("__box_dark")
document.getElementById("battery_container").classList.remove("__box_light")
}
}
applyTheme(); // Apply theme on page load
const win = new WinBox({
title: "Get Started",
modal: true,
url: "./getstarted.html",
width: '60%',
height: '60%',
border: '0.1em',
minheight: 350,
minwidth: 350,
background: "#363636"
});
</script>
</body>
</html>