|
1 | 1 | import HTML from '../HTML' |
2 | | -import { AppClosedEvent, AppOpenedEvent, Process } from '../types' |
3 | | -import { getTime } from '../utils' |
| 2 | +import { Process } from '../types' |
4 | 3 | import nullIcon from '../assets/icons/application-default-icon.svg' |
5 | 4 |
|
6 | 5 | const BootLoader: Process = { |
@@ -62,80 +61,10 @@ const BootLoader: Process = { |
62 | 61 |
|
63 | 62 | const statusBar = await process.loadLibrary('lib/StatusBar') |
64 | 63 |
|
65 | | - statusBar.element.html(` |
66 | | - <div class="outlined" data-toolbar-id="start"><span class="material-symbols-rounded">space_dashboard</span></div> |
67 | | - |
68 | | - <div data-toolbar-id="apps"></div> |
69 | | - <flex></flex> |
70 | | - <div class="outlined" data-toolbar-id="plugins"><span class="material-symbols-rounded">expand_less</span></div> |
71 | | - <div class="outlined" data-toolbar-id="controls"> |
72 | | - <span class="material-symbols-rounded battery">battery_2_bar</span> |
73 | | - <span class="material-symbols-rounded signal">signal_cellular_4_bar</span> |
74 | | - </div> |
75 | | - <div class="outlined" data-toolbar-id="calendar"></div> |
76 | | - |
77 | | - `) |
78 | | - |
79 | | - setInterval((): any => { |
80 | | - getTime().then((time) => { |
81 | | - statusBar.element.qs('div[data-toolbar-id="calendar"]')?.text(time) |
82 | | - }).catch(e => console.error) |
83 | | - }, 1000) |
84 | | - |
85 | 64 | statusBar.element.qs('div[data-toolbar-id="start"]')?.on('click', () => { |
86 | 65 | launcher.toggle() |
87 | 66 | }) |
88 | 67 |
|
89 | | - if ('getBattery' in navigator) { |
90 | | - (navigator as any).getBattery().then((battery: any) => { |
91 | | - statusBar.updateBatteryIcon(battery) |
92 | | - |
93 | | - battery.addEventListener('levelchange', () => { |
94 | | - statusBar.updateBatteryIcon(battery) |
95 | | - }) |
96 | | - |
97 | | - battery.addEventListener('chargingchange', () => { |
98 | | - statusBar.updateBatteryIcon(battery) |
99 | | - }) |
100 | | - }) |
101 | | - } else { |
102 | | - const batteryDiv = document.querySelector('div[data-toolbar-id="controls"] > .battery') |
103 | | - if (batteryDiv != null) { |
104 | | - batteryDiv.innerHTML = 'battery_unknown' |
105 | | - } |
106 | | - } |
107 | | - |
108 | | - async function ping (startTime: number): Promise<void> { |
109 | | - fetch(`${process.kernel.config.SERVER as string}/bare/`) |
110 | | - .then(() => { |
111 | | - const endTime = performance.now() |
112 | | - const pingTime = endTime - startTime |
113 | | - statusBar.updateIcon(pingTime) |
114 | | - }) |
115 | | - .catch(() => { |
116 | | - (document.querySelector('div[data-toolbar-id="controls"] > .signal') as HTMLElement).innerHTML = 'signal_cellular_connected_no_internet_4_bar' |
117 | | - }) |
118 | | - } |
119 | | - |
120 | | - setInterval((): any => ping(performance.now()), 10_000) |
121 | | - |
122 | | - document.addEventListener('app_opened', (e: AppOpenedEvent): void => { |
123 | | - new HTML('app').appendMany( |
124 | | - new HTML('img').attr({ |
125 | | - alt: `${e.detail.proc.config.name} icon`, |
126 | | - 'data-id': e.detail.token, |
127 | | - src: e.detail.proc.config.icon ?? nullIcon |
128 | | - }).on('click', () => { |
129 | | - e.detail.win.focus() |
130 | | - e.detail.win.toggleMin() |
131 | | - }) |
132 | | - ).appendTo(statusBar.element.qs('div[data-toolbar-id="apps"]')?.elm as HTMLElement) |
133 | | - }) |
134 | | - |
135 | | - document.addEventListener('app_closed', (e: AppClosedEvent): void => { |
136 | | - statusBar.element.qs('div[data-toolbar-id="apps"]')?.qs(`img[data-id="${e.detail.token}"]`)?.elm.parentElement?.remove() |
137 | | - }) |
138 | | - |
139 | 68 | document.body.style.flexDirection = 'column-reverse' |
140 | 69 |
|
141 | 70 | await statusBar.element.appendTo(document.body) |
|
0 commit comments