Project added to repo
This commit is contained in:
@@ -0,0 +1,774 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Nebula Browser - Home</title>
|
||||
<!-- Google Material Icons -->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
src: url('../../assets/fonts/InterVariable.ttf') format('truetype');
|
||||
}
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
|
||||
background: #1a1724;
|
||||
min-height: 100vh;
|
||||
color: #333;
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Header Section */
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 100px;
|
||||
margin-bottom: 10px;
|
||||
filter: drop-shadow(0 2px 10px rgba(0,0,0,0.3));
|
||||
}
|
||||
|
||||
.title {
|
||||
color: white;
|
||||
font-size: 3.5rem;
|
||||
font-weight: 600;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 40px;
|
||||
text-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
/* Search Section */
|
||||
.search-section {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.search-container {
|
||||
position: relative;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
padding: 18px 60px 18px 20px;
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
border-radius: 25px;
|
||||
background: rgba(255,255,255,0.95);
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
|
||||
outline: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
background: white;
|
||||
box-shadow: 0 12px 40px rgba(0,0,0,0.15);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.search-button {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: #792fff;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.search-button:hover {
|
||||
background: #0384ff;
|
||||
transform: translateY(-50%) scale(1.1);
|
||||
}
|
||||
|
||||
.search-button svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
fill: white;
|
||||
}
|
||||
|
||||
/* Quick Links Section */
|
||||
.quick-links {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
text-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
.links-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
||||
gap: 20px;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
background: rgba(255,255,255,0.1);
|
||||
backdrop-filter: blur(10px);
|
||||
border-radius: 15px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
transition: all 0.3s ease;
|
||||
border: 1px solid rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
.link-item:hover {
|
||||
background: rgba(255,255,255,0.2);
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.link-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin: 0 auto 12px;
|
||||
background: rgba(255,255,255,0.2);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.link-title {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.delete-bookmark-btn {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: rgba(0,0,0,0.5);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.link-item:hover .delete-bookmark-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Add Link Button */
|
||||
.add-link-item {
|
||||
background: rgba(255,255,255,0.1);
|
||||
border: 2px dashed rgba(255,255,255,0.3);
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 48px;
|
||||
color: rgba(255,255,255,0.5);
|
||||
min-height: 125px; /* Ensure consistent height */
|
||||
}
|
||||
|
||||
.add-link-item:hover {
|
||||
background: rgba(255,255,255,0.2);
|
||||
color: white;
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
/* Modal Styles */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(5px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 15px;
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
||||
animation: fadeInUp 0.3s ease forwards;
|
||||
}
|
||||
|
||||
.modal-content h2 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 25px;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.form-actions button {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.form-actions button[type="submit"] {
|
||||
background-color: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.form-actions button[type="submit"]:hover {
|
||||
background-color: #5a67d8;
|
||||
}
|
||||
|
||||
.form-actions button[type="button"] {
|
||||
background-color: #e0e0e0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-actions button[type="button"]:hover {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
/* Icon Selector Styles */
|
||||
.icon-selector {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
|
||||
gap: 8px;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.icon-option {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.icon-option:hover {
|
||||
background: #e0e0e0;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.icon-option.selected {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #5a67d8;
|
||||
}
|
||||
|
||||
.icon-option .material-icons {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.icon-input-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.icon-input-group input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.icon-preview {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.footer {
|
||||
text-align: center;
|
||||
color: rgba(255,255,255,0.7);
|
||||
font-size: 14px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
/* Responsive Design */
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 20px 15px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
padding: 15px 50px 15px 18px;
|
||||
}
|
||||
|
||||
.links-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.recent-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.container > * {
|
||||
animation: fadeInUp 0.6s ease forwards;
|
||||
}
|
||||
|
||||
.search-section {
|
||||
animation-delay: 0.1s;
|
||||
}
|
||||
|
||||
.quick-links {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="main-content">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<img src="../../assets/images/Nebula-Logo.svg" alt="Nebula Browser Logo" class="logo">
|
||||
<h1 class="title">Nebula Browser</h1>
|
||||
</div>
|
||||
|
||||
<!-- Search Section -->
|
||||
<div class="search-section">
|
||||
<div class="search-container">
|
||||
<input type="text" class="search-input" placeholder="Search" id="searchInput">
|
||||
<button class="search-button" id="searchButton">
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Links -->
|
||||
<div class="quick-links">
|
||||
<h2 class="section-title">Quick Access</h2>
|
||||
<div class="links-grid" id="quickLinksGrid">
|
||||
<!-- Bookmarks will be populated by JavaScript -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Bookmark Modal -->
|
||||
<div id="addBookmarkModal" class="modal-overlay" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<h2>Add New Bookmark</h2>
|
||||
<form id="addBookmarkForm">
|
||||
<div class="form-group">
|
||||
<label for="bookmarkTitle">Title</label>
|
||||
<input type="text" id="bookmarkTitle" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bookmarkUrl">URL</label>
|
||||
<input type="url" id="bookmarkUrl" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bookmarkIcon">Icon</label>
|
||||
<div class="icon-input-group">
|
||||
<input type="text" id="bookmarkIcon" placeholder="Search for icon or enter emoji">
|
||||
<div class="icon-preview" id="iconPreview">⭐</div>
|
||||
</div>
|
||||
<div class="icon-selector" id="iconSelector">
|
||||
<!-- Icons will be generated dynamically -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="button" id="cancelAddBookmark">Cancel</button>
|
||||
<button type="submit">Add</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="footer">
|
||||
<p>© 2025 Nebula Browser.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
import { materialIcons } from './iconData.js';
|
||||
// Search functionality
|
||||
const searchInput = document.getElementById('searchInput');
|
||||
const searchButton = document.getElementById('searchButton');
|
||||
|
||||
function performSearch() {
|
||||
const query = searchInput.value.trim();
|
||||
if (query) {
|
||||
// Check if it's a URL
|
||||
if (query.includes('.') && !query.includes(' ')) {
|
||||
const url = query.startsWith('http') ? query : `https://${query}`;
|
||||
navigateToUrl(url);
|
||||
} else {
|
||||
// Perform search
|
||||
const searchUrl = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
|
||||
navigateToUrl(searchUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function navigateToUrl(url) {
|
||||
if (window.homeAPI) {
|
||||
window.homeAPI.navigateTo(url);
|
||||
} else {
|
||||
console.error('Home API not available');
|
||||
// Fallback for when preload script fails
|
||||
window.parent.postMessage({ type: 'navigate', url: url }, '*');
|
||||
}
|
||||
}
|
||||
|
||||
searchButton.addEventListener('click', performSearch);
|
||||
searchInput.addEventListener('keypress', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
performSearch();
|
||||
}
|
||||
});
|
||||
|
||||
// Quick links and recent items navigation
|
||||
document.addEventListener('click', (e) => {
|
||||
// Handle delete button click
|
||||
if (e.target.classList.contains('delete-bookmark-btn')) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const urlToDelete = e.target.dataset.url;
|
||||
deleteBookmark(urlToDelete);
|
||||
return; // Stop further processing
|
||||
}
|
||||
|
||||
// Handle add bookmark button click
|
||||
if (e.target.id === 'addBookmarkBtn' || e.target.closest('#addBookmarkBtn')) {
|
||||
modal.style.display = 'flex';
|
||||
resetModal();
|
||||
return; // Stop further processing
|
||||
}
|
||||
|
||||
// Handle navigation for links
|
||||
const linkItem = e.target.closest('.link-item');
|
||||
if (linkItem) {
|
||||
e.preventDefault();
|
||||
const url = linkItem.dataset.url;
|
||||
if (url) {
|
||||
navigateToUrl(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Focus search input on load
|
||||
window.addEventListener('load', () => {
|
||||
searchInput.focus();
|
||||
loadQuickLinks();
|
||||
});
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
document.addEventListener('keydown', (e) => {
|
||||
// Ctrl+L or F6 to focus address bar (search input)
|
||||
if ((e.ctrlKey && e.key === 'l') || e.key === 'F6') {
|
||||
e.preventDefault();
|
||||
searchInput.focus();
|
||||
searchInput.select();
|
||||
}
|
||||
});
|
||||
|
||||
// Load quick links from bookmarks
|
||||
async function loadQuickLinks() {
|
||||
const quickLinksGrid = document.getElementById('quickLinksGrid');
|
||||
if (!quickLinksGrid) return;
|
||||
|
||||
if (window.homeAPI && window.homeAPI.getBookmarks) {
|
||||
try {
|
||||
const { home_bookmarks } = await window.homeAPI.getBookmarks();
|
||||
quickLinksGrid.innerHTML = ''; // Clear existing links
|
||||
|
||||
if (home_bookmarks && home_bookmarks.length > 0) {
|
||||
home_bookmarks.forEach(bookmark => {
|
||||
const linkItem = document.createElement('a');
|
||||
linkItem.href = '#';
|
||||
linkItem.className = 'link-item';
|
||||
linkItem.dataset.url = bookmark.url;
|
||||
|
||||
const linkIcon = document.createElement('div');
|
||||
linkIcon.className = 'link-icon';
|
||||
|
||||
// Check if it's a Material Icon or emoji
|
||||
if (bookmark.icon && bookmark.icon.startsWith('material:')) {
|
||||
const materialIcon = document.createElement('span');
|
||||
materialIcon.className = 'material-icons';
|
||||
materialIcon.textContent = bookmark.icon.replace('material:', '');
|
||||
linkIcon.appendChild(materialIcon);
|
||||
} else {
|
||||
linkIcon.textContent = bookmark.icon || '⭐';
|
||||
}
|
||||
|
||||
const linkTitle = document.createElement('div');
|
||||
linkTitle.className = 'link-title';
|
||||
linkTitle.textContent = bookmark.title;
|
||||
|
||||
const deleteBtn = document.createElement('button');
|
||||
deleteBtn.className = 'delete-bookmark-btn';
|
||||
deleteBtn.textContent = 'x';
|
||||
deleteBtn.dataset.url = bookmark.url;
|
||||
|
||||
linkItem.appendChild(linkIcon);
|
||||
linkItem.appendChild(linkTitle);
|
||||
linkItem.appendChild(deleteBtn);
|
||||
quickLinksGrid.appendChild(linkItem);
|
||||
});
|
||||
}
|
||||
|
||||
// Add the "Add" button
|
||||
const addButton = document.createElement('div');
|
||||
addButton.className = 'link-item add-link-item';
|
||||
addButton.id = 'addBookmarkBtn';
|
||||
addButton.textContent = '+';
|
||||
quickLinksGrid.appendChild(addButton);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading home bookmarks:', error);
|
||||
quickLinksGrid.innerHTML = '<p style="color: white; text-align: center; grid-column: 1 / -1;">Could not load bookmarks.</p>';
|
||||
}
|
||||
} else {
|
||||
console.error('Home API for bookmarks not available');
|
||||
quickLinksGrid.innerHTML = '<p style="color: white; text-align: center; grid-column: 1 / -1;">Could not load bookmarks.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
// Modal handling
|
||||
const modal = document.getElementById('addBookmarkModal');
|
||||
const cancelBtn = document.getElementById('cancelAddBookmark');
|
||||
const form = document.getElementById('addBookmarkForm');
|
||||
|
||||
// Icon selector functionality
|
||||
const iconInput = document.getElementById('bookmarkIcon');
|
||||
const iconPreview = document.getElementById('iconPreview');
|
||||
const iconSelector = document.getElementById('iconSelector');
|
||||
// Dynamically generate icon options
|
||||
materialIcons.forEach(name => {
|
||||
const option = document.createElement('div');
|
||||
option.className = 'icon-option';
|
||||
option.dataset.icon = name;
|
||||
const span = document.createElement('span');
|
||||
span.className = 'material-icons';
|
||||
span.textContent = name;
|
||||
option.appendChild(span);
|
||||
iconSelector.appendChild(option);
|
||||
});
|
||||
let selectedIconType = 'emoji'; // 'emoji' or 'material'
|
||||
let selectedIcon = '⭐';
|
||||
|
||||
// Handle icon input changes
|
||||
iconInput.addEventListener('input', (e) => {
|
||||
const value = e.target.value.trim();
|
||||
if (value) {
|
||||
selectedIconType = 'emoji';
|
||||
selectedIcon = value;
|
||||
updateIconPreview(value);
|
||||
clearIconSelection();
|
||||
}
|
||||
});
|
||||
|
||||
// Handle icon selector clicks
|
||||
iconSelector.addEventListener('click', (e) => {
|
||||
const iconOption = e.target.closest('.icon-option');
|
||||
if (iconOption) {
|
||||
const iconName = iconOption.dataset.icon;
|
||||
selectedIconType = 'material';
|
||||
selectedIcon = iconName;
|
||||
|
||||
// Update input and preview
|
||||
iconInput.value = iconName;
|
||||
updateIconPreview(`material:${iconName}`);
|
||||
|
||||
// Update selection visual
|
||||
clearIconSelection();
|
||||
iconOption.classList.add('selected');
|
||||
}
|
||||
});
|
||||
|
||||
function updateIconPreview(icon) {
|
||||
iconPreview.innerHTML = '';
|
||||
if (icon.startsWith('material:')) {
|
||||
const materialIcon = document.createElement('span');
|
||||
materialIcon.className = 'material-icons';
|
||||
materialIcon.textContent = icon.replace('material:', '');
|
||||
iconPreview.appendChild(materialIcon);
|
||||
} else {
|
||||
iconPreview.textContent = icon || '⭐';
|
||||
}
|
||||
}
|
||||
|
||||
function clearIconSelection() {
|
||||
iconSelector.querySelectorAll('.icon-option').forEach(option => {
|
||||
option.classList.remove('selected');
|
||||
});
|
||||
}
|
||||
|
||||
// Reset modal when opened
|
||||
function resetModal() {
|
||||
form.reset();
|
||||
selectedIconType = 'emoji';
|
||||
selectedIcon = '⭐';
|
||||
updateIconPreview('⭐');
|
||||
clearIconSelection();
|
||||
}
|
||||
|
||||
cancelBtn.addEventListener('click', () => {
|
||||
modal.style.display = 'none';
|
||||
});
|
||||
|
||||
modal.addEventListener('click', (e) => {
|
||||
if (e.target === modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const title = document.getElementById('bookmarkTitle').value;
|
||||
const url = document.getElementById('bookmarkUrl').value;
|
||||
|
||||
// Determine the final icon format
|
||||
let icon;
|
||||
if (selectedIconType === 'material') {
|
||||
icon = `material:${selectedIcon}`;
|
||||
} else {
|
||||
icon = selectedIcon || iconInput.value || '⭐';
|
||||
}
|
||||
|
||||
if (window.homeAPI && window.homeAPI.addBookmark) {
|
||||
const result = await window.homeAPI.addBookmark({ title, url, icon });
|
||||
if (result.success) {
|
||||
loadQuickLinks();
|
||||
modal.style.display = 'none';
|
||||
resetModal();
|
||||
} else {
|
||||
alert(result.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function deleteBookmark(url) {
|
||||
if (window.homeAPI && window.homeAPI.removeBookmark) {
|
||||
const result = await window.homeAPI.removeBookmark(url);
|
||||
if (result.success) {
|
||||
loadQuickLinks();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user