wow-politur: akzentfarbe waehlbar, sanfte ansichtswechsel, freundliche leerzustaende
- Einstellungen -> Allgemein: Akzentfarbe (8 Presets + eigener Farbwaehler), per color-mix theme-aware abgeleitet, in localStorage gespeichert - sanfter Fade + einmaliges Karten-Stagger beim View-Wechsel (Guard-Flag, respektiert prefers-reduced-motion) - Leerzustaende: "nichts passt zu deinen Filtern" + Filter zuruecksetzen, sonst "noch keine Projekte" + Neues Projekt (im Demo-Limit ausgeblendet) in Board/Galerie/Liste/Home - README als Markdown im Info-Panel (server: readmeFull-Feld) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
155
public/app.js
155
public/app.js
@@ -54,6 +54,39 @@ function escapeHtml(s) {
|
||||
return String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]))
|
||||
}
|
||||
|
||||
// Small, dependency-free Markdown -> HTML for a project's README. Everything is escaped first, so no
|
||||
// raw HTML from the file can run; then a safe subset is formatted. Links only for http(s), open extern.
|
||||
function renderMarkdown(src) {
|
||||
const esc = escapeHtml(String(src ?? '').replace(/\r\n?/g, '\n'))
|
||||
const inline = (s) => s
|
||||
.replace(/`([^`]+)`/g, (_, c) => `<code>${c}</code>`)
|
||||
.replace(/\[([^\]]+)\]\((https?:[^)\s]+)\)/g, (_, txt, url) => `<a href="${url}" target="_blank" rel="noopener">${txt}</a>`)
|
||||
.replace(/(^|[^*])\*\*([^*\n]+)\*\*/g, '$1<strong>$2</strong>')
|
||||
.replace(/(^|[^*_])[*_]([^*_\n]+)[*_]/g, '$1<em>$2</em>')
|
||||
const lines = esc.split('\n')
|
||||
let html = '', i = 0
|
||||
const closeList = (stack) => { while (stack.length) html += stack.pop() }
|
||||
const listStack = []
|
||||
while (i < lines.length) {
|
||||
const line = lines[i]
|
||||
// fenced code block
|
||||
if (/^\s*```/.test(line)) { closeList(listStack); i++; const buf = []; while (i < lines.length && !/^\s*```/.test(lines[i])) buf.push(lines[i++]); i++; html += `<pre><code>${buf.join('\n')}</code></pre>`; continue }
|
||||
if (/^\s*(---|\*\*\*|___)\s*$/.test(line)) { closeList(listStack); html += '<hr>'; i++; continue }
|
||||
const h = line.match(/^(#{1,6})\s+(.*)$/)
|
||||
if (h) { closeList(listStack); html += `<h${h[1].length}>${inline(h[2].trim())}</h${h[1].length}>`; i++; continue }
|
||||
const q = line.match(/^\s*>\s?(.*)$/) // '>' was escaped to >
|
||||
if (q) { closeList(listStack); const buf = []; let m = q; while (i < lines.length && (m = lines[i].match(/^\s*>\s?(.*)$/))) { buf.push(m[1]); i++ } html += `<blockquote>${inline(buf.join(' '))}</blockquote>`; continue }
|
||||
const li = line.match(/^(\s*)([-*+]|\d+\.)\s+(.*)$/)
|
||||
if (li) { const ordered = /\d/.test(li[2]); const want = ordered ? '</ol>' : '</ul>'; if (listStack[listStack.length - 1] !== want) { closeList(listStack); html += ordered ? '<ol>' : '<ul>'; listStack.push(want) } html += `<li>${inline(li[3].trim())}</li>`; i++; continue }
|
||||
if (!line.trim()) { closeList(listStack); i++; continue }
|
||||
// paragraph: gather until blank
|
||||
closeList(listStack); const buf = [line]; i++; while (i < lines.length && lines[i].trim() && !/^\s*(#|>|```|[-*+]\s|\d+\.\s|---|\*\*\*)/.test(lines[i])) buf.push(lines[i++])
|
||||
html += `<p>${inline(buf.join(' '))}</p>`
|
||||
}
|
||||
closeList(listStack)
|
||||
return html
|
||||
}
|
||||
|
||||
function timeAgo(iso) {
|
||||
if (!iso) return ''
|
||||
const days = Math.floor((Date.now() - new Date(iso)) / 86400000)
|
||||
@@ -92,6 +125,7 @@ function avatar(p, cls = '') {
|
||||
const deletableMB = (p) => p.storage ? p.storage.deletable.Cache + p.storage.deletable.Release + p.storage.deletable.Output : 0
|
||||
// last change = newest file in the project (server: lib/activity.js), else last commit / folder date
|
||||
const lastActivity = (p) => p.lastChange?.at ?? p.lastCommit?.date ?? p.mtime
|
||||
const isToday = (iso) => { if (!iso) return false; const d = new Date(iso), n = new Date(); return d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth() && d.getDate() === n.getDate() }
|
||||
|
||||
function fmtDate(iso, withYear = true) {
|
||||
if (!iso) return '–'
|
||||
@@ -1370,6 +1404,30 @@ function sortProjects(items) {
|
||||
})
|
||||
}
|
||||
|
||||
// is any search / quick-filter / status filter narrowing the list right now?
|
||||
function filtersActive() {
|
||||
const status = document.getElementById('fltStatus')?.value ?? 'all'
|
||||
return !!searchTerm.trim() || quickFilter !== 'all' || status !== 'all' || (activeView === 'home' && homeStatus !== 'all')
|
||||
}
|
||||
function clearFilters() {
|
||||
searchTerm = ''
|
||||
const s = document.getElementById('search'); if (s) s.value = ''
|
||||
quickFilter = 'all'
|
||||
const fs = document.getElementById('fltStatus'); if (fs) fs.value = 'all'
|
||||
homeStatus = 'all'
|
||||
render()
|
||||
}
|
||||
// friendly empty state: "no matches + reset" when filtering, else "no projects + new" (hidden when demo caps)
|
||||
function emptyState() {
|
||||
const T = window.I18N.t
|
||||
if (filtersActive())
|
||||
return `<div class="empty rich">${ic('search-x', 'xl')}<div class="et">${T('empty.noMatch')}</div>` +
|
||||
`<button type="button" class="btn ghost" onclick="clearFilters()">${ic('rotate-ccw', 'sm')}${T('empty.resetFilters')}</button></div>`
|
||||
const act = demoBlocksNew() ? '' :
|
||||
`<button type="button" class="btn primary" onclick="openNewProject('')">${ic('folder-plus', 'sm')}${T('empty.newProject')}</button>`
|
||||
return `<div class="empty rich">${ic('folder-open', 'xl')}<div class="et">${T('empty.noProjects')}</div>${act}</div>`
|
||||
}
|
||||
|
||||
/* ── header: KPIs, quick filters ──────────────────────────────────────── */
|
||||
|
||||
function renderKpis() {
|
||||
@@ -1555,6 +1613,7 @@ function renderBoard() {
|
||||
const board = document.getElementById('board')
|
||||
board.innerHTML = ''
|
||||
const visible = visibleProjects({ useStatus: false })
|
||||
if (!visible.length) { board.innerHTML = `<div class="boardempty">${emptyState()}</div>`; return }
|
||||
|
||||
for (const col of STATUS) {
|
||||
const items = visible
|
||||
@@ -1600,7 +1659,7 @@ function renderBoard() {
|
||||
function renderGallery() {
|
||||
const grid = document.getElementById('galleryGrid')
|
||||
const items = sortProjects(visibleProjects())
|
||||
if (!items.length) { grid.innerHTML = `<div class="empty">${ic('search-x', 'xl')}<div>${t('empty.noProjects')}</div></div>`; return }
|
||||
if (!items.length) { grid.innerHTML = emptyState(); return }
|
||||
grid.innerHTML = ''
|
||||
for (const p of items) {
|
||||
const tile = document.createElement('div')
|
||||
@@ -1654,7 +1713,7 @@ function renderList() {
|
||||
<button class="btn ghost" data-a="explorer" title="Explorer">${ic('folder-open')}</button>
|
||||
<button class="btn ghost" data-a="vscode" title="VS Code">${ic('code-xml')}</button>
|
||||
<button class="btn ghost" data-a="details" title="Details">${ic('chevron-right')}</button>
|
||||
</div></td></tr>`).join('') || `<tr><td colspan="9" class="empty">${t('empty.noProjects')}</td></tr>`}</tbody>`
|
||||
</div></td></tr>`).join('') || `<tr><td colspan="9" class="empty">${emptyState()}</td></tr>`}</tbody>`
|
||||
for (const th of table.querySelectorAll('th[data-sort]')) {
|
||||
th.onclick = () => { document.getElementById('fltSort').value = th.dataset.sort; render() }
|
||||
}
|
||||
@@ -1727,7 +1786,45 @@ function sortHome(items) {
|
||||
}
|
||||
const HL_SEG = [{ k: 'cards', ic: 'layout-grid', key: 'home.cards' }, { k: 'compact', ic: 'grid-2x2', key: 'home.compact' }, { k: 'list', ic: 'list', key: 'home.list' }]
|
||||
const HL_SORT = [{ k: 'mtime', key: 'flt.sort.mtime' }, { k: 'name', key: 'flt.sort.name' }, { k: 'size', key: 'flt.sort.size' }]
|
||||
// "Today" band on the home page: greeting, continue-where-you-left-off, quick stats. From the loaded
|
||||
// projects only (no extra request). Shown on the default home (no filter, no search).
|
||||
let todayOpen = (() => { try { return localStorage.getItem('dash.todayOpen') !== '0' } catch { return true } })()
|
||||
function renderToday() {
|
||||
const band = document.getElementById('todayBand')
|
||||
if (!band) return
|
||||
if (homeStatus !== 'all' || searchTerm.trim()) { band.innerHTML = ''; return }
|
||||
const live = projects.filter((p) => p.status !== 'archived')
|
||||
const recent = [...live].sort((a, b) => new Date(lastActivity(b)) - new Date(lastActivity(a))).slice(0, 3)
|
||||
const changed = live.filter((p) => isToday(lastActivity(p))).length
|
||||
const due = projects.filter(backupDue).length
|
||||
const active = projects.filter((p) => p.status === 'active').length
|
||||
const h = new Date().getHours()
|
||||
const greet = t(h < 5 ? 'today.night' : h < 11 ? 'today.morning' : h < 17 ? 'today.day' : h < 22 ? 'today.evening' : 'today.night')
|
||||
const dateStr = new Date().toLocaleDateString(I18N.locale(), { weekday: 'long', day: 'numeric', month: 'long' })
|
||||
const chip = (icon, n, label, q) => n ? `<button type="button" class="tchip" data-q="${q}">${ic(icon, 'sm')}<b>${n}</b> ${label}</button>` : ''
|
||||
const stats = chip('file-pen', changed, t('today.changed'), 'all') + chip('clock-alert', due, t('today.due'), 'due') + chip('rocket', active, t('today.active'), 'active')
|
||||
const cards = recent.map((p) => `<div class="tcard" data-open="${escapeHtml(p.name)}" role="button" tabindex="0">
|
||||
${avatar(p)}<span class="tc-main"><span class="tc-name">${escapeHtml(p.name)}</span><span class="tc-sub">${statusHtml(p.status)}<span class="hint">· ${timeAgo(lastActivity(p))}</span></span></span>${qsGroup(p, true, false)}</div>`).join('')
|
||||
band.innerHTML = `<div class="today ${todayOpen ? '' : 'closed'}">
|
||||
<div class="today-head">
|
||||
<div><div class="today-greet">${greet}</div><div class="today-date">${dateStr}</div></div>
|
||||
<div class="today-stats">${stats}</div>
|
||||
<button type="button" class="today-toggle" title="${t('today.toggle')}">${ic('chevron-down', 'sm')}</button>
|
||||
</div>
|
||||
<div class="today-body">${cards}${recent.length ? `<a href="#" class="jump today-act">${ic('activity', 'sm')}${t('today.activity')}</a>` : ''}</div>
|
||||
</div>`
|
||||
band.querySelector('.today-toggle').onclick = () => { todayOpen = !todayOpen; try { localStorage.setItem('dash.todayOpen', todayOpen ? '1' : '0') } catch {}; band.querySelector('.today').classList.toggle('closed', !todayOpen) }
|
||||
for (const b of band.querySelectorAll('.tchip')) b.onclick = () => { homeStatus = b.dataset.q; renderHome() }
|
||||
band.querySelector('.today-act')?.addEventListener('click', (e) => { e.preventDefault(); setView('activity') })
|
||||
for (const b of band.querySelectorAll('.tcard')) {
|
||||
const p = projects.find((x) => x.name === b.dataset.open)
|
||||
b.onclick = (e) => { if (!e.target.closest('.qsg')) openEditor(p) }
|
||||
wireQuickStart(b, p)
|
||||
}
|
||||
}
|
||||
|
||||
function renderHome() {
|
||||
renderToday()
|
||||
const base = projects.filter(matchesSearch)
|
||||
const pills = HOME_PILLS.map((q) => {
|
||||
const n = base.filter(pillTest(q)).length
|
||||
@@ -1785,8 +1882,13 @@ const ADV_VIEWS = ['board', 'gallery', 'list']
|
||||
function setView(view) {
|
||||
if (uiMode === 'simple' && ADV_VIEWS.includes(view)) view = 'home'
|
||||
if (uiMode === 'advanced' && view === 'home') view = lastAdvView()
|
||||
const changed = activeView !== view
|
||||
activeView = view
|
||||
for (const el of document.querySelectorAll('.view')) el.classList.toggle('active', el.id === view)
|
||||
if (changed) { // one-shot stagger flag; render() builds the cards, flag clears after the animation
|
||||
document.body.classList.add('switching')
|
||||
clearTimeout(setView._t); setView._t = setTimeout(() => document.body.classList.remove('switching'), 500)
|
||||
}
|
||||
for (const btn of document.querySelectorAll('#tabs button')) btn.classList.toggle('active', btn.dataset.view === view)
|
||||
document.body.classList.toggle('view-wide', WIDE_VIEWS.includes(view))
|
||||
updateToolbarForView()
|
||||
@@ -2484,10 +2586,19 @@ function renderInfo(name, d) {
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
// README rendered as markdown (collapsible; open by default when short)
|
||||
const readmeCard = d.readmeFull
|
||||
? `<details class="card-sec mdcard" id="info-readme"${d.readmeFull.length < 1500 ? ' open' : ''}>
|
||||
<summary><h4>${ic('book-open')}README</h4>${ic('chevron-down', 'sm')}</summary>
|
||||
<div class="md">${renderMarkdown(d.readmeFull)}</div>
|
||||
</details>`
|
||||
: ''
|
||||
|
||||
const el = document.getElementById('sec-info')
|
||||
el.innerHTML =
|
||||
section('notebook-text', t('info.description'), `<div class="pdesc-view">${descBody}</div>${descEdit}`,
|
||||
{ id: 'info-desc', right: `<a href="#" class="jump" id="btnDescEdit">${ic('pencil', 'sm')}${desc ? t('desc.edit') : t('desc.write')}</a>` }) +
|
||||
readmeCard +
|
||||
section('info', t('info.overview'), overview, { right: del >= 1 ? `<span class="adv">${jumpLink('act-clean', t('info.cleanUp'))}</span>` : '' }) +
|
||||
section('git-branch', 'Git', gitBody, { adv: true, right: jumpLink('act-git', g.isRepo ? t('info.pushRemote') : t('set.setup')) }) +
|
||||
(name === '_Tools' || !itchOn() ? '' : section('rocket', 'itch.io', itchBody, { adv: true, right: jumpLink('act-itch', ip.exists ? t('info.view') : t('info.generate')) })) +
|
||||
@@ -3420,6 +3531,45 @@ function applyTheme() {
|
||||
const theme = themeMode === 'system' ? (systemDark.matches ? 'dark' : 'light') : themeMode
|
||||
document.documentElement.dataset.theme = theme
|
||||
for (const b of document.querySelectorAll('#themeSeg button')) b.classList.toggle('active', b.dataset.mode === themeMode)
|
||||
applyAccent() // accent is derived per theme, so recompute on every theme change
|
||||
}
|
||||
|
||||
/* ── accent colour (Einstellungen → Allgemein → Darstellung) ──────────── */
|
||||
// All accent CSS vars are derived from one chosen base colour via color-mix, theme-aware. Not set =
|
||||
// the hand-tuned defaults in index.html stay untouched.
|
||||
const ACCENTS = ['#6366f1', '#3b82f6', '#06b6d4', '#10b981', '#f59e0b', '#ef4444', '#ec4899', '#a855f7']
|
||||
let accentBase = (() => { try { return localStorage.getItem('dash.accent') || '' } catch { return '' } })()
|
||||
function applyAccent() {
|
||||
const r = document.documentElement, s = r.style
|
||||
if (!accentBase) { for (const v of ['--accent', '--accent-2', '--accent-soft', '--accent-text']) s.removeProperty(v); return }
|
||||
const dark = r.dataset.theme === 'dark'
|
||||
const base = accentBase
|
||||
const accent = dark ? `color-mix(in srgb, ${base} 78%, #fff)` : base
|
||||
s.setProperty('--accent', accent)
|
||||
s.setProperty('--accent-2', `color-mix(in srgb, ${base} 65%, ${dark ? '#c084fc' : '#a855f7'})`)
|
||||
s.setProperty('--accent-soft', dark ? `color-mix(in srgb, ${base} 30%, #171a23)` : `color-mix(in srgb, ${base} 13%, #fff)`)
|
||||
s.setProperty('--accent-text', dark ? `color-mix(in srgb, ${base} 45%, #fff)` : `color-mix(in srgb, ${base} 72%, #1e1b4b)`)
|
||||
}
|
||||
function setAccent(hex) {
|
||||
accentBase = /^#[0-9a-f]{6}$/i.test(hex || '') && hex.toLowerCase() !== '#6366f1' ? hex.toLowerCase() : ''
|
||||
try { accentBase ? localStorage.setItem('dash.accent', accentBase) : localStorage.removeItem('dash.accent') } catch {}
|
||||
applyAccent()
|
||||
renderAccentPicker()
|
||||
}
|
||||
function renderAccentPicker() {
|
||||
const box = document.getElementById('accentSwatches')
|
||||
if (!box) return
|
||||
const cur = accentBase || '#6366f1'
|
||||
box.innerHTML = ACCENTS.map((c) => `<button type="button" class="swatch ${c === cur ? 'active' : ''}" style="--sw:${c}" data-accent="${c}" title="${c}"></button>`).join('')
|
||||
for (const b of box.querySelectorAll('[data-accent]')) b.onclick = () => setAccent(b.dataset.accent)
|
||||
const custom = document.getElementById('accentCustom')
|
||||
if (custom) { custom.value = cur; const lab = custom.closest('.swatch'); if (lab) lab.classList.toggle('active', !ACCENTS.includes(cur)) }
|
||||
}
|
||||
function initAccent() {
|
||||
applyAccent()
|
||||
renderAccentPicker()
|
||||
const custom = document.getElementById('accentCustom')
|
||||
if (custom) custom.oninput = (e) => setAccent(e.target.value)
|
||||
}
|
||||
function setThemeMode(mode) {
|
||||
themeMode = ['light', 'dark', 'system'].includes(mode) ? mode : 'system'
|
||||
@@ -3566,6 +3716,7 @@ document.addEventListener('keydown', (e) => {
|
||||
const [hashView, hashProject, hashSec] = decodeURIComponent(location.hash.slice(1)).split('/')
|
||||
const VIEWS = ['home', 'board', 'gallery', 'list', 'tasks', 'storage', 'activity']
|
||||
initTheme()
|
||||
initAccent()
|
||||
initLang()
|
||||
initUiMode()
|
||||
if (VIEWS.includes(hashView)) setView(hashView)
|
||||
|
||||
Reference in New Issue
Block a user