- 달력 표시에 일반근무 글자 숨기기(hideRegular). 앱·웹 달력 칸과 위젯 및 근무표 그림에서만 빼고 오늘 카드·날짜 상세·기본 달력 반영·구독은 그대로 - 달력 연동 안내 페이지(/calendar/guide): 구독 주소 · 안드로이드 앱 기본 달력 반영 · 구글 · 삼성 · 아이폰 · 아웃룩 · 파일 · 문제 해결. 글은 관리자에서 고침(guide_text.py 기본값) - 게시판(/calendar/board, board.py): 게시판 종류와 읽기·쓰기·댓글 권한을 관리자에서 만들고 고침, 글·댓글 쓰기·고치기·지우기, 운영진 숨김·고정·되살리기, 하루 한도 - 관리자: 설정 칸에 화면 구분(page)과 숫자·색·긴 글 종류. 색·메뉴·탭 제목·처음 기본값(웹)·게시판 한도 - 홈페이지 위쪽 메뉴 줄, 달력 연동·공유 창과 앱 메뉴에서 안내 페이지로 가는 링크 - 검사: 서버 103개(게시판 9개 새로), 앱 단위 54개, 위젯 기기 검사에 숨기기 확인. 로고 가져오기 시험의 같은 초 기록 순서 흔들림 고침
81 lines
4.2 KiB
JavaScript
81 lines
4.2 KiB
JavaScript
'use strict';
|
|
/* 달력 연동 안내. 글은 관리자 페이지 '연동 안내'에서 고친 홈페이지 설정(api/site)을 그대로 그린다.
|
|
* 모든 글은 textContent로 넣어 HTML로 해석되지 않는다. 꾸밈은 **굵게**와 https:// 링크 및 번호·점 목록만 받는다. */
|
|
(function () {
|
|
const $ = id => document.getElementById(id);
|
|
function el(tag, text, className) {
|
|
const node = document.createElement(tag);
|
|
if (text !== undefined && text !== null) node.textContent = String(text);
|
|
if (className) node.className = className;
|
|
return node;
|
|
}
|
|
// 한 줄 안의 **굵게**와 https 주소만 꾸민다. 주소 끝의 마침표와 괄호는 링크에서 뺀다.
|
|
function richLine(parent, text) {
|
|
for (const part of String(text).split(/(\*\*[^*]+\*\*|https:\/\/[^\s<>"']+)/g)) {
|
|
if (!part) continue;
|
|
if (/^\*\*[^*]+\*\*$/.test(part)) parent.append(el('strong', part.slice(2, -2)));
|
|
else if (/^https:\/\//.test(part)) {
|
|
const tail = (/[.,)\]]+$/.exec(part) || [''])[0];
|
|
const url = tail ? part.slice(0, -tail.length) : part;
|
|
const link = el('a', url.replace(/^https:\/\//, ''));
|
|
link.href = url; link.target = '_blank'; link.rel = 'noopener noreferrer';
|
|
parent.append(link);
|
|
if (tail) parent.append(tail);
|
|
} else parent.append(part);
|
|
}
|
|
}
|
|
function renderText(container, text) {
|
|
container.replaceChildren();
|
|
for (const block of String(text || '').replace(/\r\n/g, '\n').split(/\n\s*\n/)) {
|
|
let list = null, kind = null;
|
|
for (const raw of block.split('\n')) {
|
|
const line = raw.trim();
|
|
if (!line) continue;
|
|
const number = /^\d+\.\s+/.exec(line), dash = /^-\s+/.exec(line);
|
|
const want = number ? 'ol' : dash ? 'ul' : null;
|
|
if (want) {
|
|
if (kind !== want) { list = el(want); container.append(list); kind = want; }
|
|
const item = el('li'); richLine(item, line.slice((number || dash)[0].length)); list.append(item);
|
|
} else {
|
|
kind = null; list = null;
|
|
const paragraph = el('p'); richLine(paragraph, line); container.append(paragraph);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function render(settings) {
|
|
if (!settings) return;
|
|
const sections = $('guide-sections'), toc = $('guide-toc');
|
|
sections.replaceChildren(); toc.replaceChildren();
|
|
if (settings.guideOn === false) {
|
|
$('guide-title').textContent = '달력 연동 안내';
|
|
$('guide-intro').replaceChildren(el('p', '연동 안내를 준비하고 있습니다. 조금 뒤에 다시 들러 주세요.'));
|
|
return;
|
|
}
|
|
$('guide-title').textContent = settings.guideTitle || '휴대폰 달력과 연동하기';
|
|
renderText($('guide-intro'), settings.guideIntro);
|
|
// 순서는 서버 설정 목록의 순서를 따른다. 관리자에서 끈 안내는 빼고 그린다.
|
|
const keys = Object.keys(settings).map(key => /^guide_(.+)_title$/.exec(key)).filter(Boolean).map(match => match[1]);
|
|
let number = 0;
|
|
for (const key of keys) {
|
|
if (settings['guide_' + key + '_on'] === false) continue;
|
|
number += 1;
|
|
const id = 'guide-' + key;
|
|
const chip = el('a', settings['guide_' + key + '_title']); chip.href = '#' + id; toc.append(chip);
|
|
const card = el('section', null, 'guide-section' + (key === 'start' ? ' first' : '')); card.id = id;
|
|
const head = el('h2'); head.append(el('span', number, 'step'), settings['guide_' + key + '_title']);
|
|
const body = el('div', null, 'rich'); renderText(body, settings['guide_' + key + '_body']);
|
|
card.append(head, body);
|
|
sections.append(card);
|
|
}
|
|
if (!number) sections.append(el('p', '지금 보여 줄 안내가 없습니다.', 'small'));
|
|
if (location.hash && document.getElementById(location.hash.slice(1))) document.getElementById(location.hash.slice(1)).scrollIntoView();
|
|
}
|
|
render(window.dutySiteSettings);
|
|
document.addEventListener('duty-site', event => render(event.detail));
|
|
// 설정을 끝내 받지 못하면 안내가 비어 보이지 않게 알린다.
|
|
setTimeout(() => {
|
|
if (!window.dutySiteSettings) $('guide-sections').replaceChildren(el('p', '안내를 불러오지 못했습니다. 인터넷 연결을 확인하고 새로고침해 주세요.', 'small'));
|
|
}, 8000);
|
|
})();
|