Tap core for menu • hold for scan • double-tap for globe

eX-cLu-siVe

TITAN PROTOCOL
HOLD TO AUTHENTICATE
Default feed: Satellite + Tags. After boot: HELP. Keys: M menu, F full. If hold is blocked, tap twice.
EXCLUSIVE // OPS
SESSION
MODE SAT
VOICE ON
Quick Start
Flow: GEO LOCK → SCAN → CITY. Use Cmd/Ctrl+K for full commands.
Tactical Tools
Utilities
Basemap
Layers
Tip: if mobile feels heavy, tap FX TIER to drop into low mode.
Atmosphere
Presets
City Control
Feed Behavior
Refresh tuning: FAST / NORM / LOW
Profiles
Profiles change multiple toggles at once (mode, FX, overlays).
Automation
AUTO SCAN
Periodic scan after GEO lock
CINEMATIC FX
Warp + packet overlays on key actions
REDUCE MOTION
Stabilize UI for low-power / accessibility
HAPTICS
Vibration feedback (toggle for comfort)
State persists in your browser (localStorage).
System
SYS.TIME --:--:--
LOC.LAT --.----
LOC.LNG --.----
ZOOM -- • SIG --
CPU
RAM
TARGET NO LOCK
MODE SAT
NET ONLINE • PINS 0
>
OPTICSOFF
or backticks-heavy scripts inside template strings. // This implementation generates a minimal print-friendly report (no scripts), so it can't break the main app. const REPORT = (() => { const esc = (v) => String(v ?? "").replace(/[&<>"]/g, (c) => ({"&":"&","<":"<",">":">","\"":"""}[c])); const fmt = (n, d=5) => { const x = Number(n); return Number.isFinite(x) ? x.toFixed(d) : "—"; }; function collectPins(){ // TITAN.pins may be array of {pin,...} or pin objects const arr = (window.TITAN && Array.isArray(TITAN.pins)) ? TITAN.pins : []; return arr.map(x => x && x.pin ? x.pin : x).filter(Boolean).slice(-75); } function print(){ try{ const pins = collectPins(); const ts = new Date().toLocaleString(); const rows = pins.map((p,i)=>{ const lat = p.lat ?? p.latitude ?? (p.coords && p.coords.lat); const lng = p.lng ?? p.lon ?? p.longitude ?? (p.coords && (p.coords.lng ?? p.coords.lon)); const kind = p.kind ?? p.type ?? "pin"; const label = p.name ?? p.title ?? p.label ?? p.code ?? ""; const note = p.note ?? p.desc ?? p.summary ?? ""; return ` ${i+1} ${esc(kind)} ${esc(label)} ${fmt(lat)} ${fmt(lng)} ${esc(note)} `; }).join(""); const html = ` XMIND Field Report

XMIND Field Report

Generated: ${esc(ts)} • Pins: ${pins.length}

${pins.length ? `${rows}
#TypeLabelLatLngNotes
` : `
No pins captured yet. Run a locate/scan to generate pins, then export again.
`} `; const w = window.open("", "_blank", "noopener,noreferrer"); if(!w){ if (typeof showToast === "function") showToast("Popup blocked — allow popups to export the report.", "warn"); return; } w.document.open(); w.document.write(html); w.document.close(); w.focus(); setTimeout(()=>{ try{ w.print(); }catch(_){} }, 250); }catch(err){ console.error("REPORT.print failed", err); if (typeof showToast === "function") showToast("Report export failed. Check console for details.", "bad"); } } return { print }; })(); // Wire common UI hooks (safe if elements don't exist) try{ const a = document.getElementById("menu-report"); const b = document.getElementById("dosExReport"); [a,b].filter(Boolean).forEach(el => el.addEventListener("click", (e)=>{ e.preventDefault(); REPORT.print(); })); }catch(_){} // ---- Make the menu button accessible (it's a div in the demo) ---- try{ const mb = document.getElementById("menu-btn"); if(mb && mb.tagName !== "BUTTON"){ mb.setAttribute("role","button"); mb.setAttribute("tabindex","0"); mb.setAttribute("aria-label","Open ops menu"); mb.addEventListener("keydown", (e)=>{ const k = e.key || ""; if(k === "Enter" || k === " "){ try{ e.preventDefault(); }catch(_){} try{ mb.click(); }catch(_){} } }, {passive:false}); } }catch(_){} // ---- Ensure every button has an accessible name (fallback: aria-label from text) ---- try{ $$("button").forEach(b=>{ const name = safe(b.getAttribute("aria-label")) || safe(b.textContent); if(!name) return; if(!b.getAttribute("aria-label")) b.setAttribute("aria-label", name); }); }catch(_){} // ---- Normalize visible GEO labels (without affecting command parsing) ---- try{ $$("#ops-pad [data-act='geo']").forEach(b=>{ if(safe(b.textContent)==="GEO") b.textContent="GEO LOCK"; b.setAttribute("aria-label","GEO LOCK"); }); $$("#auth-hint").forEach(h=>{ h.innerHTML = h.innerHTML.replace(/\bGEO\b/g, "GEO LOCK"); }); }catch(_){} // ---- Story discoverability: first session nudge after unlock ---- const LS_KEY = "ex_story_nudged"; function toastAction(msg, label, onAct){ const t = document.getElementById("toast"); if(!t) { try{ window.showToast && window.showToast(msg); }catch(_){}; return; } t.classList.add("toast-actionable","on"); t.classList.remove("off"); t.innerHTML = `${msg}`; const btn = t.querySelector("button.toast-act"); if(btn){ btn.onclick = ()=>{ try{ onAct && onAct(); }catch(_e){}; try{ t.classList.remove("show","toast-actionable"); t.innerHTML=""; }catch(_e){}; }; } clearTimeout(t.__ex_to2); t.__ex_to2 = setTimeout(()=>{ try{ t.classList.remove("on","toast-actionable"); t.classList.add("off"); t.innerHTML=""; }catch(_e){} }, 9000); } function nudgeStory(){ try{ if(localStorage.getItem(LS_KEY)==="1") return; const dash = document.getElementById("dashboard-layer"); if(!dash || !dash.classList.contains("active")) return; const storyBtn = document.querySelector('#system-menu [data-run="story"]'); if(storyBtn) storyBtn.classList.add("ex-pulse"); // explain exposure + story path (no extra modal spam) toastAction("Tip: STORY guides you (GEO LOCK → SCAN → CITY). Exposure rises with active sensors.", "START STORY", ()=>{ try{ localStorage.setItem(LS_KEY,"1"); }catch(_){} try{ storyBtn && storyBtn.classList.remove("ex-pulse"); }catch(_){} try{ if(window.PROTO?.startStory) PROTO.startStory(); else window.TITAN?.log?.("STORY UNAVAILABLE.", "warn"); }catch(_){} }); try{ localStorage.setItem(LS_KEY,"1"); }catch(_){} }catch(_){} } try{ const dash = document.getElementById("dashboard-layer"); if(dash){ const mo = new MutationObserver(()=> nudgeStory()); mo.observe(dash, {attributes:true, attributeFilter:["class"]}); } setTimeout(nudgeStory, 1800); }catch(_){} })(); `; const w = window.open("", "_blank"); if(!w) return; w.document.open(); w.document.write(html); w.document.close(); w.focus(); setTimeout(()=>{ try{ w.print(); }catch(e){} }, 500); } return { print }; })(); window.REPORT = REPORT; // ----- Collaboration (Local multi-user via BroadcastChannel + optional WebSocket stub) ----- const COLLAB = (() => { const st = PROTO.getState(); const CH = "ex_ops_channel_v1"; let bc = null; let ws = null; let enabled = false; let peers = {}; let peerLayer = null; let peerTimer = null; const myId = (()=> { try{ const k = "ex_ops_id"; const e = localStorage.getItem(k); if(e) return e; const v = "OP-" + Math.random().toString(16).slice(2,8).toUpperCase(); localStorage.setItem(k, v); return v; }catch(_){ return "OP-" + Math.random().toString(16).slice(2,8).toUpperCase(); } })(); function ensureLayer(){ if(!window.TITAN?.map) return; if(peerLayer) return; peerLayer = L.layerGroup().addTo(TITAN.map); } function paint(){ if(!enabled || !window.TITAN?.map || !peerLayer) return; peerLayer.clearLayers(); Object.keys(peers).forEach(id=>{ const p = peers[id]; if(!p || !p.lat || !p.lng) return; const m = L.circleMarker([p.lat, p.lng], { radius: 5, color:"#E6C56A", weight:2, fillColor:"#000", fillOpacity:0.85 }); m.bindTooltip(`${id}${p.tier?(" • "+p.tier):""}`, {direction:"top"}); m.addTo(peerLayer); }); } function broadcast(payload){ const msg = Object.assign({ type:"presence", id: myId, ts: Date.now(), tier: PROTO.getState().tier }, payload||{}); try{ bc?.postMessage(msg); }catch(_){} try{ ws?.readyState===1 && ws.send(JSON.stringify(msg)); }catch(_){} } function onMsg(msg){ if(!msg || msg.id===myId) return; peers[msg.id] = Object.assign(peers[msg.id]||{}, msg); paint(); } function enable(){ if(enabled) return; if(!PROTO.requireTier("TITAN", "COLLAB REQUIRES TITAN CLEARANCE")) return; enabled = true; st.settings.collab = true; PROTO.save(); ensureLayer(); try{ bc = new BroadcastChannel(CH); bc.onmessage = (e)=> onMsg(e.data); }catch(_){} // optional ws try{ const url = st.settings.wsUrl; if(url){ ws = new WebSocket(url); ws.onmessage = (e)=> { try{ onMsg(JSON.parse(e.data)); }catch(_){ } }; ws.onopen = ()=>{ try{ TITAN.log("COLLAB WS CONNECTED.", "ok"); }catch(_){ } }; } }catch(_){} // keep presence updated peerTimer = setInterval(()=>{ try{ const c = TITAN.map.getCenter(); broadcast({ lat: c.lat, lng: c.lng, exposure: st.exposure }); }catch(_){} }, 1800); PROTO.event("collab"); try{ UIX?.push?.("ok", "COLLAB ENABLED (local channel)"); }catch(_){} BRIEF.brief("OPS", "COLLAB ONLINE", "Local multi-user mode enabled.", [ "Peers appear as operatives on your map.", "Optional WebSocket URL can be configured in Settings (future)." ], 5200); } function disable(){ enabled = false; st.settings.collab = false; PROTO.save(); try{ peerLayer?.clearLayers?.(); }catch(_){} try{ bc?.close?.(); }catch(_){} try{ ws?.close?.(); }catch(_){} bc = null; ws = null; peers = {}; if(peerTimer) clearInterval(peerTimer); peerTimer = null; try{ UIX?.push?.("sys", "COLLAB OFF"); }catch(_){} } function toggle(){ enabled ? disable() : enable(); } return { enable, disable, toggle, get enabled(){ return enabled; }, myId }; })(); window.COLLAB = COLLAB; // ----- Live Feeds (ISS + Weather) ----- const FEEDS = (() => { const st = PROTO.getState(); let issMarker = null; let issTimer = null; let wxTimer = null; let wxLast = null; async function fetchISS(){ // public endpoint (may be blocked by some networks) const r = await fetch("https://api.wheretheiss.at/v1/satellites/25544", {cache:"no-store"}); const d = await r.json(); return { lat: d.latitude, lng: d.longitude, alt: d.altitude, vel: d.velocity }; } function ensureISS(){ if(!TITAN.map) return; if(!issMarker){ issMarker = L.circleMarker([0,0], { radius: 4, color:"#00F0FF", weight:2, fillColor:"#000", fillOpacity:0.9 }); issMarker.bindTooltip("ISS • LIVE", {direction:"top"}); issMarker.addTo(TITAN.map); } } async function tickISS(){ try{ const d = await fetchISS(); ensureISS(); issMarker.setLatLng([d.lat, d.lng]); // don't spam logs wxLast = d; }catch(e){ // silent fail } } function enableISS(){ if(!PROTO.requireTier("TITAN", "LIVE FEEDS REQUIRE TITAN CLEARANCE")) return; st.settings.liveISS = true; PROTO.save(); tickISS(); issTimer = setInterval(tickISS, 12000); try{ UIX?.push?.("ok", "ISS FEED ONLINE"); }catch(_){} } function disableISS(){ st.settings.liveISS = false; PROTO.save(); if(issTimer) clearInterval(issTimer); issTimer = null; try{ TITAN.map && issMarker && TITAN.map.removeLayer(issMarker); }catch(_){} issMarker = null; try{ UIX?.push?.("sys", "ISS FEED OFF"); }catch(_){} } function toggleISS(){ st.settings.liveISS ? disableISS() : enableISS(); } async function fetchWX(lat,lng){ // open-meteo is simple and keyless const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lng}¤t=temperature_2m,wind_speed_10m,weather_code`; const r = await fetch(url, {cache:"no-store"}); return r.json(); } async function tickWX(){ try{ if(!TITAN.map) return; const c = TITAN.map.getCenter(); const d = await fetchWX(c.lat, c.lng); const cur = d.current || {}; wxLast = cur; // update AI guide status line if present const el = document.getElementById("ai-status2"); if(el){ const t = cur.temperature_2m; const w = cur.wind_speed_10m; el.textContent = (el.textContent.split(" • ").slice(0,4).join(" • ")) + ` • WX:${t!=null?Math.round(t)+"°": "--"} WIND:${w!=null?Math.round(w):"--"}`; } }catch(e){} } function enableWX(){ if(!PROTO.requireTier("TITAN", "LIVE FEEDS REQUIRE TITAN CLEARANCE")) return; st.settings.liveWX = true; PROTO.save(); tickWX(); wxTimer = setInterval(tickWX, 18000); try{ UIX?.push?.("ok", "WEATHER FEED ONLINE"); }catch(_){} } function disableWX(){ st.settings.liveWX = false; PROTO.save(); if(wxTimer) clearInterval(wxTimer); wxTimer = null; try{ UIX?.push?.("sys", "WEATHER FEED OFF"); }catch(_){} } function toggleWX(){ st.settings.liveWX ? disableWX() : enableWX(); } return { toggleISS, toggleWX }; })(); window.FEEDS = FEEDS; // ----- Hologram Overlay (canvas) ----- const HOLO = (() => { const cvs = document.getElementById("holo-canvas"); const ctx = cvs.getContext("2d"); let dpr = 1; let raf = null; let pulse = 0; function resize(){ dpr = Math.min(2, window.devicePixelRatio||1); cvs.width = Math.floor(innerWidth*dpr); cvs.height = Math.floor(innerHeight*dpr); } function drawRing(x,y,r,alpha=0.55){ ctx.beginPath(); ctx.arc(x,y,r,0,Math.PI*2); ctx.strokeStyle = `rgba(212,175,55,${alpha})`; ctx.lineWidth = 1.5; ctx.stroke(); ctx.beginPath(); ctx.arc(x,y,r+6,0,Math.PI*2); ctx.strokeStyle = `rgba(212,175,55,${alpha*0.35})`; ctx.lineWidth = 1; ctx.stroke(); } function draw(){ resize(); ctx.setTransform(1,0,0,1,0,0); ctx.clearRect(0,0,cvs.width,cvs.height); ctx.scale(dpr,dpr); if(!window.TITAN?.map) { raf = requestAnimationFrame(draw); return; } const now = performance.now(); pulse = (now*0.001)%1; const W = innerWidth, H = innerHeight; // subtle drift noise scan ctx.fillStyle = "rgba(0,0,0,0.06)"; ctx.fillRect(0,0,W,H); // draw pins try{ const pins = (TITAN.pins||[]).slice(-20); pins.forEach((p,i)=>{ const ll = p.pin || p; const pt = TITAN.map.latLngToContainerPoint([ll.lat, ll.lng]); const x = pt.x, y = pt.y; const r = 10 + (i%5)*1.2 + pulse*10; drawRing(x,y,r,0.45); }); }catch(_){} // draw fragments try{ const frags = FRAG.listVisible(); frags.forEach(f=>{ const pt = TITAN.map.latLngToContainerPoint([f.lat, f.lng]); const x = pt.x, y = pt.y; drawRing(x,y, 14 + pulse*12, 0.62); // label ctx.fillStyle = "rgba(255,255,255,0.75)"; ctx.font = "11px JetBrains Mono, monospace"; ctx.fillText("NODE", x+18, y-10); }); }catch(_){} // scan pulse ring at center after scans if(FRAG.scanPulseTs && (Date.now() - FRAG.scanPulseTs) < 2200){ const age = (Date.now() - FRAG.scanPulseTs)/2200; const c = TITAN.map.getContainer().getBoundingClientRect(); const x = c.left + c.width/2; const y = c.top + c.height/2; const rr = 30 + age*240; drawRing(x,y,rr, 0.85*(1-age)); } raf = requestAnimationFrame(draw); } function start(){ if(raf) return; resize(); raf = requestAnimationFrame(draw); } start(); addEventListener("resize", resize); return { start }; })(); // ----- Data Fragments (map nodes) ----- const FRAG = (() => { let layer = null; const st = PROTO.getState(); const fragments = []; function ensureLayer(){ if(!TITAN.map) return; if(layer) return; layer = L.layerGroup().addTo(TITAN.map); } function addFragment(id, lat, lng, label){ fragments.push({ id, lat, lng, label, ts: Date.now() }); } function seedBase(){ // fixed seeds near your presets for demo addFragment("proj:xmind:tor", 43.6532, -79.3832, "XMIND"); addFragment("proj:omni:nyc", 40.7128, -74.0060, "OMNI"); addFragment("proj:vault:lon", 51.5074, -0.1278, "VAULT"); addFragment("proj:420up:par", 48.8566, 2.3522, "420UP"); // a few anomalies addFragment("anom:tok", 35.6762, 139.6503, "ANOM"); addFragment("anom:dub", 25.2048, 55.2708, "ANOM"); } function loadCollected(){ // nothing else; state.fragments holds } function isCollected(id){ return !!st.fragments[id]?.collected; } function collect(id){ if(isCollected(id)) return false; st.fragments[id] = { collected:true, ts: Date.now() }; PROTO.save(); PROTO.event("fragment"); try{ TITAN.log(`DATA FRAGMENT RECOVERED: ${id.toUpperCase()}`, "warn"); }catch(_){} BRIEF.brief("RECOVERY", "DATA FRAGMENT ACQUIRED", "Dossier access updated.", [ "Open DOSSIER (SECURE) to inspect unlocked files.", "Scan again to reveal additional anomalies." ], 5200); try{ SFX.speak("Fragment acquired. Dossier updated.", { mode:"mysterious", interrupt:false }); }catch(_){ } vib([12,18,12,30,12]); // auto unlock secure if enough fragments const n = Object.keys(st.fragments||{}).filter(k=>st.fragments[k]?.collected).length; if(n>=2) PROTO.unlockSecure(false); if(n>=4) PROTO.unlockTitan(false); return true; } function render(){ ensureLayer(); if(!layer) return; layer.clearLayers(); fragments.forEach(f=>{ if(isCollected(f.id)) return; const m = L.circleMarker([f.lat,f.lng], { radius: 6, color: "#D4AF37", weight: 2, fillColor: "#000", fillOpacity: 0.88 }); m.bindTooltip((f.label||"NODE") + " • DATA", {direction:"top"}); m.on("click", ()=>{ // require proximity OR SECURE const c = TITAN.map.getCenter(); const dist = haversine(c.lat, c.lng, f.lat, f.lng); if(dist < 0.45 || PROTO.hasTier("SECURE")){ collect(f.id); render(); }else{ BRIEF.brief("PROXIMITY", "NODE OUT OF RANGE", "Move closer or elevate access.", [ "Requirement: within 450m of node.", "Tip: fly to presets and scan." ], 4200); vib([8,16,8]); } }); m.addTo(layer); }); } // scan adds anomalies near center function spawnNearCenter(){ if(!TITAN.map) return; const c = TITAN.map.getCenter(); const b = TITAN.map.getBounds(); // create 2-4 fragments within bounds const count = 2 + Math.floor(Math.random()*3); for(let i=0;id*Math.PI/180; const dLat=toRad(lat2-lat1), dLon=toRad(lon2-lon1); const a=Math.sin(dLat/2)**2 + Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)**2; return 2*R*Math.asin(Math.sqrt(a)); } function listVisible(){ return fragments.filter(f=>!isCollected(f.id)); } let scanPulseTs = 0; function onScan(){ scanPulseTs = Date.now(); spawnNearCenter(); } seedBase(); return { render, collect, onScan, listVisible, get scanPulseTs(){ return scanPulseTs; }, set scanPulseTs(v){ scanPulseTs=v; } }; })(); // ----- Offline Pack Generator (SW + manifest as downloads) ----- const OFFLINE = (() => { function download(name, content, type="text/plain"){ const blob = new Blob([content], {type}); const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = name; document.body.appendChild(a); a.click(); setTimeout(()=>{ URL.revokeObjectURL(a.href); a.remove(); }, 3000); } function installPack(){ if(!PROTO.requireTier("TITAN", "OFFLINE PACK REQUIRES TITAN CLEARANCE")) return; const sw = `// eX-cLu-siVe // TITAN SW // Place this file at your site root as /sw.js (or adjust paths). const CACHE = 'exclusive-v1'; const CORE = ['./','./index.html']; self.addEventListener('install', (e)=>{ self.skipWaiting(); e.waitUntil(caches.open(CACHE).then(c=>c.addAll(CORE))); }); self.addEventListener('activate', (e)=>{ e.waitUntil((async ()=>{ const keys = await caches.keys(); await Promise.all(keys.map(k => (k !== CACHE) ? caches.delete(k) : null)); await self.clients.claim(); })()); }); self.addEventListener('fetch', (e)=>{ const req = e.request; // Only cache GET requests if(req.method !== 'GET') return; e.respondWith((async ()=>{ const cached = await caches.match(req); if(cached) return cached; try{ const res = await fetch(req); const copy = res.clone(); caches.open(CACHE).then(c=>c.put(req, copy)).catch(()=>{}); return res; }catch(err){ return cached || new Response('offline', {status:503, headers:{'content-type':'text/plain'}}); } })()); }); `; const mf = JSON.stringify({ name:"eX-cLu-siVe // TITAN", short_name:"eX-cLu-siVe", start_url:"./", display:"standalone", background_color:"#020202", theme_color:"#020202", icons:[{src:"/share.png", sizes:"512x512", type:"image/png"}] }, null, 2); download("sw.js", sw, "text/javascript"); download("manifest.webmanifest", mf, "application/manifest+json"); BRIEF.brief("OFFLINE", "OFFLINE PACK GENERATED", "Two files downloaded.", [ "Upload sw.js + manifest.webmanifest beside index.html", "Add ", "Register SW in your real deployment." ], 6200); } return { installPack }; })(); // ----- Ambient Soundscape (hum + static) ----- const SOUND = (() => { let ctx = null, gain=null, hum=null, noise=null, on=false; function init(){ if(ctx) return; ctx = new (window.AudioContext || window.webkitAudioContext)(); gain = ctx.createGain(); gain.gain.value = 0.0; gain.connect(ctx.destination); // hum hum = ctx.createOscillator(); hum.type = "sine"; hum.frequency.value = 46; const humGain = ctx.createGain(); humGain.gain.value = 0.18; hum.connect(humGain); humGain.connect(gain); hum.start(); // static noise (buffer) const buffer = ctx.createBuffer(1, ctx.sampleRate*2, ctx.sampleRate); const data = buffer.getChannelData(0); for(let i=0;i { const st = PROTO.getState(); const bcName = "ex_companion_v1"; let bc = null; let on = false; function send(cmd, payload){ try{ bc?.postMessage({cmd, payload, ts:Date.now()}); }catch(_){} } function enable(){ on = true; bc = new BroadcastChannel(bcName); showToast("companion channel online"); } function bindMain(){ try{ bc = new BroadcastChannel(bcName); bc.onmessage = (e)=>{ const m = e.data||{}; const cmd = (m.cmd||"").toLowerCase(); if(cmd === "geo") TITAN.geoLocate(); if(cmd === "scan") TITAN.exec("scan"); if(cmd === "pin") TITAN.exec("pin"); if(cmd === "palette") UIX.openPalette(); if(cmd === "dossier") DOSSIER.openFirstUnlocked(); if(cmd === "skills") SKILLS.open(); if(cmd === "crypto") CRYPTO.open(); if(cmd === "collab") COLLAB.toggle(); if(cmd === "iss") FEEDS.toggleISS(); if(cmd === "wx") FEEDS.toggleWX(); if(cmd === "sound") SOUND.toggle(); if(cmd === "story") PROTO.startStory(); if(cmd === "share") SHARECARD.export(); }; }catch(_){} } function renderCompanionUI(){ document.body.innerHTML = `
eX-cLu-siVe • Companion

TITAN REMOTE

Second-screen controls (same origin / same browser). Open main index in another tab/device.

${[ ["GEO","geo"],["SCAN","scan"],["PIN","pin"],["PALETTE","palette"], ["DOSSIER","dossier"],["SKILLS","skills"],["DECRYPT","crypto"],["COLLAB","collab"], ["ISS","iss"],["WEATHER","wx"],["SOUND","sound"],["STORY","story"], ["SHARE","share"] ].map(([t,c])=>` `).join("")}
Tip: Add #companion=1 to open this remote interface.
`; document.body.addEventListener("click",(e)=>{ const b = e.target.closest("button[data-c]"); if(!b) return; vib(10); send(b.getAttribute("data-c")); }); } function maybeEnterCompanion(){ const h = location.hash || ""; if(h.includes("companion=1")){ enable(); renderCompanionUI(); return true; } return false; } return { maybeEnterCompanion, bindMain }; })(); // ----- Hook into existing systems ----- (function wireUltimate(){ // Companion mode takes over page if requested if(COMPANION.maybeEnterCompanion()) return; // Main screen listens to companion commands COMPANION.bindMain(); // Ensure fragments render when map is ready const _init = TITAN.init.bind(TITAN); TITAN.init = function(){ const r = _init(); try{ FRAG.render(); }catch(_){} try{ // initial status badge PROTO.event("enter"); }catch(_){} return r; }; // Patch exec to emit mission events const _exec = TITAN.exec.bind(TITAN); TITAN.exec = function(act){ const res = _exec(act); try{ if(act==="scan") { PROTO.event("scan"); FRAG.onScan(); try{ const now = Date.now(); if(!TITAN._lastScanNarration || (now - TITAN._lastScanNarration) > 9000){ TITAN._lastScanNarration = now; SFX.narrate(["Scan complete.","Anomalies pinged on your map."], { mode:"mysterious", interrupt:false, gap:200 }); } }catch(_){} } if(act==="pin") { /* no mission */ } if(act==="route") { /* no mission */ } if(act==="sim") { /* no mission */ } }catch(_){} return res; }; // Patch geo locate const _geo = TITAN.geoLocate.bind(TITAN); TITAN.geoLocate = function(){ try{ const ua = navigator.userAgent || ""; const inApp = /(FBAN|FBAV|Instagram|Line\/|TikTok|Snapchat|Pinterest|Twitter)/i.test(ua); if(inApp){ try{ TITAN.log("IN-APP BROWSER DETECTED — GEO/CAM/MIC MAY FAIL. USE COPY LINK.", "warn"); BRIEF.brief("IN-APP BROWSER", "LIMITED PERMISSIONS", "Some in-app browsers block Geo/Cam/Mic. For the full demo:", [ "Tap COPY LINK.", "Open the link in Chrome / Safari.", "Then run GEO + SCAN again." ], 6200); }catch(_){} } }catch(_){} const res = _geo(); try{ PROTO.event("geo"); }catch(_){} return res; }; // Patch onLock for demo guidance (geo → scan → reveal) const _onLock = TITAN.onLock.bind(TITAN); TITAN.onLock = function(name){ const res = _onLock(name); try{ const n = String(name||"").toUpperCase(); if(n.includes("YOUR POSITION")){ if(!TITAN._demoGeoConfirmed){ TITAN._demoGeoConfirmed = true; try{ SFX.narrate([ "Geo lock confirmed.", "Initiating scan pulse. Watch for gold nodes." ], { mode:"directive", interrupt:false, gap:240 }); }catch(_){} try{ BRIEF.brief("GEO LOCK", "POSITION CONFIRMED", "Initiating sector scan to reveal encrypted fragments.", [ "Gold nodes = data fragments.", "Tap a node to recover it.", "Open DOSSIER to inspect unlocked files." ], 5200); }catch(_){} setTimeout(()=>{ try{ TITAN.exec("scan"); }catch(_){} }, 900); } } }catch(e){ try{ ERRLOG.push("error", e, "patch.onLock"); }catch(_){} } return res; }; // Patch export pins const _exp = TITAN.exportPins.bind(TITAN); TITAN.exportPins = function(){ const res = _exp(); try{ PROTO.event("export"); }catch(_){} return res; }; // Patch voice cmd start (button) by listening to UIX push from VoiceCmd start if present const vcBtn = document.getElementById("btn-voicecmd"); vcBtn?.addEventListener("click", ()=>{ try{ PROTO.event("voice"); }catch(_){ } }); // Patch optics toggle try{ const _toggle = CAM.toggle.bind(CAM); CAM.toggle = function(){ const before = CAM.on; const res = _toggle(); setTimeout(()=>{ if(CAM.on && !before) PROTO.event("optics"); }, 450); return res; }; }catch(_){} // Cheats const cheats = document.getElementById("cheats"); function toggleCheats(){ cheats.classList.toggle("show"); vib(8); } document.addEventListener("keydown", (e)=>{ if(e.key === "?" || (e.shiftKey && e.key === "/")){ e.preventDefault(); toggleCheats(); } if(e.key.toLowerCase() === "g" && !e.metaKey && !e.ctrlKey){ TITAN.geoLocate(); } if(e.key.toLowerCase() === "s" && !e.metaKey && !e.ctrlKey){ TITAN.exec("scan"); } if(e.key.toLowerCase() === "p" && !e.metaKey && !e.ctrlKey){ TITAN.exec("pin"); } }); // Add advanced commands into palette try{ const _build = UIX.buildCommands.bind(UIX); UIX.buildCommands = function(){ _build(); const add = (key, title, hint, run) => UIX.cmdAll.push({ key, title, hint, run }); add("STORY", "Story mode", "Guided progression / onboarding", ()=> PROTO.startStory()); add("DOSSIER", "Project dossiers", "Open unlocked project files", ()=> DOSSIER.openFirstUnlocked()); add("SKILLS", "Skills matrix", "Interactive network graph", ()=> SKILLS.open()); add("ACH", "Achievements", "Badges + progression", ()=> ACH.open()); add("DECRYPT", "Encryption challenge", "Solve cipher to unlock SECURE", ()=> CRYPTO.open()); add("SHARE", "Export share card", "PNG with HUD stats", ()=> SHARECARD.export()); add("REPORT", "Print report", "Browser print → save PDF", ()=> REPORT.print()); add("COLLAB", "Collaboration", "Local multi-user operatives", ()=> COLLAB.toggle()); add("ISS", "Live feed: ISS", "Track the ISS marker", ()=> FEEDS.toggleISS()); add("WX", "Live feed: Weather", "Weather at map center", ()=> FEEDS.toggleWX()); add("SOUND", "Soundscape", "Ambient hum + radio static", ()=> SOUND.toggle()); add("OFFLINE", "Offline pack", "Download sw.js + manifest", ()=> OFFLINE.installPack()); add("COMPANION", "Companion mode", "Open #companion=1", ()=> { navigator.clipboard?.writeText(location.href.split("#")[0] + "#companion=1"); showToast("companion link copied"); }); }; // rebuild UIX.cmdAll = []; UIX.buildCommands(); }catch(_){} // Extend menu buttons if present try{ const menu = document.getElementById("system-menu"); if(menu){ const extra = document.createElement("div"); extra.innerHTML = ` `; menu.appendChild(extra); const bind = (id, fn)=>{ document.getElementById(id)?.addEventListener("click", ()=>{ SFX.play("click"); vib(8); fn(); }); }; bind("menu-story", ()=> PROTO.startStory()); bind("menu-dossier", ()=> DOSSIER.openFirstUnlocked()); bind("menu-ach", ()=> ACH.open()); bind("menu-crypto", ()=> CRYPTO.open()); bind("menu-iss", ()=> FEEDS.toggleISS()); bind("menu-wx", ()=> FEEDS.toggleWX()); bind("menu-share", ()=> SHARECARD.export()); bind("menu-report", ()=> REPORT.print()); bind("menu-collab", ()=> COLLAB.toggle()); bind("menu-sound", ()=> SOUND.toggle()); bind("menu-offline", ()=> OFFLINE.installPack()); bind("menu-reset", ()=> PROTO.reset()); } }catch(_){} // Auto apply saved toggles (sound, feeds) try{ const s = PROTO.getState().settings; if(s.sound) setTimeout(()=>SOUND.set(true), 900); if(s.liveISS) setTimeout(()=>FEEDS.toggleISS(), 1200); if(s.liveWX) setTimeout(()=>FEEDS.toggleWX(), 1500); }catch(_){} // In-app browsers: force FX low for stability try{ if(isInApp){ TITAN.setFx("low"); showToast("in-app browser: fx low"); } }catch(_){} // First-run hint (non-blocking) try{ const st = PROTO.getState(); if(!st.badges?.first_unlock){ st.badges = st.badges || {}; st.badges.first_unlock = true; PROTO.save(); showToast("Tip: GEO → SCAN → CITY • Cmd/Ctrl+K for palette"); } }catch(_){} })();