import { esc, formatWhen, stripTags } from './utils.js'; export function renderNoteList(listEl, options) { if (!listEl) return; options = options || {}; var pane = options.pane || 'active'; var search = options.search || ''; var source = pane === 'trash' ? (options.trash || []) : (options.notes || []); var filtered = source; if (search) { filtered = source.filter(function(n) { var hay = ((n.title || '') + ' ' + stripTags(n.body || '')).toLowerCase(); return hay.indexOf(search) !== -1; }); } if (filtered.length === 0) { listEl.innerHTML = '
' + (search ? 'No matches' : (pane === 'trash' ? 'Trash is empty' : '')) + '
'; return; } listEl.innerHTML = filtered.map(function(n) { var snippet = stripTags(n.body || '').substring(0, 110); var when = formatWhen(pane === 'trash' ? n.deleted_at : n.updated_at); var active = (n.id === options.activeId && pane === 'active') ? ' active' : ''; var trashActions = pane === 'trash' ? '
' + '' + '' + '
' : ''; return '
' + '' + trashActions + '
'; }).join(''); } export function updateTrashCount(el, trashCount) { if (!el) return; el.textContent = trashCount ? '(' + trashCount + ')' : ''; }