Every app in HagalazOS runs inside a self-contained window: a draggableDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/linuxfandudeguy/HagalazOS/llms.txt
Use this file to discover all available pages before exploring further.
div styled with the 7.css Windows 7 chrome, housing a sandboxed blob iframe. The entire lifecycle — creation, restoration, minimization, maximization, closure, and z-index stacking — is managed by a handful of functions in script.js.
Opening a window
openWindow is the single entry point for launching any app. It is called by both desktop icons and taskbar buttons.
A unique DOM
id for the .window-wrapper element. Used to look up an existing window before creating a new one, and as the key in the minimizedWindows record.Relative or absolute URL of the primary HTML document to load into the window’s iframe. Fetched with the Fetch API; failure triggers the fallback path.
Text displayed in the 7.css
.title-bar-text element at the top of the window.Optional secondary URL tried if
htmlPath fetch returns a non-OK response or throws. Useful for apps whose primary HTML is local but have a CDN mirror. Defaults to null.Behaviour
Check for an existing window
openWindow calls document.getElementById(id). If a matching element exists:- If it is hidden (
display: none), it is shown (display: block) and removed from theminimizedWindowsrecord. - Its
z-indexis bumped viazIndexCounter++to bring it to the front. - The function returns early — no new window is created.
Create the window wrapper
A new
div.window-wrapper is created with:position: absolutewidth: 800px,height: 600pxtop: 50px,left: 50pxz-indexset to the currentzIndexCountervalue (then incremented)
mousedown listener on the wrapper increments zIndexCounter again each time the user clicks inside it, keeping the active window on top.Window controls
Minimize
display: none on the wrapper identified by id and records minimizedWindows[id] = true. The window remains in the DOM; the next openWindow(id, ...) call will restore it.
Maximize / Restore
btn.closest(".window-wrapper") to find the target. Toggles between two states tracked by win.dataset.max. Newly created windows have dataset.max unset; the condition checks strictly for === "1", so the first click always maximizes:
dataset.max value | Action taken | dataset.max set to |
|---|---|---|
unset or "0" (normal) | top:0, left:0, width:100%, height:calc(100% - 48px) — fills the desktop above the taskbar | "1" |
"1" (maximized) | Restores to width:800px, height:600px, top:50px, left:50px | "0" |
zIndexCounter is also incremented on every maximize/restore toggle via win.style.zIndex = zIndexCounter++.
Close
btn.closest(".window-wrapper") to obtain the wrapper, deletes the corresponding minimizedWindows entry, and calls win.remove() to detach the element from the DOM entirely.
Drag behaviour
makeDraggable(wrapper) wires a mousedown handler onto the .title-bar child of the wrapper. On press it records the cursor offset relative to the wrapper’s bounding rect:
mousemove listener on document updates wrapper.style.left and wrapper.style.top on every frame. A one-shot mouseup listener on document (using { once: true }) removes the mousemove handler when the drag ends.
App loading pipeline
renderBlobIframe(container, htmlText)
- Creates a
BlobfromhtmlTextwith MIME typetext/html. - Generates an object URL via
URL.createObjectURL(blob). - Creates a borderless, 100 % × 100 %
<iframe>and sets itssrcto the object URL. - Replaces
container.innerHTMLwith the iframe. - On
iframe.onload, schedulesURL.revokeObjectURL(url)after 60 000 ms (60 seconds).
Z-index management
zIndexCounter is a module-level integer starting at 1. It increments in four situations:
openWindow— new window created — the new wrapper receives the current value then the counter increments.openWindow— existing window restored/focused — counter increments and is applied to the existing wrapper.mousedownon any wrapper — amousedownlistener added during window creation callswin.style.zIndex = zIndexCounter++, bringing the clicked window visually to the front.maximizeWindow/ restore — every maximize and restore toggle also callswin.style.zIndex = zIndexCounter++, ensuring the affected window rises to the top of the stack.
Keyboard shortcut: Ctrl+X
Akeydown listener on document fires when e.ctrlKey && e.key.toLowerCase() === 'x'. It:
- Queries all
.window-wrapperelements. - Iterates them to find the one with the highest
parseInt(style.zIndex). - Deletes that window’s
minimizedWindowsentry and calls.remove()on it.