Kanban
Qwen 3.6 27B MTP GGUF IQ4 NL · full

Reviews & generation details
Reviews
No human review yet. Unreviewed does not mean unsuccessful.
Generation context
Imported historical artifact. Its exact original instructions and lineage are not known.
Generation prompt · exact text unavailable
See the current prompt for reference. It may differ from the instructions used to generate this artifact.
Inspect original source 50,264 bytes · SHA-256 ecd29fa3b20d
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kanban Board</title>
<style>
/* ============================================
TUNABLE CONSTANTS & THEME
============================================ */
:root {
--bg: #f4f5f7;
--board-bg: #f4f5f7;
--column-bg: #ebecf0;
--column-bg-hover: #e4e5e9;
--card-bg: #ffffff;
--card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
--card-shadow-hover: 0 4px 12px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
--card-shadow-drag: 0 14px 32px rgba(0,0,0,0.22), 0 4px 8px rgba(0,0,0,0.15);
--text-primary: #172b4d;
--text-secondary: #5e6c84;
--text-tertiary: #97a0af;
--accent: #0079bf;
--accent-hover: #026aa7;
--danger: #eb5a46;
--danger-hover: #cf513d;
--success: #61bd4f;
--wip-exceeded: #eb5a46;
--border: #dfe1e6;
--radius: 8px;
--radius-sm: 4px;
--transition-fast: 150ms ease;
--transition-med: 250ms ease;
--font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
--column-width: 272px;
--card-min-height: 20px;
--header-height: 48px;
--topbar-height: 56px;
--label-blue: #34458a;
--label-green: #61b44d;
--label-yellow: #f2d600;
--label-red: #eb5a46;
--label-purple: #c377e0;
--label-teal: #00897b;
--label-orange: #fa5a47;
--label-pink: #ff78cb;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: var(--font);
background: var(--bg);
color: var(--text-primary);
overflow: hidden;
height: 100vh;
-webkit-font-smoothing: antialiased;
}
/* TOP BAR */
#topbar {
height: var(--topbar-height);
background: linear-gradient(135deg, #0079bf 0%, #005a8c 100%);
display: flex;
align-items: center;
padding: 0 20px;
gap: 16px;
z-index: 100;
position: relative;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#topbar h1 {
color: #fff;
font-size: 18px;
font-weight: 700;
letter-spacing: -0.3px;
flex-shrink: 0;
}
#search-box { flex: 1; max-width: 320px; position: relative; }
#search-box input {
width: 100%; height: 34px; border: none; border-radius: 6px;
padding: 0 12px 0 36px; font-size: 14px; font-family: var(--font);
background: rgba(255,255,255,0.2); color: #fff; outline: none;
transition: background var(--transition-fast);
}
#search-box input::placeholder { color: rgba(255,255,255,0.7); }
#search-box input:focus { background: rgba(255,255,255,0.3); }
#search-box .search-icon {
position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
color: rgba(255,255,255,0.7); font-size: 14px; pointer-events: none;
}
#filter-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-chip {
height: 28px; padding: 0 12px; border-radius: 14px;
font-size: 12px; font-weight: 600; cursor: pointer;
border: 2px solid transparent; transition: all var(--transition-fast);
display: flex; align-items: center; gap: 4px; color: #fff;
background: rgba(255,255,255,0.25);
}
.filter-chip:hover { background: rgba(255,255,255,0.35); }
.filter-chip.active { background: #fff; color: var(--text-primary); border-color: #fff; }
#add-column-btn {
height: 34px; padding: 0 16px; border-radius: 6px;
border: 2px solid rgba(255,255,255,0.4); background: transparent;
color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
font-family: var(--font); transition: all var(--transition-fast); flex-shrink: 0;
}
#add-column-btn:hover { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.6); }
/* BOARD */
#board-container {
height: calc(100vh - var(--topbar-height));
overflow-x: auto; overflow-y: hidden;
display: flex; align-items: flex-start;
padding: 20px; gap: 12px;
}
#board-container::-webkit-scrollbar { height: 10px; }
#board-container::-webkit-scrollbar-track { background: var(--column-bg); border-radius: 5px; }
#board-container::-webkit-scrollbar-thumb { background: #c4c9cc; border-radius: 5px; }
#board-container::-webkit-scrollbar-thumb:hover { background: #a9abb1; }
#board {
display: flex; gap: 12px; height: 100%; flex-shrink: 0;
}
/* COLUMNS */
.column {
width: var(--column-width); max-width: var(--column-width);
min-width: var(--column-width); background: var(--column-bg);
border-radius: var(--radius); display: flex; flex-direction: column;
max-height: 100%; transition: background var(--transition-fast);
position: relative; flex-shrink: 0;
}
.column.wip-exceeded { background: #fde8e5; border: 2px solid var(--wip-exceeded); }
.column-header {
height: var(--header-height); padding: 0 12px;
display: flex; align-items: center; justify-content: space-between;
cursor: grab; user-select: none; flex-shrink: 0;
border-radius: var(--radius) var(--radius) 0 0;
}
.column-header:active { cursor: grabbing; }
.column-header-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.column-title {
font-size: 14px; font-weight: 700; white-space: nowrap;
overflow: hidden; text-overflow: ellipsis;
}
.column-count {
font-size: 12px; color: var(--text-tertiary); font-weight: 600;
background: rgba(0,0,0,0.06); padding: 1px 7px; border-radius: 10px; flex-shrink: 0;
}
.column-header-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition-fast); }
.column:hover .column-header-actions { opacity: 1; }
.column-header-actions button {
width: 26px; height: 26px; border: none; background: transparent;
border-radius: var(--radius-sm); cursor: pointer; font-size: 16px;
color: var(--text-secondary); display: flex; align-items: center;
justify-content: center; transition: all var(--transition-fast);
}
.column-header-actions button:hover { background: rgba(0,0,0,0.08); color: var(--text-primary); }
.column-cards {
flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 8px;
display: flex; flex-direction: column; gap: 8px; min-height: var(--card-min-height);
}
.column-cards::-webkit-scrollbar { width: 6px; }
.column-cards::-webkit-scrollbar-track { background: transparent; }
.column-cards::-webkit-scrollbar-thumb { background: #c4c9cc; border-radius: 3px; }
.column-cards.is-empty {
justify-content: center; border: 2px dashed #c4c9cc;
border-radius: 0 0 var(--radius) var(--radius); margin: 0 4px 4px; min-height: 80px;
}
.empty-column-msg {
color: var(--text-tertiary); font-size: 13px; font-style: italic;
text-align: center; pointer-events: none;
}
.add-card-btn {
padding: 8px 12px; border: none; background: transparent;
color: var(--text-secondary); font-size: 14px; cursor: pointer;
border-radius: var(--radius-sm); font-family: var(--font);
text-align: left; flex-shrink: 0; transition: all var(--transition-fast);
display: flex; align-items: center; gap: 6px; margin: 0 4px 8px;
}
.add-card-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
/* CARDS */
.card {
background: var(--card-bg); border-radius: var(--radius);
padding: 10px 12px; box-shadow: var(--card-shadow);
cursor: grab; transition: box-shadow var(--transition-fast), transform var(--transition-fast);
position: relative; user-select: none;
}
.card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-1px); }
.card:active { cursor: grabbing; }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin-bottom: 4px; word-break: break-word; }
.card-description {
font-size: 12px; color: var(--text-secondary); line-height: 1.4;
margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; overflow: hidden;
}
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.label-chip {
height: 18px; padding: 0 8px; border-radius: 3px;
font-size: 11px; font-weight: 600; color: #fff;
display: flex; align-items: center; line-height: 18px;
}
.card-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-tertiary); }
.card-meta .due-date { display: flex; align-items: center; gap: 4px; }
.card-meta .due-date.overdue { color: var(--danger); font-weight: 600; }
.card-actions {
position: absolute; top: 6px; right: 6px; display: flex;
gap: 2px; opacity: 0; transition: opacity var(--transition-fast);
}
.card:hover .card-actions { opacity: 1; }
.card-actions button {
width: 22px; height: 22px; border: none; background: var(--column-bg);
border-radius: 3px; cursor: pointer; font-size: 13px;
color: var(--text-secondary); display: flex; align-items: center;
justify-content: center; transition: all var(--transition-fast);
}
.card-actions button:hover { background: #d0d4db; color: var(--text-primary); }
/* DROP PLACEHOLDER */
.drop-indicator {
position: absolute; left: 0; right: 0; height: 3px;
background: var(--accent); border-radius: 2px; z-index: 5;
box-shadow: 0 0 0 2px rgba(0,121,191,0.2);
pointer-events: none;
}
/* DRAGGING CARD (floating) */
.floating-card {
position: fixed; z-index: 10000; pointer-events: none;
opacity: 0.92; transform: rotate(2.5deg) scale(1.04);
box-shadow: var(--card-shadow-drag); transition: none;
width: var(--column-width); max-width: var(--column-width);
}
/* GHOST PLACEHOLDER (where card was) */
.ghost-placeholder {
background: rgba(0,121,191,0.06); border: 2px dashed rgba(0,121,191,0.25);
border-radius: var(--radius); min-height: 32px;
}
/* COLUMN DRAGGING */
.column.dragging-column { opacity: 0.3; }
.column-drop-indicator {
width: 4px; height: calc(100% - 40px); min-height: 120px;
background: var(--accent); border-radius: 2px;
flex-shrink: 0; box-shadow: 0 0 0 4px rgba(0,121,191,0.15);
align-self: center; transition: margin 100ms ease;
}
/* MODALS & MENUS */
.modal-overlay {
position: fixed; inset: 0; background: rgba(0,0,0,0.5);
z-index: 5000; display: flex; align-items: center; justify-content: center;
animation: fadeIn 150ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
background: #fff; border-radius: 12px; padding: 24px;
width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: slideUp 200ms ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-field { margin-bottom: 16px; }
.modal-field label {
display: block; font-size: 12px; font-weight: 600;
color: var(--text-secondary); text-transform: uppercase;
letter-spacing: 0.5px; margin-bottom: 6px;
}
.modal-field input, .modal-field textarea {
width: 100%; padding: 8px 12px; border: 2px solid var(--border);
border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
color: var(--text-primary); outline: none; transition: border-color var(--transition-fast);
}
.modal-field input:focus, .modal-field textarea:focus { border-color: var(--accent); }
.modal-field textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.label-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.label-option {
height: 28px; padding: 0 12px; border-radius: 14px;
font-size: 12px; font-weight: 600; cursor: pointer;
border: 2px solid transparent; display: flex; align-items: center;
color: #fff; transition: all var(--transition-fast);
}
.label-option:hover { transform: scale(1.05); }
.label-option.selected { border-color: #333; transform: scale(1.05); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn {
padding: 8px 20px; border-radius: 6px; border: none;
font-size: 14px; font-weight: 600; cursor: pointer;
font-family: var(--font); transition: all var(--transition-fast);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--column-bg); color: var(--text-primary); }
.btn-secondary:hover { background: #d0d4db; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.dropdown-menu {
position: fixed; background: #fff; border-radius: var(--radius);
box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.1);
z-index: 4000; min-width: 180px; padding: 6px 0; animation: fadeIn 100ms ease;
}
.dropdown-item {
padding: 8px 16px; font-size: 14px; cursor: pointer;
display: flex; align-items: center; gap: 8px; color: var(--text-primary);
transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--column-bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #fde8e5; }
.dropdown-separator { height: 1px; background: var(--border); margin: 4px 0; }
.wip-input-row {
padding: 8px 16px; display: flex; align-items: center; gap: 8px; font-size: 14px;
}
.wip-input-row input {
width: 50px; padding: 4px 8px; border: 2px solid var(--border);
border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
text-align: center; outline: none;
}
.wip-input-row input:focus { border-color: var(--accent); }
/* TOAST */
#toast-container {
position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
z-index: 9000; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
background: #333; color: #fff; padding: 10px 20px; border-radius: 8px;
font-size: 14px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
display: flex; align-items: center; gap: 12px; animation: toastIn 200ms ease;
}
.toast .undo-btn {
color: #79bbff; font-weight: 700; cursor: pointer; text-decoration: underline;
background: none; border: none; font-size: 14px; font-family: var(--font);
}
.toast .undo-btn:hover { color: #4dabf7; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
/* INLINE EDITING */
.inline-edit-input {
font-size: 14px; font-family: var(--font); font-weight: 700;
border: 2px solid var(--accent); border-radius: var(--radius-sm);
padding: 2px 6px; outline: none; width: 100%; background: #fff;
}
/* Card settle animation */
@keyframes cardSettle { 0% { transform: scale(1.02); } 100% { transform: scale(1); } }
.card.just-dropped { animation: cardSettle 200ms ease; }
</style>
</head>
<body>
<!-- TOP BAR -->
<div id="topbar">
<h1>📋 Kanban Board</h1>
<div id="search-box">
<span class="search-icon">🔍</span>
<input type="text" id="search-input" placeholder="Search cards...">
</div>
<div id="filter-bar"></div>
<button id="add-column-btn">+ Add Column</button>
</div>
<!-- BOARD -->
<div id="board-container">
<div id="board"></div>
</div>
<!-- TOAST -->
<div id="toast-container"></div>
<script>
/* ============================================
SECTION 1: TUNABLE CONSTANTS
============================================ */
const CONFIG = {
STORAGE_KEY: 'kanban-board-state-v2',
LABEL_PALETTE: [
{ name: 'Blue', color: '#34458a' },
{ name: 'Green', color: '#61b44d' },
{ name: 'Yellow', color: '#f2d600' },
{ name: 'Red', color: '#eb5a46' },
{ name: 'Purple', color: '#c377e0' },
{ name: 'Teal', color: '#00897b' },
{ name: 'Orange', color: '#fa5a47' },
{ name: 'Pink', color: '#ff78cb' },
],
DEFAULT_COLUMNS: ['Backlog', 'To Do', 'In Progress', 'Review', 'Done'],
AUTO_SCROLL_SPEED: 15,
AUTO_SCROLL_MARGIN: 50,
DRAG_TILT_DEG: 2.5,
DRAG_SCALE: 1.04,
TOAST_DURATION: 5000,
MIN_COLUMNS: 1,
};
/* ============================================
SECTION 2: UTILITIES
============================================ */
const $ = (sel, parent = document) => parent.querySelector(sel);
const $$ = (sel, parent = document) => [...parent.querySelectorAll(sel)];
function genId() {
return 'id_' + Math.random().toString(36).substr(2, 9) + Date.now().toString(36);
}
function deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
function escapeHtml(str) {
const d = document.createElement('div');
d.textContent = str;
return d.innerHTML;
}
function formatDate(dateStr) {
if (!dateStr) return '';
const d = new Date(dateStr + 'T00:00:00');
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
return `${months[d.getMonth()]} ${d.getDate()}`;
}
function isOverdue(dateStr) {
if (!dateStr) return false;
const today = new Date(); today.setHours(0,0,0,0);
return new Date(dateStr) < today;
}
/* ============================================
SECTION 3: MODEL — SINGLE SOURCE OF TRUTH
============================================ */
let model = null;
let undoState = null;
function createDefaultModel() {
const columns = CONFIG.DEFAULT_COLUMNS.map((title, i) => ({
id: genId(),
title,
wipLimit: null,
cards: generateSampleCards(i),
}));
return { columns, columnOrder: columns.map(c => c.id), labelFilters: [], searchQuery: '' };
}
function generateSampleCards(colIndex) {
const samples = [
[
{ title: 'Research competitors', description: 'Analyze top 5 competitor features and pricing', labels: ['Blue'], dueDate: daysFromNow(3) },
{ title: 'Define user personas', description: 'Create 3 primary user personas with pain points', labels: ['Purple'], dueDate: null },
],
[
{ title: 'Design login page', description: 'Create mockup for auth flow', labels: ['Green', 'Pink'], dueDate: daysFromNow(1) },
],
[
{ title: 'Implement auth API', description: 'JWT-based authentication endpoints', labels: ['Red', 'Teal'], dueDate: daysFromNow(5) },
{ title: 'Database schema', description: 'Design and implement initial schema', labels: ['Blue'], dueDate: null },
],
[
{ title: 'Code review: auth', description: 'Review authentication module', labels: ['Yellow'], dueDate: daysFromNow(2) },
],
[
{ title: 'Setup CI/CD pipeline', description: 'GitHub Actions for automated testing and deployment', labels: ['Teal', 'Green'], dueDate: null },
],
];
const arr = samples[colIndex];
if (!arr) return [];
return arr.map(c => ({ id: genId(), title: c.title, description: c.description || '', labels: c.labels || [], dueDate: c.dueDate }));
}
function daysFromNow(n) {
const d = new Date(); d.setDate(d.getDate() + n);
return d.toISOString().split('T')[0];
}
function saveModel() {
try { localStorage.setItem(CONFIG.STORAGE_KEY, JSON.stringify(model)); } catch(e) {}
}
function loadModel() {
try {
const saved = localStorage.getItem(CONFIG.STORAGE_KEY);
if (saved) {
const p = JSON.parse(saved);
if (p && p.columns && p.columnOrder) return p;
}
} catch(e) {}
return createDefaultModel();
}
function getColumnById(id) { return model.columns.find(c => c.id === id); }
function isWipExceeded(col) { return col.wipLimit != null && col.cards.length > col.wipLimit; }
function findCardAndColumn(cardId) {
for (const col of model.columns) {
const idx = col.cards.findIndex(c => c.id === cardId);
if (idx >= 0) return { columnId: col.id, index: idx, card: col.cards[idx] };
}
return null;
}
function getVisibleCards(col) {
let cards = col.cards;
if (model.labelFilters.length > 0) {
cards = cards.filter(c => c.labels.some(l => model.labelFilters.includes(l)));
}
if (model.searchQuery) {
const q = model.searchQuery.toLowerCase();
cards = cards.filter(c => c.title.toLowerCase().includes(q) || (c.description && c.description.toLowerCase().includes(q)));
}
return cards;
}
/* ============================================
SECTION 4: RENDERING
============================================ */
function renderAll() {
renderFilterBar();
renderBoard();
}
function renderFilterBar() {
const bar = $('#filter-bar'); bar.innerHTML = '';
CONFIG.LABEL_PALETTE.forEach(label => {
const chip = document.createElement('div');
const isActive = model.labelFilters.includes(label.name);
chip.className = 'filter-chip' + (isActive ? ' active' : '');
chip.style.background = isActive ? '#fff' : label.color;
if (isActive) chip.style.color = label.color;
chip.textContent = label.name;
chip.addEventListener('click', () => toggleLabelFilter(label.name));
bar.appendChild(chip);
});
}
function renderBoard() {
const board = $('#board'); board.innerHTML = '';
model.columnOrder.forEach(colId => {
const col = getColumnById(colId);
if (!col) return;
board.appendChild(buildColumnDOM(col));
});
}
function buildColumnDOM(col) {
const el = document.createElement('div');
el.className = 'column' + (isWipExceeded(col) ? ' wip-exceeded' : '');
el.dataset.columnId = col.id;
// Header
const header = document.createElement('div');
header.className = 'column-header';
header.dataset.columnId = col.id;
const left = document.createElement('div'); left.className = 'column-header-left';
const title = document.createElement('span');
title.className = 'column-title';
title.textContent = col.title;
title.dataset.columnId = col.id;
left.appendChild(title);
const count = document.createElement('span');
count.className = 'column-count';
count.textContent = col.cards.length;
left.appendChild(count);
const actions = document.createElement('div'); actions.className = 'column-header-actions';
const wipBtn = document.createElement('button');
wipBtn.title = 'Column settings'; wipBtn.textContent = '⚙️';
wipBtn.addEventListener('click', e => { e.stopPropagation(); showColumnMenu(col.id, e.clientX, e.clientY); });
actions.appendChild(wipBtn);
const delBtn = document.createElement('button');
delBtn.title = 'Delete column'; delBtn.textContent = '🗑️';
delBtn.addEventListener('click', e => { e.stopPropagation(); deleteColumn(col.id); });
actions.appendChild(delBtn);
header.appendChild(left); header.appendChild(actions);
el.appendChild(header);
// Cards area
const cardsArea = document.createElement('div');
cardsArea.className = 'column-cards' + (col.cards.length === 0 ? ' is-empty' : '');
cardsArea.dataset.columnId = col.id;
cardsArea.style.position = 'relative';
const visibleCards = getVisibleCards(col);
if (col.cards.length === 0) {
const msg = document.createElement('div');
msg.className = 'empty-column-msg';
msg.textContent = 'Drop cards here';
cardsArea.appendChild(msg);
} else {
visibleCards.forEach(card => {
cardsArea.appendChild(buildCardDOM(card, col.id));
});
}
el.appendChild(cardsArea);
// Add card button
const addBtn = document.createElement('button');
addBtn.className = 'add-card-btn';
addBtn.innerHTML = '+ Add a card';
addBtn.addEventListener('click', e => { e.stopPropagation(); showAddCardModal(col.id); });
el.appendChild(addBtn);
// Column header drag (drag the whole column)
header.addEventListener('pointerdown', e => {
if (e.target.tagName === 'BUTTON') return;
if (e.button !== 0) return;
startColumnDrag(col.id, el, e);
});
return el;
}
function buildCardDOM(card, columnId) {
const el = document.createElement('div');
el.className = 'card';
el.dataset.cardId = card.id;
el.dataset.columnId = columnId;
// Labels
if (card.labels && card.labels.length > 0) {
const labelsDiv = document.createElement('div'); labelsDiv.className = 'card-labels';
card.labels.forEach(lName => {
const l = CONFIG.LABEL_PALETTE.find(x => x.name === lName);
if (l) {
const chip = document.createElement('span');
chip.className = 'label-chip'; chip.style.background = l.color;
chip.textContent = l.name;
labelsDiv.appendChild(chip);
}
});
el.appendChild(labelsDiv);
}
// Title
const title = document.createElement('div');
title.className = 'card-title'; title.textContent = card.title;
title.addEventListener('dblclick', e => {
e.stopPropagation();
startInlineEdit(title, card, columnId);
});
el.appendChild(title);
// Description
if (card.description) {
const desc = document.createElement('div');
desc.className = 'card-description'; desc.textContent = card.description;
el.appendChild(desc);
}
// Due date meta
if (card.dueDate) {
const meta = document.createElement('div'); meta.className = 'card-meta';
const due = document.createElement('span');
due.className = 'due-date' + (isOverdue(card.dueDate) ? ' overdue' : '');
due.textContent = '📅 ' + formatDate(card.dueDate);
meta.appendChild(due);
el.appendChild(meta);
}
// Actions
const actDiv = document.createElement('div'); actDiv.className = 'card-actions';
const editBtn = document.createElement('button');
editBtn.title = 'Edit'; editBtn.textContent = '✏️';
editBtn.addEventListener('click', e => { e.stopPropagation(); showEditCardModal(card.id, columnId); });
actDiv.appendChild(editBtn);
const delBtn = document.createElement('button');
delBtn.title = 'Delete'; delBtn.textContent = '🗑️';
delBtn.addEventListener('click', e => { e.stopPropagation(); deleteCard(card.id, columnId); });
actDiv.appendChild(delBtn);
el.appendChild(actDiv);
// Card pointer drag
el.addEventListener('pointerdown', e => {
if (e.target.tagName === 'BUTTON') return;
if (e.button !== 0) return;
if (e.target.classList.contains('inline-edit-input')) return;
e.preventDefault();
startCardDrag(card.id, columnId, el, e);
});
return el;
}
/* ============================================
SECTION 5: INLINE EDITING
============================================ */
function startInlineEdit(element, card, columnId) {
const oldTitle = card.title;
const input = document.createElement('input');
input.className = 'inline-edit-input';
input.value = card.title;
element.textContent = '';
element.appendChild(input);
input.focus(); input.select();
const commit = (val) => {
const v = val !== undefined ? val : input.value.trim();
if (v && v !== oldTitle) {
const col = getColumnById(columnId);
if (col) {
saveUndoState('edit');
const c = col.cards.find(x => x.id === card.id);
if (c) { c.title = v; saveModel(); }
}
}
renderAll();
};
input.addEventListener('keydown', e => {
if (e.key === 'Enter') { e.preventDefault(); commit(); }
if (e.key === 'Escape') { e.preventDefault(); commit(oldTitle); }
});
input.addEventListener('blur', () => setTimeout(() => commit(), 100));
}
/* ============================================
SECTION 6: CRUD OPERATIONS
============================================ */
function saveUndoState(action) {
undoState = { action, previousModel: deepClone(model) };
}
function addColumn() {
saveUndoState('addColumn');
const col = { id: genId(), title: 'New Column', wipLimit: null, cards: [] };
model.columns.push(col);
model.columnOrder.push(col.id);
saveModel(); renderAll();
}
function deleteColumn(colId) {
if (model.columns.length <= CONFIG.MIN_COLUMNS) { showToast('Cannot delete the last column'); return; }
saveUndoState('deleteColumn');
const idx = model.columnOrder.indexOf(colId);
if (idx >= 0) model.columnOrder.splice(idx, 1);
model.columns = model.columns.filter(c => c.id !== colId);
saveModel(); renderAll();
showToast('Column deleted', () => undo());
}
function deleteCard(cardId, columnId) {
saveUndoState('deleteCard');
const col = getColumnById(columnId);
if (col) {
col.cards = col.cards.filter(c => c.id !== cardId);
saveModel(); renderAll();
showToast('Card deleted', () => undo());
}
}
function undo() {
if (undoState) {
model = undoState.previousModel;
undoState = null;
saveModel(); renderAll();
showToast('Undo successful');
}
}
function toggleLabelFilter(name) {
const idx = model.labelFilters.indexOf(name);
if (idx >= 0) model.labelFilters.splice(idx, 1);
else model.labelFilters.push(name);
saveModel(); renderAll();
}
/* ============================================
SECTION 7: MODALS
============================================ */
function showAddCardModal(columnId) {
const col = getColumnById(columnId);
const overlay = makeOverlay();
const modal = document.createElement('div'); modal.className = 'modal';
modal.innerHTML = `
<h2>Add Card to "${col ? escapeHtml(col.title) : ''}"</h2>
<div class="modal-field"><label>Title</label>
<input type="text" id="card-title-input" placeholder="Card title..."></div>
<div class="modal-field"><label>Description</label>
<textarea id="card-desc-input" placeholder="Description (optional)..."></textarea></div>
<div class="modal-field"><label>Labels</label>
<div class="label-selector" id="label-selector">
${CONFIG.LABEL_PALETTE.map(l => `<div class="label-option" data-name="${l.name}" style="background:${l.color}">${l.name}</div>`).join('')}</div></div>
<div class="modal-field"><label>Due Date</label>
<input type="date" id="card-date-input"></div>
<div class="modal-actions">
<button class="btn btn-secondary" id="modal-cancel">Cancel</button>
<button class="btn btn-primary" id="modal-add">Add Card</button></div>`;
overlay.appendChild(modal); document.body.appendChild(overlay);
const titleIn = modal.querySelector('#card-title-input'); titleIn.focus();
modal.querySelectorAll('.label-option').forEach(o => o.addEventListener('click', () => o.classList.toggle('selected')));
modal.querySelector('#modal-add').addEventListener('click', () => {
const title = titleIn.value.trim(); if (!title) { titleIn.focus(); return; }
const desc = modal.querySelector('#card-desc-input').value.trim();
const labels = [...modal.querySelectorAll('.label-option.selected')].map(el => el.dataset.name);
const dueDate = modal.querySelector('#card-date-input').value || null;
saveUndoState('addCard');
const c = getColumnById(columnId);
if (c) { c.cards.push({ id: genId(), title, description: desc, labels, dueDate }); saveModel(); renderAll(); }
removeOverlay(overlay);
});
modal.querySelector('#modal-cancel').addEventListener('click', () => removeOverlay(overlay));
overlay.addEventListener('click', e => { if (e.target === overlay) removeOverlay(overlay); });
const onKey = e => { if (e.key === 'Escape') { removeOverlay(overlay); document.removeEventListener('keydown', onKey); } };
document.addEventListener('keydown', onKey);
}
function showEditCardModal(cardId, columnId) {
const col = getColumnById(columnId);
const card = col ? col.cards.find(c => c.id === cardId) : null;
if (!card) return;
const overlay = makeOverlay();
const modal = document.createElement('div'); modal.className = 'modal';
modal.innerHTML = `
<h2>Edit Card</h2>
<div class="modal-field"><label>Title</label>
<input type="text" id="card-title-input" value="${escapeHtml(card.title)}"></div>
<div class="modal-field"><label>Description</label>
<textarea id="card-desc-input">${escapeHtml(card.description || '')}</textarea></div>
<div class="modal-field"><label>Labels</label>
<div class="label-selector" id="label-selector">
${CONFIG.LABEL_PALETTE.map(l => `<div class="label-option${card.labels.includes(l.name) ? ' selected' : ''}" data-name="${l.name}" style="background:${l.color}">${l.name}</div>`).join('')}</div></div>
<div class="modal-field"><label>Due Date</label>
<input type="date" id="card-date-input" value="${card.dueDate || ''}"></div>
<div class="modal-actions">
<button class="btn btn-danger" id="modal-delete">Delete</button>
<button class="btn btn-secondary" id="modal-cancel">Cancel</button>
<button class="btn btn-primary" id="modal-save">Save</button></div>`;
overlay.appendChild(modal); document.body.appendChild(overlay);
modal.querySelector('#card-title-input').focus();
modal.querySelectorAll('.label-option').forEach(o => o.addEventListener('click', () => o.classList.toggle('selected')));
modal.querySelector('#modal-save').addEventListener('click', () => {
const title = modal.querySelector('#card-title-input').value.trim(); if (!title) return;
const desc = modal.querySelector('#card-desc-input').value.trim();
const labels = [...modal.querySelectorAll('.label-option.selected')].map(el => el.dataset.name);
const dueDate = modal.querySelector('#card-date-input').value || null;
card.title = title; card.description = desc; card.labels = labels; card.dueDate = dueDate;
saveModel(); renderAll(); removeOverlay(overlay);
});
modal.querySelector('#modal-delete').addEventListener('click', () => { deleteCard(cardId, columnId); removeOverlay(overlay); });
modal.querySelector('#modal-cancel').addEventListener('click', () => removeOverlay(overlay));
overlay.addEventListener('click', e => { if (e.target === overlay) removeOverlay(overlay); });
const onKey = e => { if (e.key === 'Escape') { removeOverlay(overlay); document.removeEventListener('keydown', onKey); } };
document.addEventListener('keydown', onKey);
}
function showColumnMenu(colId, x, y) {
closeAllMenus();
const col = getColumnById(colId); if (!col) return;
const menu = document.createElement('div');
menu.className = 'dropdown-menu';
menu.style.left = x + 'px'; menu.style.top = y + 'px';
const wipRow = document.createElement('div');
wipRow.className = 'wip-input-row';
wipRow.innerHTML = `WIP Limit: <input type="number" min="0" max="99" value="${col.wipLimit || ''}" placeholder="None">`;
const wipIn = wipRow.querySelector('input');
const applyWip = () => {
const v = parseInt(wipIn.value, 10);
col.wipLimit = (isNaN(v) || v <= 0) ? null : v;
saveModel(); renderAll(); if (menu.parentNode) menu.remove();
};
wipIn.addEventListener('keydown', e => { if (e.key === 'Enter') applyWip(); });
wipIn.addEventListener('blur', () => setTimeout(applyWip, 200));
menu.appendChild(wipRow);
const rename = document.createElement('div'); rename.className = 'dropdown-item';
rename.textContent = 'Rename Column';
rename.addEventListener('click', () => {
menu.remove();
const titleSpan = document.querySelector(`.column-title[data-column-id="${colId}"]`);
if (titleSpan) startInlineEdit(titleSpan, { title: col.title }, colId);
});
menu.appendChild(rename);
const sep = document.createElement('div'); sep.className = 'dropdown-separator';
menu.appendChild(sep);
const delItem = document.createElement('div'); delItem.className = 'dropdown-item danger';
delItem.textContent = 'Delete Column';
delItem.addEventListener('click', () => { menu.remove(); deleteColumn(colId); });
menu.appendChild(delItem);
document.body.appendChild(menu);
setTimeout(() => { wipIn.focus(); wipIn.select(); }, 50);
// Reposition if needed
const rect = menu.getBoundingClientRect();
if (rect.right > window.innerWidth) menu.style.left = (x - rect.width) + 'px';
if (rect.bottom > window.innerHeight) menu.style.top = (y - rect.height) + 'px';
}
function makeOverlay() {
const o = document.createElement('div'); o.className = 'modal-overlay'; return o;
}
function removeOverlay(o) { if (o && o.parentNode) o.remove(); }
function closeAllMenus() { document.querySelectorAll('.dropdown-menu').forEach(m => m.remove()); }
/* ============================================
SECTION 8: TOAST NOTIFICATIONS
============================================ */
function showToast(message, onUndo) {
const container = $('#toast-container');
const toast = document.createElement('div'); toast.className = 'toast';
const msg = document.createElement('span'); msg.textContent = message;
toast.appendChild(msg);
if (onUndo) {
const btn = document.createElement('button');
btn.className = 'undo-btn'; btn.textContent = 'UNDO';
btn.addEventListener('click', () => { onUndo(); toast.remove(); });
toast.appendChild(btn);
}
container.appendChild(toast);
setTimeout(() => {
if (toast.parentNode) {
toast.style.transition = 'opacity 300ms'; toast.style.opacity = '0';
setTimeout(() => toast.remove(), 300);
}
}, CONFIG.TOAST_DURATION);
}
/* ============================================
SECTION 9: CARD DRAG & DROP (Pointer Events)
============================================ */
let cardDrag = null;
function startCardDrag(cardId, columnId, cardEl, e) {
e.preventDefault();
const rect = cardEl.getBoundingClientRect();
// Create floating card that follows cursor
const floater = cardEl.cloneNode(true);
floater.className = 'card floating-card';
floater.style.width = rect.width + 'px';
floater.style.left = rect.left + 'px';
floater.style.top = rect.top + 'px';
floater.style.transform = `rotate(${CONFIG.DRAG_TILT_DEG}deg) scale(${CONFIG.DRAG_SCALE})`;
document.body.appendChild(floater);
// Hide original card element
cardEl.style.visibility = 'hidden';
// Create ghost placeholder at original position
const ghost = document.createElement('div');
ghost.className = 'ghost-placeholder';
ghost.style.height = rect.height + 'px';
cardEl.parentNode.insertBefore(ghost, cardEl);
// Create drop indicator (the blue line we move)
const indicator = document.createElement('div');
indicator.className = 'drop-indicator';
indicator.style.display = 'none';
cardDrag = {
cardId,
sourceColumnId: columnId,
floater,
ghost,
indicator,
originalCardEl: cardEl,
offsetX: e.clientX - rect.left,
offsetY: e.clientY - rect.top,
targetColumnId: columnId,
targetBeforeCardId: null, // null = append at end
};
document.addEventListener('pointermove', onCardDragMove, { passive: false });
document.addEventListener('pointerup', onCardDragEnd);
document.addEventListener('keydown', onCardDragKey);
}
function onCardDragMove(e) {
if (!cardDrag) return;
e.preventDefault();
// Move floater
cardDrag.floater.style.left = (e.clientX - cardDrag.offsetX) + 'px';
cardDrag.floater.style.top = (e.clientY - cardDrag.offsetY) + 'px';
// Auto-scroll
performAutoScroll(e.clientX, e.clientY);
// Find drop target: which column and which card to drop before
const target = computeDropTarget(e.clientX, e.clientY);
if (!target) return;
cardDrag.targetColumnId = target.columnId;
cardDrag.targetBeforeCardId = target.beforeCardId;
// Position the drop indicator
positionDropIndicator(target);
}
function positionDropIndicator(target) {
const { indicator, originalCardEl } = cardDrag;
const { columnId, beforeCardId } = target;
// Find the target column's cards area
const cardsArea = document.querySelector(`.column-cards[data-column-id="${columnId}"]`);
if (!cardsArea) { indicator.style.display = 'none'; return; }
// Remove indicator from wherever it was
if (indicator.parentNode) indicator.parentNode.removeChild(indicator);
// Find the card element we're dropping before
let refEl = null;
if (beforeCardId) {
refEl = cardsArea.querySelector(`.card[data-card-id="${beforeCardId}"]`);
}
if (refEl) {
const rect = refEl.getBoundingClientRect();
const areaRect = cardsArea.getBoundingClientRect();
const topOffset = rect.top - areaRect.top + cardsArea.scrollTop;
indicator.style.display = 'block';
indicator.style.position = 'absolute';
indicator.style.top = topOffset + 'px';
indicator.style.left = '8px';
indicator.style.right = '8px';
cardsArea.appendChild(indicator);
} else {
// Append at end - position below last card
const allCards = cardsArea.querySelectorAll('.card');
if (allCards.length > 0) {
const lastCard = allCards[allCards.length - 1];
const rect = lastCard.getBoundingClientRect();
const areaRect = cardsArea.getBoundingClientRect();
const topOffset = (rect.bottom - areaRect.top) + cardsArea.scrollTop + 4;
indicator.style.display = 'block';
indicator.style.position = 'absolute';
indicator.style.top = topOffset + 'px';
indicator.style.left = '8px';
indicator.style.right = '8px';
cardsArea.appendChild(indicator);
} else {
// Empty column
indicator.style.display = 'block';
indicator.style.position = 'absolute';
indicator.style.top = '40px';
indicator.style.left = '8px';
indicator.style.right = '8px';
cardsArea.appendChild(indicator);
}
}
}
function computeDropTarget(x, y) {
// Query all column cards areas
const areas = document.querySelectorAll('.column-cards');
let bestTarget = null;
let bestDist = Infinity;
for (const area of areas) {
const colId = area.dataset.columnId;
const areaRect = area.getBoundingClientRect();
// Check if x is within this column horizontally (with some margin)
if (x < areaRect.left - 20 || x > areaRect.right + 20) continue;
const col = getColumnById(colId);
if (!col) continue;
// If column is empty, any y within the area means drop here
if (col.cards.length === 0) {
if (!bestTarget || Math.abs(y - areaRect.top - areaRect.height / 2) < bestDist) {
bestTarget = { columnId: colId, beforeCardId: null };
bestDist = 0;
}
continue;
}
// Find the card whose center is closest to y
// Skip the card being dragged (it still exists in model but shouldn't count)
for (let i = 0; i < col.cards.length; i++) {
const c = col.cards[i];
if (cardDrag && c.id === cardDrag.cardId) continue;
const cardEl = area.querySelector(`.card[data-card-id="${c.id}"]`);
if (!cardEl) continue; // card might be hidden by filter
const cardRect = cardEl.getBoundingClientRect();
const cardCenterY = cardRect.top + cardRect.height / 2;
const dist = Math.abs(y - cardCenterY);
if (dist < bestDist) {
bestDist = dist;
// Drop before this card if above center, after if below
// Find the actual next non-dragged card for "after" position
let nextAfterIdx = -1;
if (y >= cardCenterY) {
for (let j = i + 1; j < col.cards.length; j++) {
if (cardDrag && col.cards[j].id === cardDrag.cardId) continue;
nextAfterIdx = j;
break;
}
}
const beforeCardId = (y < cardCenterY) ? c.id :
(nextAfterIdx >= 0 ? col.cards[nextAfterIdx].id : null);
bestTarget = { columnId: colId, beforeCardId };
}
}
}
return bestTarget;
}
function onCardDragEnd(e) {
if (!cardDrag) return;
document.removeEventListener('pointermove', onCardDragMove);
document.removeEventListener('pointerup', onCardDragEnd);
document.removeEventListener('keydown', onCardDragKey);
const cancelled = cardDrag.cancelled;
// Clean up floating elements
if (cardDrag.floater.parentNode) cardDrag.floater.remove();
if (cardDrag.ghost.parentNode) cardDrag.ghost.remove();
if (cardDrag.indicator.parentNode) cardDrag.indicator.remove();
// Restore original card visibility
if (cardDrag.originalCardEl) {
cardDrag.originalCardEl.style.visibility = '';
}
if (!cancelled) {
// Commit the move to the model
saveUndoState('moveCard');
const { cardId, sourceColumnId, targetColumnId, targetBeforeCardId } = cardDrag;
// Find the card in the model
const sourceCol = getColumnById(sourceColumnId);
let cardObj = null;
let sourceIdx = -1;
if (sourceCol) {
sourceIdx = sourceCol.cards.findIndex(c => c.id === cardId);
if (sourceIdx >= 0) {
cardObj = sourceCol.cards.splice(sourceIdx, 1)[0];
}
}
if (cardObj) {
const targetCol = getColumnById(targetColumnId);
if (targetCol) {
if (targetBeforeCardId) {
// Insert before the target card
const insertIdx = targetCol.cards.findIndex(c => c.id === targetBeforeCardId);
if (insertIdx >= 0) {
targetCol.cards.splice(insertIdx, 0, cardObj);
} else {
targetCol.cards.push(cardObj);
}
} else {
// Append at end
targetCol.cards.push(cardObj);
}
} else {
// Target column doesn't exist, put back
sourceCol.cards.splice(sourceIdx, 0, cardObj);
}
}
saveModel();
}
cardDrag = null;
renderAll();
}
function onCardDragKey(e) {
if (e.key === 'Escape' && cardDrag) {
cardDrag.cancelled = true;
}
}
/* ============================================
SECTION 10: COLUMN DRAG & DROP
============================================ */
let colDrag = null;
function startColumnDrag(colId, colEl, e) {
e.preventDefault();
const rect = colEl.getBoundingClientRect();
// Create floating column
const floater = colEl.cloneNode(true);
floater.className = 'column floating-card';
floater.style.width = rect.width + 'px';
floater.style.left = rect.left + 'px';
floater.style.top = rect.top + 'px';
floater.style.height = rect.height + 'px';
floater.style.transform = `rotate(${CONFIG.DRAG_TILT_DEG}deg) scale(${CONFIG.DRAG_SCALE})`;
floater.style.maxHeight = 'none';
floater.style.overflow = 'hidden';
document.body.appendChild(floater);
// Dim the original column
colEl.classList.add('dragging-column');
// Create indicator
const indicator = document.createElement('div');
indicator.className = 'column-drop-indicator';
indicator.style.display = 'none';
colDrag = {
columnId: colId,
sourceIndex: model.columnOrder.indexOf(colId),
floater,
indicator,
originalColEl: colEl,
offsetX: e.clientX - rect.left,
offsetY: e.clientY - rect.top,
};
document.addEventListener('pointermove', onColDragMove, { passive: false });
document.addEventListener('pointerup', onColDragEnd);
document.addEventListener('keydown', onColDragKey);
}
function onColDragMove(e) {
if (!colDrag) return;
e.preventDefault();
colDrag.floater.style.left = (e.clientX - colDrag.offsetX) + 'px';
colDrag.floater.style.top = (e.clientY - colDrag.offsetY) + 'px';
performAutoScroll(e.clientX, e.clientY);
// Find drop position
const board = $('#board');
const cols = board.querySelectorAll('.column:not(.dragging-column)');
let targetIndex = colDrag.sourceIndex;
for (let i = 0; i < cols.length; i++) {
const r = cols[i].getBoundingClientRect();
const cx = r.left + r.width / 2;
if (e.clientX < cx) { targetIndex = i; break; }
targetIndex = i + 1;
}
colDrag.targetIndex = targetIndex;
// Position indicator
if (colDrag.indicator.parentNode) colDrag.indicator.parentNode.removeChild(colDrag.indicator);
colDrag.indicator.style.display = 'block';
const children = Array.from(board.children);
if (targetIndex >= children.length) {
board.appendChild(colDrag.indicator);
} else {
board.insertBefore(colDrag.indicator, children[targetIndex]);
}
}
function onColDragEnd(e) {
if (!colDrag) return;
document.removeEventListener('pointermove', onColDragMove);
document.removeEventListener('pointerup', onColDragEnd);
document.removeEventListener('keydown', onColDragKey);
const cancelled = colDrag.cancelled;
if (colDrag.floater.parentNode) colDrag.floater.remove();
if (colDrag.indicator.parentNode) colDrag.indicator.remove();
if (colDrag.originalColEl) colDrag.originalColEl.classList.remove('dragging-column');
if (!cancelled && colDrag.targetIndex !== undefined) {
saveUndoState('moveColumn');
const colId = colDrag.columnId;
const srcIdx = model.columnOrder.indexOf(colId);
if (srcIdx >= 0) {
model.columnOrder.splice(srcIdx, 1);
const ti = Math.min(colDrag.targetIndex, model.columnOrder.length);
model.columnOrder.splice(ti, 0, colId);
}
saveModel();
}
colDrag = null;
renderAll();
}
function onColDragKey(e) {
if (e.key === 'Escape' && colDrag) colDrag.cancelled = true;
}
/* ============================================
SECTION 11: AUTO-SCROLL
============================================ */
let autoScrollRAF = null;
function performAutoScroll(x, y) {
if (autoScrollRAF) return;
autoScrollRAF = requestAnimationFrame(() => {
autoScrollRAF = null;
let keepGoing = false;
const margin = CONFIG.AUTO_SCROLL_MARGIN;
const speed = CONFIG.AUTO_SCROLL_SPEED;
// Horizontal scroll of board
const bc = $('#board-container');
if (x < margin) { bc.scrollLeft -= speed; keepGoing = true; }
else if (x > window.innerWidth - margin) { bc.scrollLeft += speed; keepGoing = true; }
// Vertical scroll of columns
if (y < margin) {
document.querySelectorAll('.column-cards').forEach(col => {
const r = col.getBoundingClientRect();
if (x >= r.left && x <= r.right && col.scrollTop > 0) {
col.scrollTop -= speed; keepGoing = true;
}
});
} else if (y > window.innerHeight - margin) {
document.querySelectorAll('.column-cards').forEach(col => {
const r = col.getBoundingClientRect();
if (x >= r.left && x <= r.right && col.scrollHeight - col.scrollTop > col.clientHeight) {
col.scrollTop += speed; keepGoing = true;
}
});
}
if (keepGoing) performAutoScroll(x, y);
});
}
/* ============================================
SECTION 12: EVENT LISTENERS & INITIALIZATION
============================================ */
function init() {
model = loadModel();
if (model.searchQuery) $('#search-input').value = model.searchQuery;
$('#add-column-btn').addEventListener('click', addColumn);
$('#search-input').addEventListener('input', e => {
model.searchQuery = e.target.value;
saveModel(); renderAll();
});
document.addEventListener('click', e => {
if (!e.target.closest('.dropdown-menu') && !e.target.closest('.column-header-actions')) {
closeAllMenus();
}
});
document.addEventListener('keydown', e => {
if ((e.ctrlKey || e.metaKey) && e.key === 'z') { e.preventDefault(); undo(); }
});
renderAll();
}
init();
// Expose model and functions for testing
if (typeof window !== 'undefined') {
window.__kanban = { model, getColumnById, findCardAndColumn, saveModel, deepClone, genId, renderAll };
}
</script>
</body>
</html>