function createWindow(content, title, x, y) { var tmpl = document.createElement("div"); tmpl.innerHTML = "

Content

"; content = content || tmpl; title = title || "Window"; x = x || 16; y = y || 16; let wnd = document.createElement("div"); wnd.className = "window glass"; wnd.style.left = x + "px"; wnd.style.top = y + "px"; document.querySelectorAll(".window").forEach(w => { w.classList.remove("active"); }); wnd.classList.add("active"); wnd.addEventListener("mousedown", function() { document.querySelectorAll(".window").forEach(w => { w.classList.remove("active"); }); wnd.classList.add("active"); }); let titlebar = document.createElement("div"); titlebar.className = "title-bar"; let titletext = document.createElement("div"); titletext.className = "title-bar-text"; titletext.innerText = title; titlebar.appendChild(titletext); let controls = document.createElement("div"); controls.className = "title-bar-controls"; let btnMinimize = document.createElement("button"); btnMinimize.setAttribute("aria-label", "Minimize"); let btnMaximize = document.createElement("button"); btnMaximize.setAttribute("aria-label", "Maximize"); let btnClose = document.createElement("button"); btnClose.setAttribute("aria-label", "Close"); btnClose.addEventListener("mouseup", function() { wnd.remove(); }); //controls.appendChild(btnMinimize); //controls.appendChild(btnMaximize); controls.appendChild(btnClose); titlebar.appendChild(controls); let body = document.createElement("div"); body.className = "window-body"; body.appendChild(content); wnd.appendChild(titlebar); wnd.appendChild(body); document.body.appendChild(wnd); makeDraggable(wnd); makeResizable(wnd); }