1
0
Fork 0
isopod.cool/desktop.js
2023-01-09 14:30:45 -07:00

36 lines
1.5 KiB
JavaScript

let activeWindowCount = 0;
const desktop = document.getElementById('desktop');
function changeRootVar(name, value) {
document.documentElement.style.setProperty(`--${name}`, value);
}
function updateWindowCountX() {
if(activeWindowCount <= 4) {
document.documentElement.style.setProperty('--windowcountx', '2');
} else if(activeWindowCount <= 9) {
document.documentElement.style.setProperty('--windowcountx', '3');
} else {
document.documentElement.style.setProperty('--windowcountx', '4');
}
}
function openwindow(name) {
if(activeWindowCount < 9) {
let newWindow = document.createElement('div');
newWindow.innerHTML = '<div class="windowdecoration"><button class="closewindow" onclick="closewindow(this)"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 24 24" width="24" fill="currentColor"><path d="M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"></path></svg></button></div>'
let newWindowContent = document.createElement('iframe');
newWindow.className = 'window';
newWindowContent.src = `${name}/`;
newWindow.appendChild(newWindowContent);
desktop.appendChild(newWindow);
activeWindowCount = activeWindowCount + 1;
//updateWindowCountX();
}
}
function closewindow(window) {
window.parentElement.parentElement.remove();
activeWindowCount = activeWindowCount - 1;
//updateWindowCountX();
}