seperate 1 page into 3 pages for more fluent manage
This commit is contained in:
@@ -46,10 +46,10 @@ function ccn_admin_profile_ChangePassword() {
|
||||
|
||||
var result = ccn_api_common_changePassword(newpassword);
|
||||
if(result) {
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-success"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-success"));
|
||||
$('#ccn-admin-profile-inputPassword').val('');
|
||||
} else
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-update"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-update"));
|
||||
|
||||
}
|
||||
|
||||
@@ -80,10 +80,10 @@ function ccn_admin_userList_RenderItem(item, index, listDOM) {
|
||||
ccn_admin_userList_ChangeDisplayMode(uuid, false, item[1])
|
||||
|
||||
// bind event
|
||||
$("#ccn-admin-userItem-btnEdit-" + uuid).click(ccn_admin_userList_ItemEdit);
|
||||
$("#ccn-admin-userItem-btnDelete-" + uuid).click(ccn_admin_userList_ItemDelete);
|
||||
$("#ccn-admin-userItem-btnUpdate-" + uuid).click(ccn_admin_userList_ItemUpdate);
|
||||
$("#ccn-admin-userItem-btnCancelUpdate-" + uuid).click(ccn_admin_userList_ItemCancelUpdate);
|
||||
$("#ccn-userItem-btnEdit-" + uuid).click(ccn_admin_userList_ItemEdit);
|
||||
$("#ccn-userItem-btnDelete-" + uuid).click(ccn_admin_userList_ItemDelete);
|
||||
$("#ccn-userItem-btnUpdate-" + uuid).click(ccn_admin_userList_ItemUpdate);
|
||||
$("#ccn-userItem-btnCancelUpdate-" + uuid).click(ccn_admin_userList_ItemCancelUpdate);
|
||||
}
|
||||
|
||||
function ccn_admin_userList_RenderCacheList() {
|
||||
@@ -104,28 +104,28 @@ function ccn_admin_userList_RenderCacheList() {
|
||||
function ccn_admin_userList_ChangeDisplayMode(uuid, isEdit, isAdmin) {
|
||||
if (typeof(isAdmin) != 'undefined') {
|
||||
if (isAdmin)
|
||||
$("#ccn-admin-userItem-iconIsAdmin-" + uuid).show();
|
||||
$("#ccn-userItem-iconIsAdmin-" + uuid).show();
|
||||
else
|
||||
$("#ccn-admin-userItem-iconIsAdmin-" + uuid).hide();
|
||||
$("#ccn-userItem-iconIsAdmin-" + uuid).hide();
|
||||
}
|
||||
|
||||
if (typeof(isEdit) != 'undefined') {
|
||||
if (isEdit) {
|
||||
$("#ccn-admin-userItem-btnEdit-" + uuid).hide();
|
||||
$("#ccn-admin-userItem-btnDelete-" + uuid).hide();
|
||||
$("#ccn-admin-userItem-btnUpdate-" + uuid).show();
|
||||
$("#ccn-admin-userItem-btnCancelUpdate-" + uuid).show();
|
||||
$("#ccn-userItem-btnEdit-" + uuid).hide();
|
||||
$("#ccn-userItem-btnDelete-" + uuid).hide();
|
||||
$("#ccn-userItem-btnUpdate-" + uuid).show();
|
||||
$("#ccn-userItem-btnCancelUpdate-" + uuid).show();
|
||||
|
||||
$("#ccn-admin-userItem-boxPassword-" + uuid).show();
|
||||
$("#ccn-admin-userItem-boxIsAdmin-" + uuid).show();
|
||||
$("#ccn-userItem-boxPassword-" + uuid).show();
|
||||
$("#ccn-userItem-boxIsAdmin-" + uuid).show();
|
||||
} else {
|
||||
$("#ccn-admin-userItem-btnEdit-" + uuid).show();
|
||||
$("#ccn-admin-userItem-btnDelete-" + uuid).show();
|
||||
$("#ccn-admin-userItem-btnUpdate-" + uuid).hide();
|
||||
$("#ccn-admin-userItem-btnCancelUpdate-" + uuid).hide();
|
||||
$("#ccn-userItem-btnEdit-" + uuid).show();
|
||||
$("#ccn-userItem-btnDelete-" + uuid).show();
|
||||
$("#ccn-userItem-btnUpdate-" + uuid).hide();
|
||||
$("#ccn-userItem-btnCancelUpdate-" + uuid).hide();
|
||||
|
||||
$("#ccn-admin-userItem-boxPassword-" + uuid).hide();
|
||||
$("#ccn-admin-userItem-boxIsAdmin-" + uuid).hide();
|
||||
$("#ccn-userItem-boxPassword-" + uuid).hide();
|
||||
$("#ccn-userItem-boxIsAdmin-" + uuid).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ function ccn_admin_userList_Add() {
|
||||
|
||||
var result = ccn_api_admin_add(username);
|
||||
if (typeof(result) == 'undefined') {
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-add"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-add"));
|
||||
} else {
|
||||
// render
|
||||
var index = ccn_admin_userListCache.push(result) - 1;
|
||||
@@ -156,8 +156,8 @@ function ccn_admin_userList_ItemEdit() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
// copy isAdmin to checkbox and clean password box
|
||||
$('#ccn-admin-userItem-inputIsAdmin-' + uuid).prop("checked", ccn_admin_userListCache[uuid][1]);
|
||||
$('#ccn-admin-userItem-inputPassword-' + uuid).val('');
|
||||
$('#ccn-userItem-inputIsAdmin-' + uuid).prop("checked", ccn_admin_userListCache[uuid][1]);
|
||||
$('#ccn-userItem-inputPassword-' + uuid).val('');
|
||||
|
||||
// switch to edit mode
|
||||
ccn_admin_userList_ChangeDisplayMode(uuid, true, undefined);
|
||||
@@ -170,17 +170,17 @@ function ccn_admin_userList_ItemDelete() {
|
||||
|
||||
if(!result) {
|
||||
// fail
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-delete"));
|
||||
} else {
|
||||
// remove body
|
||||
$("#ccn-admin-userItem-" + uuid).remove();
|
||||
$("#ccn-userItem-" + uuid).remove();
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_admin_userList_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var newpassword = $('#ccn-admin-userItem-inputPassword-' + uuid).val();
|
||||
var isAdmin = $('#ccn-admin-userItem-inputIsAdmin-' + uuid).prop("checked");
|
||||
var newpassword = $('#ccn-userItem-inputPassword-' + uuid).val();
|
||||
var isAdmin = $('#ccn-userItem-inputIsAdmin-' + uuid).prop("checked");
|
||||
|
||||
var result = ccn_api_admin_update(
|
||||
ccn_admin_userListCache[uuid][0],
|
||||
@@ -189,7 +189,7 @@ function ccn_admin_userList_ItemUpdate() {
|
||||
|
||||
if (!result) {
|
||||
// fail
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-update"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-update"));
|
||||
} else {
|
||||
// safely update data
|
||||
ccn_admin_userListCache[uuid][1] = isAdmin
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
// 3 used cache list
|
||||
var ccn_calendar_owned_listCache = [];
|
||||
var ccn_calendar_sharing_listCache = [];
|
||||
var ccn_calendar_shared_listCache = [];
|
||||
|
||||
// current editing sharing collection
|
||||
var ccn_calendar_sharing_editingOwned = undefined; // the uuid of owned collection
|
||||
|
||||
// 2 list which will store sharing and shared collection's display mode.
|
||||
// key is uuid, value is bool
|
||||
var ccn_calendar_sharing_displayCache = [];
|
||||
var ccn_calendar_owned_displayCache = [];
|
||||
var ccn_calendar_shared_displayCache = [];
|
||||
|
||||
// modal editing object.
|
||||
// undefined mean add
|
||||
// not undefined mean update
|
||||
// not undefined mean update(a copy of calendar event)
|
||||
var ccn_calendar_eventModal_editing = undefined;
|
||||
var ccn_calendar_eventModal_collectionCache = [];
|
||||
var ccn_calendar_calendar_listCache = [];
|
||||
var ccn_calendar_calendar_displayCache = [];
|
||||
|
||||
@@ -36,6 +29,9 @@ $(document).ready(function() {
|
||||
// process calendar it self
|
||||
ccn_calendar_calendar_LoadCalendarBody();
|
||||
|
||||
// init datetimepicker
|
||||
ccn_datetimepicker_Init();
|
||||
|
||||
// bind tab control switcher and set current tab
|
||||
$("#tabcontrol-tab-1-1").click(function(){
|
||||
ccn_tabcontrol_SwitchTab(1, 1);
|
||||
@@ -48,116 +44,21 @@ $(document).ready(function() {
|
||||
});
|
||||
ccn_tabcontrol_SwitchTab(1, 1);
|
||||
|
||||
// init datetimepicker
|
||||
ccn_calendar_datetimepicker_Init();
|
||||
|
||||
// init span picker
|
||||
$('.spanpicker').attr('max', 100)
|
||||
.attr('min', 1)
|
||||
.attr('step', 1)
|
||||
.val(1);
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_LoadLanguage();
|
||||
ccn_i18n_ApplyLanguage();
|
||||
|
||||
//refresh once
|
||||
ccn_calendar_shared_Refresh();
|
||||
ccn_calendar_owned_Refresh();
|
||||
ccn_calendar_collection_Refresh();
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-shared-btnRefresh').click(ccn_calendar_shared_Refresh);
|
||||
$('#ccn-calendar-owned-btnAdd').click(ccn_calendar_owned_Add);
|
||||
$('#ccn-calendar-owned-btnRefresh').click(ccn_calendar_owned_Refresh);
|
||||
$('#ccn-calendar-sharing-btnAdd').click(ccn_calendar_sharing_Add);
|
||||
$('#ccn-calendar-sharing-btnRefresh').click(ccn_calendar_sharing_Refresh);
|
||||
$('#ccn-calendar-collection-btnRefresh').click(ccn_calendar_collection_Refresh);
|
||||
|
||||
$('#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);
|
||||
|
||||
$('#ccn-calendar-modalEvent-btnSubmit').click(ccn_calendar_calendar_ItemUpdate);
|
||||
$('#ccn-calendar-modalEvent-btnCancel').click(ccn_calendar_calendar_ItemCancel);
|
||||
$('#ccn-calendar-modalEvent-btnClose').click(ccn_calendar_calendar_ItemCancel);
|
||||
});
|
||||
|
||||
// ================== assist func
|
||||
|
||||
function ccn_calendar_datetimepicker_Init() {
|
||||
var nowtime = new Date();
|
||||
|
||||
$('.datetimepicker-year').attr('min', ccn_datetime_MIN_YEAR)
|
||||
.attr('max', ccn_datetime_MAX_YEAR)
|
||||
.attr('step', 1)
|
||||
.val(nowtime.getFullYear())
|
||||
.bind('propertychange', ccn_calendar_datetimepicker_Sync);
|
||||
|
||||
$('.datetimepicker-month').attr('min', 1)
|
||||
.attr('max', 12)
|
||||
.attr('step', 1)
|
||||
.val(nowtime.getMonth() + 1)
|
||||
.bind('propertychange', ccn_calendar_datetimepicker_Sync);
|
||||
|
||||
$('.datetimepicker-day').attr('min', 1)
|
||||
.attr('step', 1)
|
||||
.each(function(){
|
||||
ccn_calendar_datetimepicker_SyncEx($(this).attr("datetimepicker"));
|
||||
})
|
||||
.val(nowtime.getDate());
|
||||
|
||||
$('.datetimepicker-hour').attr('min', 0)
|
||||
.attr('max', 23)
|
||||
.attr('step', 1)
|
||||
.val(nowtime.getHours());
|
||||
|
||||
$('.datetimepicker-minute').attr('min', 0)
|
||||
.attr('max', 59)
|
||||
.attr('step', 1)
|
||||
.val(nowtime.getMinutes());
|
||||
}
|
||||
|
||||
function ccn_calendar_datetimepicker_Sync() {
|
||||
var pickerIndex = $(this).attr("datetimepicker");
|
||||
ccn_calendar_datetimepicker_SyncEx(pickerIndex);
|
||||
}
|
||||
|
||||
function ccn_calendar_datetimepicker_SyncEx(pickerIndex) {
|
||||
year = $('.datetimepicker-year[datetimepicker=' + pickerIndex + ']').val();
|
||||
month = $('.datetimepicker-month[datetimepicker=' + pickerIndex + ']').val();
|
||||
|
||||
dayDOM = $('.datetimepicker-day[datetimepicker=' + pickerIndex + ']');
|
||||
if (typeof(year) == 'undefined' || typeof(month) == 'undefined') {
|
||||
dayDOM.attr('max', 1)
|
||||
.val(1);
|
||||
} else {
|
||||
dayDOM.attr('max', ccn_datetime_monthDayCount[month - 1] + ((month == 2 && ccn_datetime_IsLeapYear(year) ? 1 : 0)))
|
||||
.val(1);
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_datetimepicker_Set(pickerIndex, dt) {
|
||||
$('.datetimepicker-year[datetimepicker=' + pickerIndex + ']').val(dt.getFullYear());
|
||||
$('.datetimepicker-month[datetimepicker=' + pickerIndex + ']').val(dt.getMonth() + 1);
|
||||
$('.datetimepicker-day[datetimepicker=' + pickerIndex + ']').val(dt.getDate());
|
||||
$('.datetimepicker-hour[datetimepicker=' + pickerIndex + ']').val(dt.getHours());
|
||||
$('.datetimepicker-minute[datetimepicker=' + pickerIndex + ']').val(dt.getMinutes());
|
||||
}
|
||||
|
||||
function ccn_calendar_datetimepicker_Get(pickerIndex) {
|
||||
year = $('.datetimepicker-year[datetimepicker=' + pickerIndex + ']').val();
|
||||
month = $('.datetimepicker-month[datetimepicker=' + pickerIndex + ']').val();
|
||||
day = $('.datetimepicker-day[datetimepicker=' + pickerIndex + ']').val();
|
||||
hour = $('.datetimepicker-hour[datetimepicker=' + pickerIndex + ']').val();
|
||||
minute = $('.datetimepicker-minute[datetimepicker=' + pickerIndex + ']').val();
|
||||
if (IsUndefinedOrEmpty(year)) year = ccn_datetime_MIN_YEAR;
|
||||
if (IsUndefinedOrEmpty(month)) month = 1;
|
||||
if (IsUndefinedOrEmpty(day)) day = 1;
|
||||
if (IsUndefinedOrEmpty(hour)) hour = 0;
|
||||
if (IsUndefinedOrEmpty(minute)) minute = 0;
|
||||
|
||||
return new Date(year, month - 1, day, hour, minute, 0, 0);
|
||||
}
|
||||
|
||||
// ================== calendar
|
||||
|
||||
function ccn_calendar_calendar_LoadCalendarBody() {
|
||||
@@ -165,7 +66,7 @@ function ccn_calendar_calendar_LoadCalendarBody() {
|
||||
}
|
||||
|
||||
function ccn_calendar_calendar_Refresh() {
|
||||
gottenDateTime = ccn_calendar_datetimepicker_Get(4);
|
||||
gottenDateTime = ccn_datetimepicker_Get(1);
|
||||
gottenYear = gottenDateTime.getFullYear();
|
||||
gottenMonth = gottenDateTime.getMonth() + 1;
|
||||
}
|
||||
@@ -180,361 +81,118 @@ function ccn_calendar_calendar_AnalyseEvent() {
|
||||
|
||||
function ccn_calendar_calendar_Today() {
|
||||
var nowtime = new Date();
|
||||
ccn_calendar_datetimepicker_Set(4, nowtime);
|
||||
ccn_datetimepicker_Set(1, nowtime);
|
||||
ccn_calendar_calendar_Refresh();
|
||||
}
|
||||
|
||||
function ccn_calendar_calendar_Add() {
|
||||
$('#ccn-calendar-modalEvent').addClass('is-active');
|
||||
}
|
||||
|
||||
function ccn_calendar_calendar_ItemEdit() {
|
||||
$('#ccn-calendar-modalEvent').addClass('is-active');
|
||||
window.location.href = '/web/eventAdd';
|
||||
}
|
||||
|
||||
function ccn_calendar_calendar_ItemUpdate() {
|
||||
$('#ccn-calendar-modalEvent').removeClass('is-active');
|
||||
var uuid = $(this).attr("uuid");
|
||||
window.location.href = '/web/eventUpdate/' + uuid;
|
||||
}
|
||||
|
||||
function ccn_calendar_calendar_ItemCancel() {
|
||||
$('#ccn-calendar-modalEvent').removeClass('is-active');
|
||||
}
|
||||
// ============================= collection
|
||||
|
||||
function ccn_calendar_calendar_DeployEventModal() {
|
||||
|
||||
}
|
||||
|
||||
// return undefined to indicate an error
|
||||
function ccn_calendar_calendar_GetEventModal() {
|
||||
|
||||
}
|
||||
|
||||
// ================== collection
|
||||
|
||||
function ccn_calendar_owned_Refresh() {
|
||||
ccn_calendar_owned_listCache = new Array();
|
||||
ccn_calendar_sharing_displayCache = new Array();
|
||||
|
||||
var result = ccn_api_collection_getFullOwn();
|
||||
if(typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_owned_listCache[result[index][0]] = result[index];
|
||||
ccn_calendar_sharing_displayCache[result[index][0]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
var listDOM = $('#ccn-calendar-ownedList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_calendar_owned_listCache) {
|
||||
ccn_calendar_owned_RenderItem(
|
||||
ccn_calendar_owned_listCache[index],
|
||||
listDOM
|
||||
)
|
||||
}
|
||||
|
||||
// also, order sharing list clean
|
||||
ccn_calendar_sharing_editingOwned = undefined;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_RenderItem(item, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: item[0],
|
||||
name: item[1]
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_ownedItem.render(renderdata));
|
||||
|
||||
// set mode
|
||||
var uuid = renderdata.uuid;
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, true, false);
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).click(ccn_calendar_owned_ItemEdit);
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).click(ccn_calendar_owned_ItemDelete);
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).click(ccn_calendar_owned_ItemShare);
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).click(ccn_calendar_owned_ItemUpdate);
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).click(ccn_calendar_owned_ItemCancelUpdate);
|
||||
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ChangeDisplayMode(uuid, isShow, isEdit) {
|
||||
if (typeof(isShow) != 'undefined') {
|
||||
if (isShow) {
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).hide();
|
||||
} else {
|
||||
$('#ccn-calendar-ownedItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnShow-' + uuid).show();
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(isEdit) != 'undefined') {
|
||||
if (isEdit) {
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).hide();
|
||||
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).show();
|
||||
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-boxName-' + uuid).show();
|
||||
} else {
|
||||
$('#ccn-calendar-ownedItem-btnEdit-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnShare-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-btnDelete-' + uuid).show();
|
||||
|
||||
$('#ccn-calendar-ownedItem-btnUpdate-' + uuid).hide();
|
||||
$('#ccn-calendar-ownedItem-btnCancelUpdate-' + uuid).hide();
|
||||
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).show();
|
||||
$('#ccn-calendar-ownedItem-boxName-' + uuid).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ccn_calendar_sharing_Refresh() {
|
||||
ccn_calendar_sharing_listCache = new Array();
|
||||
|
||||
if (typeof(ccn_calendar_sharing_editingOwned) != 'undefined') {
|
||||
var result = ccn_api_collection_getSharing(ccn_calendar_sharing_editingOwned);
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_sharing_listCache[index] = result[index];
|
||||
// also, sharingTarget don't have uuid, use index instead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update editing text
|
||||
$('#ccn-calendar-sharing-sharingEditing').text(
|
||||
typeof(ccn_calendar_sharing_editingOwned) == 'undefined' ?
|
||||
'' :
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][1]
|
||||
);
|
||||
|
||||
// if editing is undefined, hide container
|
||||
if (typeof(ccn_calendar_sharing_editingOwned) == 'undefined')
|
||||
$('#ccn-calendar-sharing-container').hide();
|
||||
else
|
||||
$('#ccn-calendar-sharing-container').show();
|
||||
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_calendar_sharing_listCache) {
|
||||
ccn_calendar_sharing_RenderItem(
|
||||
ccn_calendar_sharing_listCache[index],
|
||||
index,
|
||||
listDOM
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharing_RenderItem(item, index, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: index,
|
||||
username: item
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_sharingItem.render(renderdata));
|
||||
|
||||
// bind event
|
||||
var uuid = index;
|
||||
$("#ccn-calendar-sharingItem-btnDelete-" + uuid).click(ccn_calendar_sharing_ItemDelete);
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_shared_Refresh() {
|
||||
ccn_calendar_shared_listCache = new Array();
|
||||
function ccn_calendar_collection_Refresh() {
|
||||
ccn_calendar_owned_displayCache = new Array();
|
||||
ccn_calendar_shared_displayCache = new Array();
|
||||
|
||||
// render shared
|
||||
var result = ccn_api_collection_getShared();
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_calendar_shared_listCache[result[index][0]] = result[index];
|
||||
ccn_calendar_shared_displayCache[result[index][0]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharedList');
|
||||
listDOM.empty();
|
||||
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);
|
||||
|
||||
var listDOM = $('#ccn-calendar-sharedList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_calendar_shared_listCache) {
|
||||
var item = ccn_calendar_shared_listCache[index];
|
||||
renderdata.uuid = item[0];
|
||||
renderdata.name = item[1];
|
||||
renderdata.username = item[2];
|
||||
|
||||
listDOM.append(ccn_template_sharedItem.render(renderdata));
|
||||
|
||||
// change display
|
||||
var uuid = renderdata.uuid;
|
||||
ccn_calendar_shared_ChangeDisplayMode(uuid, true);
|
||||
|
||||
// bind event
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).click(ccn_calendar_shared_ItemSwitchDisplay);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
ccn_i18n_ApplyLanguage2Content(listDOM);
|
||||
}
|
||||
|
||||
function ccn_calendar_shared_ChangeDisplayMode(uuid, isShow) {
|
||||
if (isShow) {
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).show();
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).hide();
|
||||
} else {
|
||||
$('#ccn-calendar-sharedItem-btnHide-' + uuid).hide();
|
||||
$('#ccn-calendar-sharedItem-btnShow-' + uuid).show();
|
||||
// render owned
|
||||
result = ccn_api_collection_getFullOwn();
|
||||
listDOM = $('#ccn-calendar-ownedList');
|
||||
listDOM.empty();
|
||||
renderdata = {
|
||||
uuid: undefined,
|
||||
name: undefined
|
||||
}
|
||||
}
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
var item = result[index];
|
||||
renderdata.uuid = item[0];
|
||||
renderdata.name = item[1];
|
||||
|
||||
// ========================= input operation
|
||||
|
||||
function ccn_calendar_owned_Add() {
|
||||
var newname = $('#ccn-calendar-owned-inputAdd').val();
|
||||
if (newname == "") return;
|
||||
|
||||
var result = ccn_api_collection_addOwn(newname);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-add"));
|
||||
else {
|
||||
// second get. get detail
|
||||
result = ccn_api_collection_getDetailOwn(result);
|
||||
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-get"));
|
||||
else {
|
||||
// render
|
||||
ccn_calendar_owned_listCache[result[0]] = result;
|
||||
var listDOM = $('#ccn-calendar-ownedList');
|
||||
ccn_calendar_owned_RenderItem(result, listDOM);
|
||||
listDOM.append(ccn_template_displayOwnedItem.render(renderdata));
|
||||
|
||||
// set mode
|
||||
var uuid = renderdata.uuid;
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, true);
|
||||
|
||||
// push into display list
|
||||
ccn_calendar_owned_displayCache[uuid] = true;
|
||||
|
||||
// bind event
|
||||
$('#ccn-displayOwnedItem-btnHide-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
$('#ccn-displayOwnedItem-btnShow-' + uuid).click(ccn_calendar_owned_ItemSwitchDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemEdit() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
// preset inputbox
|
||||
$('#ccn-calendar-ownedItem-inputName-' + uuid).val(
|
||||
ccn_calendar_owned_listCache[uuid][1]
|
||||
);
|
||||
|
||||
// switch to edit mode
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, true);
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var result = ccn_api_collection_deleteOwn(
|
||||
uuid,
|
||||
ccn_calendar_owned_listCache[uuid][2]
|
||||
);
|
||||
if (!result) ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
else {
|
||||
$('#ccn-calendar-ownedItem-' + uuid).remove();
|
||||
|
||||
// also, we should notice sharing target, and try clean it
|
||||
if (ccn_calendar_sharing_editingOwned == uuid) {
|
||||
ccn_calendar_sharing_editingOwned = undefined;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var newname = $('#ccn-calendar-ownedItem-inputName-' + uuid).val();
|
||||
|
||||
var result = ccn_api_collection_updateOwn(uuid, newname, ccn_calendar_owned_listCache[uuid][2]);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-update"));
|
||||
else {
|
||||
// update last change
|
||||
ccn_calendar_owned_listCache[uuid][2] = result;
|
||||
ccn_calendar_owned_listCache[uuid][1] = newname;
|
||||
// update elements
|
||||
$('#ccn-calendar-ownedItem-textName-' + uuid).text(newname);
|
||||
// if editing, update sharing target
|
||||
if (ccn_calendar_sharing_editingOwned == uuid)
|
||||
ccn_calendar_sharing_Refresh();
|
||||
// back to normal mode
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, false);
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemCancelUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, undefined, false);
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemSwitchDisplay() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_sharing_displayCache[uuid] = !(ccn_calendar_sharing_displayCache[uuid]);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, ccn_calendar_sharing_displayCache[uuid], undefined);
|
||||
ccn_calendar_owned_displayCache[uuid] = !(ccn_calendar_owned_displayCache[uuid]);
|
||||
ccn_calendar_owned_ChangeDisplayMode(uuid, ccn_calendar_owned_displayCache[uuid]);
|
||||
}
|
||||
|
||||
function ccn_calendar_owned_ItemShare() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_calendar_sharing_editingOwned = uuid;
|
||||
ccn_calendar_sharing_Refresh();
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_sharing_Add() {
|
||||
var newusername = $('#ccn-calendar-sharing-inputAdd').val();
|
||||
if (newusername == "" || typeof(ccn_calendar_sharing_editingOwned) == 'undefined') return;
|
||||
|
||||
var result = ccn_api_collection_addSharing(
|
||||
ccn_calendar_sharing_editingOwned,
|
||||
newusername,
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-add"));
|
||||
else {
|
||||
// add new item
|
||||
var index = ccn_calendar_sharing_listCache.push(newusername) - 1;
|
||||
var listDOM = $('#ccn-calendar-sharingList');
|
||||
ccn_calendar_sharing_RenderItem(newusername, index, listDOM);
|
||||
// update last change
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_calendar_sharing_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var username = ccn_calendar_sharing_listCache[uuid];
|
||||
|
||||
var result = ccn_api_collection_deleteSharing(
|
||||
ccn_calendar_sharing_editingOwned,
|
||||
username,
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
else {
|
||||
// remove item in ui
|
||||
$('#ccn-calendar-sharingItem-' + uuid).remove();
|
||||
// update last change
|
||||
ccn_calendar_owned_listCache[ccn_calendar_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ccn_calendar_shared_ItemSwitchDisplay() {
|
||||
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]);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
288
src/static/js/page/collection.js
Normal file
288
src/static/js/page/collection.js
Normal file
@@ -0,0 +1,288 @@
|
||||
// 3 used cache list
|
||||
var ccn_collection_owned_listCache = [];
|
||||
var ccn_collection_sharing_listCache = [];
|
||||
|
||||
// current editing sharing collection
|
||||
var ccn_collection_sharing_editingOwned = undefined; // the uuid of owned collection
|
||||
|
||||
$(document).ready(function() {
|
||||
ccn_pages_currentPage = ccn_pages_enumPages.collection;
|
||||
|
||||
// template process
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_LoadLanguage();
|
||||
ccn_i18n_ApplyLanguage();
|
||||
|
||||
//refresh once
|
||||
ccn_collection_owned_Refresh();
|
||||
|
||||
// bind event
|
||||
//$('#ccn-calendar-shared-btnRefresh').click(ccn_calendar_shared_Refresh);
|
||||
$('#ccn-collection-owned-btnAdd').click(ccn_collection_owned_Add);
|
||||
$('#ccn-collection-owned-btnRefresh').click(ccn_collection_owned_Refresh);
|
||||
$('#ccn-collection-sharing-btnAdd').click(ccn_collection_sharing_Add);
|
||||
$('#ccn-collection-sharing-btnRefresh').click(ccn_collection_sharing_Refresh);
|
||||
|
||||
});
|
||||
|
||||
|
||||
function ccn_collection_owned_Refresh() {
|
||||
ccn_collection_owned_listCache = new Array();
|
||||
ccn_collection_sharing_displayCache = new Array();
|
||||
|
||||
var result = ccn_api_collection_getFullOwn();
|
||||
if(typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_collection_owned_listCache[result[index][0]] = result[index];
|
||||
}
|
||||
}
|
||||
|
||||
// render
|
||||
var listDOM = $('#ccn-collection-ownedList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_collection_owned_listCache) {
|
||||
ccn_collection_owned_RenderItem(
|
||||
ccn_collection_owned_listCache[index],
|
||||
listDOM
|
||||
);
|
||||
}
|
||||
|
||||
// also, order sharing list clean
|
||||
ccn_collection_sharing_editingOwned = undefined;
|
||||
ccn_collection_sharing_Refresh();
|
||||
}
|
||||
|
||||
function ccn_collection_owned_RenderItem(item, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: item[0],
|
||||
name: item[1]
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_ownedItem.render(renderdata));
|
||||
|
||||
// set mode
|
||||
var uuid = renderdata.uuid;
|
||||
ccn_collection_owned_ChangeDisplayMode(uuid, false);
|
||||
|
||||
// bind event
|
||||
$('#ccn-ownedItem-btnEdit-' + uuid).click(ccn_collection_owned_ItemEdit);
|
||||
$('#ccn-ownedItem-btnDelete-' + uuid).click(ccn_collection_owned_ItemDelete);
|
||||
$('#ccn-ownedItem-btnShare-' + uuid).click(ccn_collection_owned_ItemShare);
|
||||
$('#ccn-ownedItem-btnUpdate-' + uuid).click(ccn_collection_owned_ItemUpdate);
|
||||
$('#ccn-ownedItem-btnCancelUpdate-' + uuid).click(ccn_collection_owned_ItemCancelUpdate);
|
||||
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ChangeDisplayMode(uuid, isEdit) {
|
||||
if (isEdit) {
|
||||
$('#ccn-ownedItem-btnEdit-' + uuid).hide();
|
||||
$('#ccn-ownedItem-btnShare-' + uuid).hide();
|
||||
$('#ccn-ownedItem-btnDelete-' + uuid).hide();
|
||||
|
||||
$('#ccn-ownedItem-btnUpdate-' + uuid).show();
|
||||
$('#ccn-ownedItem-btnCancelUpdate-' + uuid).show();
|
||||
|
||||
$('#ccn-ownedItem-textName-' + uuid).hide();
|
||||
$('#ccn-ownedItem-boxName-' + uuid).show();
|
||||
} else {
|
||||
$('#ccn-ownedItem-btnEdit-' + uuid).show();
|
||||
$('#ccn-ownedItem-btnShare-' + uuid).show();
|
||||
$('#ccn-ownedItem-btnDelete-' + uuid).show();
|
||||
|
||||
$('#ccn-ownedItem-btnUpdate-' + uuid).hide();
|
||||
$('#ccn-ownedItem-btnCancelUpdate-' + uuid).hide();
|
||||
|
||||
$('#ccn-ownedItem-textName-' + uuid).show();
|
||||
$('#ccn-ownedItem-boxName-' + uuid).hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ccn_collection_sharing_Refresh() {
|
||||
ccn_collection_sharing_listCache = new Array();
|
||||
|
||||
if (typeof(ccn_collection_sharing_editingOwned) != 'undefined') {
|
||||
var result = ccn_api_collection_getSharing(ccn_collection_sharing_editingOwned);
|
||||
if (typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_collection_sharing_listCache[index] = result[index];
|
||||
// also, sharingTarget don't have uuid, use index instead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update editing text
|
||||
$('#ccn-collection-sharing-sharingEditing').text(
|
||||
typeof(ccn_collection_sharing_editingOwned) == 'undefined' ?
|
||||
'' :
|
||||
ccn_collection_owned_listCache[ccn_collection_sharing_editingOwned][1]
|
||||
);
|
||||
|
||||
// if editing is undefined, hide container
|
||||
if (typeof(ccn_collection_sharing_editingOwned) == 'undefined')
|
||||
$('#ccn-collection-sharing-container').hide();
|
||||
else
|
||||
$('#ccn-collection-sharing-container').show();
|
||||
|
||||
|
||||
var listDOM = $('#ccn-collection-sharingList');
|
||||
listDOM.empty();
|
||||
for(var index in ccn_collection_sharing_listCache) {
|
||||
ccn_collection_sharing_RenderItem(
|
||||
ccn_collection_sharing_listCache[index],
|
||||
index,
|
||||
listDOM
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_collection_sharing_RenderItem(item, index, listDOM) {
|
||||
var renderdata = {
|
||||
uuid: index,
|
||||
username: item
|
||||
}
|
||||
|
||||
// render
|
||||
listDOM.append(ccn_template_sharingItem.render(renderdata));
|
||||
|
||||
// bind event
|
||||
var uuid = index;
|
||||
$("#ccn-sharingItem-btnDelete-" + uuid).click(ccn_collection_sharing_ItemDelete);
|
||||
}
|
||||
|
||||
// ========================= input operation
|
||||
|
||||
function ccn_collection_owned_Add() {
|
||||
var newname = $('#ccn-collection-owned-inputAdd').val();
|
||||
if (newname == "") return;
|
||||
|
||||
var result = ccn_api_collection_addOwn(newname);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-add"));
|
||||
else {
|
||||
// second get. get detail
|
||||
result = ccn_api_collection_getDetailOwn(result);
|
||||
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-get"));
|
||||
else {
|
||||
// render
|
||||
ccn_collection_owned_listCache[result[0]] = result;
|
||||
var listDOM = $('#ccn-collection-ownedList');
|
||||
ccn_collection_owned_RenderItem(result, listDOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ItemEdit() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
// preset inputbox
|
||||
$('#ccn-ownedItem-inputName-' + uuid).val(
|
||||
ccn_collection_owned_listCache[uuid][1]
|
||||
);
|
||||
|
||||
// switch to edit mode
|
||||
ccn_collection_owned_ChangeDisplayMode(uuid, true);
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var result = ccn_api_collection_deleteOwn(
|
||||
uuid,
|
||||
ccn_collection_owned_listCache[uuid][2]
|
||||
);
|
||||
if (!result) ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-delete"));
|
||||
else {
|
||||
$('#ccn-ownedItem-' + uuid).remove();
|
||||
|
||||
// also, we should notice sharing target, and try clean it
|
||||
if (ccn_collection_sharing_editingOwned == uuid) {
|
||||
ccn_collection_sharing_editingOwned = undefined;
|
||||
ccn_collection_sharing_Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var newname = $('#ccn-ownedItem-inputName-' + uuid).val();
|
||||
|
||||
var result = ccn_api_collection_updateOwn(uuid, newname, ccn_collection_owned_listCache[uuid][2]);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-update"));
|
||||
else {
|
||||
// update last change
|
||||
ccn_collection_owned_listCache[uuid][2] = result;
|
||||
ccn_collection_owned_listCache[uuid][1] = newname;
|
||||
// update elements
|
||||
$('#ccn-ownedItem-textName-' + uuid).text(newname);
|
||||
// if editing, update sharing target
|
||||
if (ccn_collection_sharing_editingOwned == uuid)
|
||||
ccn_collection_sharing_Refresh();
|
||||
// back to normal mode
|
||||
ccn_collection_owned_ChangeDisplayMode(uuid, false);
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ItemCancelUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_collection_owned_ChangeDisplayMode(uuid, false);
|
||||
}
|
||||
|
||||
function ccn_collection_owned_ItemShare() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
ccn_collection_sharing_editingOwned = uuid;
|
||||
ccn_collection_sharing_Refresh();
|
||||
}
|
||||
|
||||
|
||||
function ccn_collection_sharing_Add() {
|
||||
var newusername = $('#ccn-collection-sharing-inputAdd').val();
|
||||
if (newusername == "" || typeof(ccn_collection_sharing_editingOwned) == 'undefined') return;
|
||||
|
||||
var result = ccn_api_collection_addSharing(
|
||||
ccn_collection_sharing_editingOwned,
|
||||
newusername,
|
||||
ccn_collection_owned_listCache[ccn_collection_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-add"));
|
||||
else {
|
||||
// add new item
|
||||
var index = ccn_collection_sharing_listCache.push(newusername) - 1;
|
||||
var listDOM = $('#ccn-collection-sharingList');
|
||||
ccn_collection_sharing_RenderItem(newusername, index, listDOM);
|
||||
// update last change
|
||||
ccn_collection_owned_listCache[ccn_collection_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_collection_sharing_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
var username = ccn_collection_sharing_listCache[uuid];
|
||||
|
||||
var result = ccn_api_collection_deleteSharing(
|
||||
ccn_collection_sharing_editingOwned,
|
||||
username,
|
||||
ccn_collection_owned_listCache[ccn_collection_sharing_editingOwned][2]
|
||||
);
|
||||
if (typeof(result) == 'undefined') ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-delete"));
|
||||
else {
|
||||
// remove item in ui
|
||||
$('#ccn-sharingItem-' + uuid).remove();
|
||||
// update last change
|
||||
ccn_collection_owned_listCache[ccn_collection_sharing_editingOwned][2] = result;
|
||||
}
|
||||
}
|
||||
|
||||
77
src/static/js/page/event.js
Normal file
77
src/static/js/page/event.js
Normal file
@@ -0,0 +1,77 @@
|
||||
$(document).ready(function() {
|
||||
ccn_pages_currentPage = ccn_pages_enumPages.event;
|
||||
|
||||
// template process
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_LoadLanguage();
|
||||
ccn_i18n_ApplyLanguage();
|
||||
|
||||
// init datetimepicker
|
||||
ccn_datetimepicker_Init();
|
||||
|
||||
// init span picker
|
||||
$('.spanpicker').attr('max', 100)
|
||||
.attr('min', 1)
|
||||
.attr('step', 1)
|
||||
.val(1);
|
||||
|
||||
// refresh once
|
||||
|
||||
|
||||
// bind event
|
||||
|
||||
});
|
||||
|
||||
|
||||
function ccn_event_Deploy() {
|
||||
var isAdd = typeof(ccn_calendar_eventModal_editing) == 'undefined';
|
||||
$('#ccn-event-inputTitle').val(
|
||||
isAdd ? '' : ccn_calendar_eventModal_editing[2]
|
||||
);
|
||||
$('#ccn-event-inputDescription').val(
|
||||
isAdd ? '' : ccn_calendar_eventModal_editing[3]
|
||||
);
|
||||
|
||||
// we also need render eventModal collection select
|
||||
var collectionDOM = $('#ccn-event-inputCollection');
|
||||
collectionDOM.options.length = 0;
|
||||
for(var index in ccn_calendar_eventModal_collectionCache) {
|
||||
var uuid = ccn_calendar_eventModal_collectionCache[index];
|
||||
collectionDOM.add(new Option(
|
||||
|
||||
));
|
||||
}
|
||||
$('#ccn-event-inputCollection').selectedIndex = isAdd ? -1 : ccn_calendar_eventModal_collectionCache.indexOf(ccn_calendar_eventModal_editing[1]);
|
||||
|
||||
var currentDateTime = new Date();
|
||||
currentDateTime.setMilliseconds(0);
|
||||
currentDateTime.setSeconds(0);
|
||||
currentDateTime.setMinutes(0);
|
||||
ccn_datetimepicker_Set(1, currentDateTime);
|
||||
|
||||
currentDateTime.setHours(currentDateTime.getHours() + 2);
|
||||
ccn_datetimepicker_Set(2, currentDateTime);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function ccn_event_Refresh() {
|
||||
|
||||
}
|
||||
|
||||
// return undefined to indicate an error
|
||||
function ccn_event_Get() {
|
||||
|
||||
}
|
||||
@@ -40,8 +40,8 @@ function ccn_login_startLogin() {
|
||||
// jump into home page again
|
||||
window.location.href = '/web/home';
|
||||
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-login"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-login"));
|
||||
*/
|
||||
if (ccn_api_common_webLogin(username, password)) {
|
||||
// ok, logged
|
||||
@@ -49,7 +49,7 @@ function ccn_login_startLogin() {
|
||||
window.location.href = '/web/home';
|
||||
return;
|
||||
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-login"));
|
||||
|
||||
// retore ui
|
||||
$("#ccn-login-form-login").removeAttr("disabled");
|
||||
|
||||
@@ -64,32 +64,32 @@ function ccn_todo_RenderCacheList() {
|
||||
ccn_todo_ChangeDisplayMode(uuid, false);
|
||||
|
||||
// bind event
|
||||
$("#ccn-todo-todoItem-btnEdit-" + uuid).click(ccn_todo_ItemEdit);
|
||||
$("#ccn-todo-todoItem-btnDelete-" + uuid).click(ccn_todo_ItemDelete);
|
||||
$("#ccn-todo-todoItem-btnUpdate-" + uuid).click(ccn_todo_ItemUpdate);
|
||||
$("#ccn-todo-todoItem-btnCancelUpdate-" + uuid).click(ccn_todo_ItemCancelUpdate);
|
||||
$("#ccn-todoItem-btnEdit-" + uuid).click(ccn_todo_ItemEdit);
|
||||
$("#ccn-todoItem-btnDelete-" + uuid).click(ccn_todo_ItemDelete);
|
||||
$("#ccn-todoItem-btnUpdate-" + uuid).click(ccn_todo_ItemUpdate);
|
||||
$("#ccn-todoItem-btnCancelUpdate-" + uuid).click(ccn_todo_ItemCancelUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_todo_ChangeDisplayMode(uuid, isEdit) {
|
||||
if(isEdit) {
|
||||
// 4 buttons
|
||||
$("#ccn-todo-todoItem-btnEdit-" + uuid).hide();
|
||||
$("#ccn-todo-todoItem-btnDelete-" + uuid).hide();
|
||||
$("#ccn-todo-todoItem-btnUpdate-" + uuid).show();
|
||||
$("#ccn-todo-todoItem-btnCancelUpdate-" + uuid).show();
|
||||
$("#ccn-todoItem-btnEdit-" + uuid).hide();
|
||||
$("#ccn-todoItem-btnDelete-" + uuid).hide();
|
||||
$("#ccn-todoItem-btnUpdate-" + uuid).show();
|
||||
$("#ccn-todoItem-btnCancelUpdate-" + uuid).show();
|
||||
|
||||
// 2 elements
|
||||
$("#ccn-todo-todoItem-p-" + uuid).hide();
|
||||
$("#ccn-todo-todoItem-textarea-" + uuid).show();
|
||||
$("#ccn-todoItem-p-" + uuid).hide();
|
||||
$("#ccn-todoItem-textarea-" + uuid).show();
|
||||
} else {
|
||||
$("#ccn-todo-todoItem-btnEdit-" + uuid).show();
|
||||
$("#ccn-todo-todoItem-btnDelete-" + uuid).show();
|
||||
$("#ccn-todo-todoItem-btnUpdate-" + uuid).hide();
|
||||
$("#ccn-todo-todoItem-btnCancelUpdate-" + uuid).hide();
|
||||
$("#ccn-todoItem-btnEdit-" + uuid).show();
|
||||
$("#ccn-todoItem-btnDelete-" + uuid).show();
|
||||
$("#ccn-todoItem-btnUpdate-" + uuid).hide();
|
||||
$("#ccn-todoItem-btnCancelUpdate-" + uuid).hide();
|
||||
|
||||
$("#ccn-todo-todoItem-p-" + uuid).show();
|
||||
$("#ccn-todo-todoItem-textarea-" + uuid).hide();
|
||||
$("#ccn-todoItem-p-" + uuid).show();
|
||||
$("#ccn-todoItem-textarea-" + uuid).hide();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,7 +104,7 @@ function ccn_todo_Add() {
|
||||
var result = ccn_api_todo_add();
|
||||
if (typeof(result) == 'undefined') {
|
||||
// fail
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-add"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-add"));
|
||||
} else {
|
||||
// add into cache
|
||||
ccn_todo_todoListCache[result[0]] = result;
|
||||
@@ -121,10 +121,10 @@ function ccn_todo_Add() {
|
||||
ccn_todo_ChangeDisplayMode(uuid, false);
|
||||
|
||||
// bind event
|
||||
$("#ccn-todo-todoItem-btnEdit-" + uuid).click(ccn_todo_ItemEdit);
|
||||
$("#ccn-todo-todoItem-btnDelete-" + uuid).click(ccn_todo_ItemDelete);
|
||||
$("#ccn-todo-todoItem-btnUpdate-" + uuid).click(ccn_todo_ItemUpdate);
|
||||
$("#ccn-todo-todoItem-btnCancelUpdate-" + uuid).click(ccn_todo_ItemCancelUpdate);
|
||||
$("#ccn-todoItem-btnEdit-" + uuid).click(ccn_todo_ItemEdit);
|
||||
$("#ccn-todoItem-btnDelete-" + uuid).click(ccn_todo_ItemDelete);
|
||||
$("#ccn-todoItem-btnUpdate-" + uuid).click(ccn_todo_ItemUpdate);
|
||||
$("#ccn-todoItem-btnCancelUpdate-" + uuid).click(ccn_todo_ItemCancelUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ function ccn_todo_ItemEdit() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
// copy current data to textarea
|
||||
$("#ccn-todo-todoItem-textarea-" + uuid).val(
|
||||
$("#ccn-todoItem-textarea-" + uuid).val(
|
||||
ccn_todo_todoListCache[uuid][2]
|
||||
);
|
||||
|
||||
@@ -150,17 +150,17 @@ function ccn_todo_ItemDelete() {
|
||||
|
||||
if(!result) {
|
||||
// fail
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-delete"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-delete"));
|
||||
} else {
|
||||
// remove body
|
||||
$("#ccn-todo-todoItem-" + uuid).remove();
|
||||
$("#ccn-todoItem-" + uuid).remove();
|
||||
}
|
||||
}
|
||||
|
||||
function ccn_todo_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var newData = $("#ccn-todo-todoItem-textarea-" + uuid).val();
|
||||
var newData = $("#ccn-todoItem-textarea-" + uuid).val();
|
||||
var result = ccn_api_todo_update(
|
||||
uuid,
|
||||
newData,
|
||||
@@ -169,12 +169,12 @@ function ccn_todo_ItemUpdate() {
|
||||
|
||||
if (typeof(result) == 'undefined') {
|
||||
// fail
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-update"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-update"));
|
||||
} else {
|
||||
// safely update data & lastChanged and control
|
||||
ccn_todo_todoListCache[uuid][2] = newData;
|
||||
ccn_todo_todoListCache[uuid][3] = result;
|
||||
$("#ccn-todo-todoItem-p-" + uuid).html(LineBreaker2Br(newData));
|
||||
$("#ccn-todoItem-p-" + uuid).html(LineBreaker2Br(newData));
|
||||
|
||||
// switch to normal mode
|
||||
ccn_todo_ChangeDisplayMode(uuid, false);
|
||||
@@ -184,7 +184,7 @@ function ccn_todo_ItemUpdate() {
|
||||
function ccn_todo_ItemCancelUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
// clean data
|
||||
$("#ccn-todo-todoItem-textarea-" + uuid).val("");
|
||||
$("#ccn-todoItem-textarea-" + uuid).val("");
|
||||
// switch to normal mode
|
||||
ccn_todo_ChangeDisplayMode(uuid, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user