From 3ae5f8b8eda6fa0635e1d599f6642d9b2b1311a8 Mon Sep 17 00:00:00 2001 From: numex-admin Date: Wed, 9 Sep 2026 22:38:22 +0000 Subject: [PATCH] =?UTF-8?q?Numex=20yay=C4=B1n:=20public/js/desktop.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/desktop.js | 94 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 public/js/desktop.js diff --git a/public/js/desktop.js b/public/js/desktop.js new file mode 100644 index 0000000..ee8b00f --- /dev/null +++ b/public/js/desktop.js @@ -0,0 +1,94 @@ +/* ============================================================ + AURA OS — Masaüstü & Uygulama Başlatıcı + Simgeler (çift tık → pencere), kayıtlı AuraApps + ============================================================ */ + +// Uygulama özellikleri (desktop simgesi için) +const APP_META = { + notes: { label: 'Siber Not Defteri', icon: '📝', bg: '#00b34a' }, + terminal: { label: 'Hacker Terminali', icon: '⌨️', bg: '#889999' }, + paint: { label: 'Neon Paint', icon: '🎨', bg: '#ff00ff' }, +}; + +const DESKTOP_APP_ORDER = ['notes', 'terminal', 'paint']; + +/* Masaüstü simgelerini çizer (cift tıkla aç) */ +function initDesktop() { + const container = document.getElementById('desktop-icons'); + if (!container) return; + + container.innerHTML = ''; + DESKTOP_APP_ORDER.forEach(appId => { + const meta = APP_META[appId]; + if (!meta) return; + + const iconEl = document.createElement('div'); + iconEl.className = 'app-icon'; + iconEl.dataset.app = appId; + iconEl.innerHTML = + '
' + + meta.icon + + '
' + + '
' + meta.label + '
'; + + // Seçim (tek tık) + iconEl.addEventListener('click', (e) => { + e.stopPropagation(); + document.querySelectorAll('.app-icon').forEach(i => i.classList.remove('selected')); + iconEl.classList.add('selected'); + }); + + // Çift tık → uygulamayı aç + iconEl.addEventListener('dblclick', () => { + launchApp(appId); + }); + + container.appendChild(iconEl); + }); +} + +/** + * Uygulamayı başlatır (daha önce açıksa öne alır). + * @param {string} appId + */ +function launchApp(appId) { + const cfg = AuraApps[appId]; + if (!cfg) { + console.warn('[Desktop] Başlatılamayan uygulama:', appId); + return; + } + + // Zaten açık bir pencere varsa onu öne getir (singleton mantığı yoksa bile pratik) + const existing = Wm.windows.find(w => w.appId === appId); + if (existing && !existing.minimized) { + window.focusWindow(existing.id); + return; + } + if (existing && existing.minimized) { + window.restoreWindow(existing.id); + return; + } + + // Pencere aç + const winInfo = cfg.windowProps || { width: 560, height: 420 }; + const meta = APP_META[appId] || { icon: cfg.icon || '🪟', label: cfg.name || appId }; + + const winRef = createWindow({ + appId, + title: cfg.windowTitle || meta.label || cfg.name, + icon: cfg.icon || meta.icon, + width: winInfo.width || 560, + height: winInfo.height || 420, + // İçerik şablonu html — aşağıdaki buildBodyContent + }); + + return winRef; +} + +/* launchApp küresel olarak taskbar/başlat menüsünde kullanılsın */ +window.launchApp = launchApp; + +/* DOM hazır */ +window.addEventListener('DOMContentLoaded', () => { + initDesktop(); +});