From d14dc759c20ff5741fea08f8c1ce79da8e649cdb Mon Sep 17 00:00:00 2001 From: Adilet Date: Fri, 6 Nov 2026 11:29:45 +0000 Subject: [PATCH] Convert Schedule to weekly calendar view --- script.js | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/script.js b/script.js index 6fcbcf5..235c812 100644 --- a/script.js +++ b/script.js @@ -173,23 +173,38 @@ function renderBoard(key) { `).join(""); } -function renderSchedule() { - const placeholder = $1("#schedule-placeholder"); +function renderSchedule(){ + const placeholder = $1('#schedule-placeholder'); if (!placeholder) return; if (!state.gdplan.length) { placeholder.innerHTML = '
Нет запланированных встреч
'; return; } - const items = state.gdplan.slice().sort((a, b) => - (a.due || "9999-99-99").localeCompare(b.due || "9999-99-99") || - (a.time || "99:99").localeCompare(b.time || "99:99") - ); - placeholder.innerHTML = items.map(t => ` -
- ${escapeHtml(fmtDateShort(t.due))} - ${escapeHtml(t.time || "—")} - ${escapeHtml(t.text)} -
`).join(""); + const dayOrder = [1,2,3,4,5,6,0]; // Monday..Sunday (JS getDay:0=Sun) + const dayNames = {1:'Пн',2:'Вт',3:'Среда',4:'Чт',5:'Пт',6:'Сб',0:'Вс'}; + const tasksByDay = {0:[],1:[],2:[],3:[],4:[],5:[],6:[]}; + state.gdplan.forEach(t => { + if (t.due) { + const d = new Date(t.due + 'T00:00:00'); + const wd = d.getDay(); + tasksByDay[wd].push(t); + } + }); + let html = ''; + dayOrder.forEach(d => { + const tasks = tasksByDay[d]; + const dayName = dayNames[d]; + html += `
+

${dayName}

`; + if (!tasks || tasks.length === 0) { + html += '
Нет задач
'; + } else { + const sorted = tasks.slice().sort((a,b)=>(a.time||'99:99').localeCompare(b.time||'99:99')); + html += sorted.map(t=>`
${escapeHtml(t.time||'—')} ${escapeHtml(t.text)}
`).join(''); + } + html += '
'; + }); + placeholder.innerHTML = html; } function renderNews() { const list = document.getElementById("list-news");