| 193 | } |
| 194 | |
| 195 | function init() { |
| 196 | cockpit.translate(); |
| 197 | |
| 198 | /* Give us a name. This used to (maybe) indicate at some point to |
| 199 | * child frames that we are a cockpit1 router frame. But they |
| 200 | * actually check for a "cockpit1:" prefix of their own name. |
| 201 | */ |
| 202 | window.name = "cockpit1"; |
| 203 | |
| 204 | /* Tell the pages about our features. */ |
| 205 | (window as ShellWindow).features = { |
| 206 | navbar_is_for_current_machine: true |
| 207 | }; |
| 208 | |
| 209 | function follow(arg: unknown) { |
| 210 | /* A promise of some sort */ |
| 211 | if (arguments.length == 1 && arg && typeof arg == "object" && "then" in arg && typeof arg.then == "function") { |
| 212 | arg.then(function(...args: unknown[]) { console.log(...args) }, |
| 213 | function(...args: unknown[]) { console.error(...args) }); |
| 214 | if ("stream" in arg && typeof arg.stream == "function") |
| 215 | arg.stream(function(...args: unknown[]) { console.log(...args) }); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | let zz_value: unknown; |
| 220 | |
| 221 | /* For debugging in the browser console */ |
| 222 | Object.defineProperties(window, { |
| 223 | cockpit: { value: cockpit }, |
| 224 | zz: { |
| 225 | get: function() { return zz_value }, |
| 226 | set: function(val) { zz_value = val; follow(val) } |
| 227 | } |
| 228 | }); |
| 229 | |
| 230 | const root = createRoot(document.getElementById("shell")!); |
| 231 | root.render(<WithDialogs><Shell /></WithDialogs>); |
| 232 | } |
| 233 | |
| 234 | document.addEventListener("DOMContentLoaded", init); |