Files
Andrew Zambazos 207a849f06 Add Nebula Browser app, UI and assets
Add initial Nebula Browser project skeleton: CMakeLists to configure and link CEF (including post-build steps to copy runtime and UI files), a Windows CEF-based entry (app/main.cpp) that initializes CEF and loads the bundled UI, and a full ui/ and assets/ tree (HTML, CSS, JS, fonts, icons, and branding images). Update .gitignore to ignore build/out, thirdparty/cef, IDE and common OS artifacts.
2026-05-13 22:17:58 +12:00

39 lines
1.2 KiB
JavaScript

const SEARCH_URL = 'https://www.google.com/search?q=';
function toNavigationUrl(input) {
const value = (input || '').trim();
if (!value) return null;
if (/^(https?:|file:|data:|blob:)/i.test(value)) return value;
if (value.includes('.') && !/\s/.test(value)) return `https://${value}`;
return `${SEARCH_URL}${encodeURIComponent(value)}`;
}
function rememberSearch(input) {
if (!input || input.includes('.') || /^(https?:|file:)/i.test(input)) return;
try {
const current = JSON.parse(localStorage.getItem('searchHistory') || '[]');
const next = [input, ...current.filter(item => item !== input)].slice(0, 100);
localStorage.setItem('searchHistory', JSON.stringify(next));
} catch {}
}
function navigateTo(input) {
const target = toNavigationUrl(input);
if (!target) return;
rememberSearch(input.trim());
window.location.href = target;
}
window.NebulaCEF = { navigateTo, toNavigationUrl };
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('start-form');
const urlInput = document.getElementById('start-url');
if (!form || !urlInput) return;
form.addEventListener('submit', event => {
event.preventDefault();
navigateTo(urlInput.value);
});
});