당직근무 0.16.1 (웹 2026-12-01.2): 날짜가 바뀌면 지난달 달력에 머물지 않고 이번 달로 넘어감

This commit is contained in:
블리어 committed 2026-12-01 07:43:29 +00:00
1 parent e678b8520b
commit 3060246e9f
18 files changed
+187 -36

No files matched your search

+6
View File
@@ -144,6 +144,12 @@ $('event-delete').onclick=async()=>{if(await confirmAction('이 일정을 삭제
$('add').onclick=()=>openEvent();$('day-add').onclick=()=>openEvent();
function moveMonth(step){const d=dayDate(month+'-01');d.setUTCMonth(d.getUTCMonth()+step);month=dateKey(d).slice(0,7);render();}
$('prev').onclick=()=>moveMonth(-1);$('next').onclick=()=>moveMonth(1);$('today').onclick=()=>{selected=todayKey();month=selected.slice(0,7);render();};
// 열어 둔 채 날짜가 바뀌면 보던 달과 고른 날이 그 전 오늘이었을 때 새 오늘로 옮긴다(2026-12-01: 12월 1일인데 11월 달력이 보이던 문제).
let shownDay=selected;
function followToday(){const today=todayKey();if(today===shownDay)return false;if(month===shownDay.slice(0,7))month=today.slice(0,7);if(selected===shownDay)selected=today;shownDay=today;return true;}
setInterval(()=>{if(followToday())render();},30000);
document.addEventListener('visibilitychange',()=>{if(!document.hidden&&followToday())render();});
window.addEventListener('focus',()=>{if(followToday())render();});
function drawRotation(pattern){$('rotation-count').value=pattern.length;$('rotation-days').replaceChildren();pattern.forEach((shift,index)=>{const label=text('label',(index+1)+'일째');const select=document.createElement('select');for(const [value,name] of shiftChoices()){const option=text('option',name);option.value=value;select.append(option);}select.value=shift;label.append(select);$('rotation-days').append(label);});}
$('rotation').onclick=()=>{const r=rotation()??{anchor:todayKey(),pattern:['DUTY','OFF']};$('rotation-anchor').value=r.anchor;$('rotation-work-week').value=String(r.workWeek||6);resetPatternMode('rotation');drawRotation(r.pattern);$('rotation-error').textContent='';$('rotation-dialog').showModal();};
$('rotation-form').onsubmit=event=>{event.preventDefault();const pattern=[...$('rotation-days').querySelectorAll('select')].map(node=>node.value);if(pattern.length!==Number($('rotation-count').value)){$('rotation-error').textContent='반복 일수를 확인해 주세요.';return;}// 근무 순서 이름은 따로 된 창에서 넣는다. 순서 길이가 그대로면 넣어 둔 이름을 남기고 바뀌면 비운다.