1
0
Files
coconut-leaf/src/static/js/page/calendar.js

199 lines
6.0 KiB
JavaScript
Raw Normal View History

2021-02-03 20:50:02 +08:00
// 2 list which will store sharing and shared collection's display mode.
// key is uuid, value is bool
var ccn_calendar_owned_displayCache = [];
2021-02-03 20:50:02 +08:00
var ccn_calendar_shared_displayCache = [];
2021-02-07 21:12:56 +08:00
// modal editing object.
// undefined mean add
// not undefined mean update(a copy of calendar event)
2021-02-07 21:12:56 +08:00
var ccn_calendar_eventModal_editing = undefined;
var ccn_calendar_eventModal_collectionCache = [];
2021-02-07 21:12:56 +08:00
var ccn_calendar_calendar_listCache = [];
var ccn_calendar_calendar_displayCache = [];
2021-01-19 22:20:11 +08:00
$(document).ready(function() {
ccn_pages_currentPage = ccn_pages_enumPages.calendar;
2021-01-24 14:38:08 +08:00
// template process
ccn_template_Load();
// nav process
2021-01-30 17:30:28 +08:00
ccn_headerNav_Insert();
ccn_headerNav_BindEvents();
ccn_headerNav_LoggedRefresh();
2021-01-19 22:20:11 +08:00
2021-01-30 17:30:28 +08:00
// messagebox process
ccn_messagebox_Insert();
ccn_messagebox_BindEvent();
2021-01-19 22:20:11 +08:00
// process calendar it self
2021-02-07 21:12:56 +08:00
ccn_calendar_calendar_LoadCalendarBody();
2021-01-19 22:20:11 +08:00
// init datetimepicker
ccn_datetimepicker_Init();
2021-01-23 18:37:12 +08:00
// bind tab control switcher and set current tab
$("#tabcontrol-tab-1-1").click(function(){
ccn_tabcontrol_SwitchTab(1, 1);
});
$("#tabcontrol-tab-1-2").click(function(){
ccn_tabcontrol_SwitchTab(1, 2);
});
$("#tabcontrol-tab-1-3").click(function(){
ccn_tabcontrol_SwitchTab(1, 3);
});
ccn_tabcontrol_SwitchTab(1, 1);
2021-01-19 22:20:11 +08:00
// apply i18n
2021-02-03 16:08:40 +08:00
ccn_i18n_LoadLanguage();
2021-01-19 22:20:11 +08:00
ccn_i18n_ApplyLanguage();
2021-02-04 16:32:42 +08:00
2021-02-05 17:07:20 +08:00
//refresh once
ccn_calendar_collection_Refresh();
2021-02-05 17:07:20 +08:00
2021-02-04 16:32:42 +08:00
// bind event
$('#ccn-calendar-collection-btnRefresh').click(ccn_calendar_collection_Refresh);
2021-02-07 21:12:56 +08:00
$('#ccn-calendar-calendar-btnJump').click(ccn_calendar_calendar_Refresh);
$('#ccn-calendar-calendar-btnToday').click(ccn_calendar_calendar_Today);
$('#ccn-calendar-calendar-btnAdd').click(ccn_calendar_calendar_Add);
2021-01-19 22:20:11 +08:00
});
2021-02-04 16:32:42 +08:00
// ================== calendar
2021-02-07 21:12:56 +08:00
function ccn_calendar_calendar_LoadCalendarBody() {
$('#ccn-calendar-calendarBody').append(ccn_template_calendarItem.render());
}
function ccn_calendar_calendar_Refresh() {
2021-02-09 17:10:05 +08:00
gottenDateTime = ccn_datetimepicker_Get(1, false);
2021-02-07 21:12:56 +08:00
gottenYear = gottenDateTime.getFullYear();
gottenMonth = gottenDateTime.getMonth() + 1;
}
function ccn_calendar_calendar_Render() {
}
function ccn_calendar_calendar_AnalyseEvent() {
}
function ccn_calendar_calendar_Today() {
var nowtime = new Date();
2021-02-09 17:10:05 +08:00
ccn_datetimepicker_Set(1, nowtime, false);
2021-02-07 21:12:56 +08:00
ccn_calendar_calendar_Refresh();
}
function ccn_calendar_calendar_Add() {
window.location.href = '/web/eventAdd';
2021-02-07 21:12:56 +08:00
}
function ccn_calendar_calendar_ItemUpdate() {
var uuid = $(this).attr("uuid");
window.location.href = '/web/eventUpdate/' + uuid;
2021-02-03 16:08:40 +08:00
}
// ============================= collection
2021-02-03 20:50:02 +08:00
function ccn_calendar_collection_Refresh() {
ccn_calendar_owned_displayCache = new Array();
2021-02-03 20:50:02 +08:00
ccn_calendar_shared_displayCache = new Array();
2021-02-03 16:08:40 +08:00
// render shared
2021-02-03 20:50:02 +08:00
var result = ccn_api_collection_getShared();
var listDOM = $('#ccn-calendar-sharedList');
listDOM.empty();
2021-02-03 20:50:02 +08:00
var renderdata = {
uuid: undefined,
name: undefined,
username: undefined
}
if (typeof(result) != 'undefined') {
for(var index in result) {
var item = result[index];
renderdata.uuid = item[0];
renderdata.name = item[1];
renderdata.username = item[2];
listDOM.append(ccn_template_displaySharedItem.render(renderdata));
// change display
var uuid = renderdata.uuid;
ccn_calendar_shared_ChangeDisplayMode(uuid, true);
2021-02-03 20:50:02 +08:00
// push into display list
ccn_calendar_shared_displayCache[uuid] = true;
// bind event
$('#ccn-displaySharedItem-btnHide-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
$('#ccn-displaySharedItem-btnShow-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
}
2021-02-03 20:50:02 +08:00
}
ccn_i18n_ApplyLanguage2Content(listDOM);
// render owned
result = ccn_api_collection_getFullOwn();
listDOM = $('#ccn-calendar-ownedList');
listDOM.empty();
renderdata = {
uuid: undefined,
name: undefined
2021-02-03 20:50:02 +08:00
}
if (typeof(result) != 'undefined') {
for(var index in result) {
var item = result[index];
renderdata.uuid = item[0];
renderdata.name = item[1];
2021-02-04 16:32:42 +08:00
// render
listDOM.append(ccn_template_displayOwnedItem.render(renderdata));
2021-02-03 20:50:02 +08:00
// set mode
var uuid = renderdata.uuid;
ccn_calendar_owned_ChangeDisplayMode(uuid, true);
2021-02-04 16:32:42 +08:00
// push into display list
ccn_calendar_owned_displayCache[uuid] = true;
2021-02-03 20:50:02 +08:00
// bind event
$('#ccn-displayOwnedItem-btnHide-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
$('#ccn-displayOwnedItem-btnShow-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
2021-02-04 16:32:42 +08:00
}
}
2021-02-03 20:50:02 +08:00
}
2021-02-05 17:07:20 +08:00
function ccn_calendar_owned_ItemSwitchDisplay() {
2021-02-04 16:32:42 +08:00
var uuid = $(this).attr("uuid");
ccn_calendar_owned_displayCache[uuid] = !(ccn_calendar_owned_displayCache[uuid]);
ccn_calendar_owned_ChangeDisplayMode(uuid, ccn_calendar_owned_displayCache[uuid]);
2021-02-03 20:50:02 +08:00
}
function ccn_calendar_shared_ItemSwitchDisplay() {
2021-02-04 16:32:42 +08:00
var uuid = $(this).attr("uuid");
ccn_calendar_shared_displayCache[uuid] = !(ccn_calendar_shared_displayCache[uuid]);
ccn_calendar_shared_ChangeDisplayMode(uuid, ccn_calendar_shared_displayCache[uuid]);
2021-02-03 20:50:02 +08:00
}
function ccn_calendar_shared_ChangeDisplayMode(uuid, isShow) {
if (isShow) {
$('#ccn-displaySharedItem-btnHide-' + uuid).show();
$('#ccn-displaySharedItem-btnShow-' + uuid).hide();
} else {
$('#ccn-displaySharedItem-btnHide-' + uuid).hide();
$('#ccn-displaySharedItem-btnShow-' + uuid).show();
2021-02-04 16:32:42 +08:00
}
2021-02-03 20:50:02 +08:00
}
function ccn_calendar_owned_ChangeDisplayMode(uuid, isShow) {
if (isShow) {
$('#ccn-displayOwnedItem-btnHide-' + uuid).show();
$('#ccn-displayOwnedItem-btnShow-' + uuid).hide();
} else {
$('#ccn-displayOwnedItem-btnHide-' + uuid).hide();
$('#ccn-displayOwnedItem-btnShow-' + uuid).show();
2021-02-04 16:32:42 +08:00
}
2021-02-03 20:50:02 +08:00
}