function formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } function renderScheduleListCustom(items) { var side_list_show = 5; var $list = $('#sc-list').html(''); var n_dates = Object.keys(items).length; var date_count = 0; var hide = false; $.each(items, function(key, ele) { var dates = key.split('~'); var sdate = dates[0]; var edate = dates[1]; var sdt = sdate.split('-'); var edt = edate.split('-'); var $item = $('
'); if(hide) { $item.addClass('hidden-item'); } date_count += 1; $item.append('
'+sdt[0] + '.' + sdt[1] + '
'+sdt[2]+'
'); var addcls = ''; if(edate && sdate != edate) { $item.append('
~
'); $item.append('
'+edt[0] + '.' + edt[1] + '
'+edt[2]+'
'); addcls = ' has-duration'; } var $content = $('
'); $.each(ele, function(didx, dlist) { $.each(dlist, function(idx, item) { console.log(item); var label = item.label; var ca_name = ''; $content.append('
' + item.type + ' (' + item.si_startdate + ')
'); $.each(item.class_list, function(cidx, cls) { $content.append('
' + cls.no + '교시 '+ cls.stime + (cls.etime ? '~'+cls.etime : '') + ' ('+ cls.cname+')
'); }); }); }); var show_more = false; if(date_count == side_list_show && n_dates > side_list_show) { hide = true; show_more = true; } if(show_more) { $item.addClass('before-more'); } $item.append($content); $list.append($item); if(show_more) { $list.append('
+ 더보기
'); } }); if(items.length == 0) { $list.append('
등록된 일정이 없습니다.
'); } } function renderScheduleList(items) { var side_list_show = 5; var $list = $('#sc-list').html(''); var n_dates = Object.keys(items).length; var date_count = 0; var hide = false; $.each(items, function(key, ele) { var dates = key.split('~'); var sdate = dates[0]; var edate = dates[1]; var sdt = sdate.split('-'); var edt = edate.split('-'); var $item = $('
'); if(hide) { $item.addClass('hidden-item'); } date_count += 1; $item.append('
'+sdt[0] + '.' + sdt[1] + '
'+sdt[2]+'
'); var addcls = ''; if(edate && sdate != edate) { $item.append('
~
'); $item.append('
'+edt[0] + '.' + edt[1] + '
'+edt[2]+'
'); addcls = ' has-duration'; } var $content = $('
'); if(ele.mode == 'auto') { $.each(ele, function(idx, item) { //var label = (item.type1 ? item.type1 : (item.type2 ? item.type2 : item.type3)); //var ca_name = (item.ca_name ? ' ('+item.ca_name+')' : ''); var label = item.label; var ca_name = ''; $content.append('
' + label + ca_name + '
'); }); } else { // custom mode $.each(ele, function(idx, item) { var label = item.label; var ca_name = ''; $content.append('
' + label + ca_name + '
'); $.each(item.class_list, function(cidx, cls) { $content.append('
' + cls.no + '교시 '+ cls.stime + (cls.etime ? '~'+cls.etime : '') + ' ('+ cls.cname+')
'); }); }); } var show_more = false; if(date_count == side_list_show && n_dates > side_list_show) { hide = true; show_more = true; } if(show_more) { $item.addClass('before-more'); } $item.append($content); $list.append($item); if(show_more) { $list.append('
+ 더보기
'); } }); if(items.length == 0) { $list.append('
등록된 일정이 없습니다.
'); } } function updateScheduleList(start) { $.ajax({ url: 'https://boatcraft.co.kr/skin/board/1st_map/schedule/feed-list.php', data: { start: formatDate(Date.parse(start)), sname: '서울서초', ename: '대한민국특수임무유공자회(서울반포)', bo_table:'testsite_info', wr_id:'42' }, method: 'get', dataType: 'json', aysnc: false, success: function(json) { if(json.code !== 1) { alert(json.message); return; } if(typeof json.mode !== 'undefined' && json.mode == 'custom') { renderScheduleListCustom(json.list); } else { renderScheduleList(json.list); } }, error: function(jqXHR, textStatus, errorThrown) { alert('서버와의 통신 중 에러가 발생했습니다.'); } }); } document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', initialDate: '2024-04-28', locale: 'ko', height: 'auto', eventDidMount: function(info) { var tooltip = new Tooltip(info.el, { title: info.event.extendedProps.description, placement: 'top', trigger: 'hover', container: 'body' }); }, headerToolbar: { left: 'prev,next today', center: 'title', right: '', }, eventSources: 'https://boatcraft.co.kr/skin/board/1st_map/schedule/feed.php?bo_table=testsite_info&wr_id=42&sname=%EC%84%9C%EC%9A%B8%EC%84%9C%EC%B4%88&ename=%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD%ED%8A%B9%EC%88%98%EC%9E%84%EB%AC%B4%EC%9C%A0%EA%B3%B5%EC%9E%90%ED%9A%8C%28%EC%84%9C%EC%9A%B8%EB%B0%98%ED%8F%AC%29', }); calendar.render(); $('#calendar-prev').click(function() { calendar.prev(); $('#sc-list').html('Loading...'); var d = formatDate(calendar.getDate()); var ds = d.split('-'); $('#calendar-today').html(ds[0] + '년 ' + parseInt(ds[1]) + '월'); updateScheduleList(d); }); $('#calendar-next').click(function() { calendar.next(); $('#sc-list').html('Loading...'); var d = formatDate(calendar.getDate()); var ds = d.split('-'); $('#calendar-today').html(ds[0] + '년 ' + parseInt(ds[1]) + '월'); updateScheduleList(d); }); $('#calendar-today').click(function() { calendar.today(); $('#sc-list').html('Loading...'); var d = formatDate(calendar.getDate()); var ds = d.split('-'); $('#calendar-today').html(ds[0] + '년 ' + parseInt(ds[1]) + '월'); d = ds[0] + '-' + ds[1] + '-01'; updateScheduleList(d); }); updateScheduleList('2024-04-01'); }); $(function() { $('#tsi-admin a').click(function(evt) { var href = $(this).attr('href'); var new_win = window.open(href, 'win_sc', 'left=100,top=100,width=1000,height=800,scrollbars=0'); new_win.focus(); evt.preventDefault(); }); $(document).on('click', '.more-date', function(evt) { $('.more-date').remove(); $('#sc-list .before-more').removeClass('before-more'); $('#sc-list .hidden-item').show(); }); });