From 51d607a6bbf4de584ed84e1817e8720f534a278b Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Mon, 8 Feb 2021 16:22:04 +0800 Subject: [PATCH] seperate 1 page into 3 pages for more fluent manage --- src/server.py | 19 + src/static/css/collection.css | 34 ++ src/static/css/event.css | 11 + src/static/i18n/strings_en-US.properties | 206 ++++----- src/static/i18n/strings_zh-CN.properties | 221 +++++----- src/static/js/datetimepicker.js | 74 ++++ src/static/js/headerNav.js | 4 +- src/static/js/i18n.js | 20 +- src/static/js/page/admin.js | 56 +-- src/static/js/page/calendar.js | 510 ++++------------------- src/static/js/page/collection.js | 288 +++++++++++++ src/static/js/page/event.js | 77 ++++ src/static/js/page/login.js | 6 +- src/static/js/page/todo.js | 56 +-- src/static/js/template.js | 38 +- src/static/tmpl/calendarItem.tmpl | 8 +- src/static/tmpl/displayOwnedItem.tmpl | 12 + src/static/tmpl/displaySharedItem.tmpl | 16 + src/static/tmpl/headerNav.tmpl | 15 +- src/static/tmpl/messagebox.tmpl | 4 +- src/static/tmpl/ownedItem.tmpl | 24 +- src/static/tmpl/sharedItem.tmpl | 16 - src/static/tmpl/sharingItem.tmpl | 4 +- src/static/tmpl/todoItem.tmpl | 14 +- src/static/tmpl/userItem.tmpl | 24 +- src/templates/admin.html | 8 +- src/templates/calendar.html | 424 ++----------------- src/templates/collection.html | 94 +++++ src/templates/event.html | 346 +++++++++++++++ src/templates/home.html | 2 +- src/templates/login.html | 6 +- src/templates/todo.html | 2 +- 32 files changed, 1465 insertions(+), 1174 deletions(-) create mode 100644 src/static/css/collection.css create mode 100644 src/static/css/event.css create mode 100644 src/static/js/datetimepicker.js create mode 100644 src/static/js/page/collection.js create mode 100644 src/static/js/page/event.js create mode 100644 src/static/tmpl/displayOwnedItem.tmpl create mode 100644 src/static/tmpl/displaySharedItem.tmpl delete mode 100644 src/static/tmpl/sharedItem.tmpl create mode 100644 src/templates/collection.html create mode 100644 src/templates/event.html diff --git a/src/server.py b/src/server.py index b447089..4271be3 100644 --- a/src/server.py +++ b/src/server.py @@ -66,6 +66,25 @@ def web_loginHandle(): # UpdateStaticResources() return render_template("login.html") +@app.route('/web/collection', methods=['GET']) +def web_collectionHandle(): + # UpdateStaticResources() + return render_template("collection.html") + +@app.route('/web/eventAdd', methods=['GET']) +def web_eventAddHandle(): + # UpdateStaticResources() + return render_template("event.html", + uuidPath='' + ) + +@app.route('/web/eventUpdate/', methods=['GET']) +def web_eventUpdateHandle(uuidPath): + # UpdateStaticResources() + return render_template("event.html", + uuidPath = uuidPath + ) + # ============================================= query page route # ================================ common diff --git a/src/static/css/collection.css b/src/static/css/collection.css new file mode 100644 index 0000000..0f7dcf1 --- /dev/null +++ b/src/static/css/collection.css @@ -0,0 +1,34 @@ +div.collection-item { + display: flex; + flex-flow: row; + align-items: flex-start; + + padding: 1.25rem; + margin-bottom: 1.25rem; +} + +div.collection-item-words { + flex-grow: 1; + flex-basis: 0; + + word-break: break-all; +} + +div.collection-item-icon { + margin-left: 0.75rem; +} + + + + +div.control-list { + display: flex; + flex-flow: row; + flex-wrap: wrap; +} + +div.control-list > * { + margin-right: 0.75rem; + margin-bottom: 0.75rem; + margin-left: 0 !important; +} \ No newline at end of file diff --git a/src/static/css/event.css b/src/static/css/event.css new file mode 100644 index 0000000..f1e6a7d --- /dev/null +++ b/src/static/css/event.css @@ -0,0 +1,11 @@ +div.control-list { + display: flex; + flex-flow: row; + flex-wrap: wrap; +} + +div.control-list > * { + margin-right: 0.75rem; + margin-bottom: 0.75rem; + margin-left: 0 !important; +} \ No newline at end of file diff --git a/src/static/i18n/strings_en-US.properties b/src/static/i18n/strings_en-US.properties index 6770ca0..c9237cb 100644 --- a/src/static/i18n/strings_en-US.properties +++ b/src/static/i18n/strings_en-US.properties @@ -1,102 +1,120 @@ -ccn-pageName-home=coconut-leaf - A light, self-host calendar system. -ccn-pageName-calendar=coconut-leaf - Calendar -ccn-pageName-todo=coconut-leaf - Todo -ccn-pageName-admin=coconut-leaf - Admin -ccn-pageName-login=coconut-leaf - Login +ccn-i18n-pageName-home=coconut-leaf - A light, self-host calendar system. +ccn-i18n-pageName-collection=coconut-leaf - Collection +ccn-i18n-pageName-calendar=coconut-leaf - Calendar +ccn-i18n-pageName-event=coconut-leaf - Event +ccn-i18n-pageName-todo=coconut-leaf - Todo +ccn-i18n-pageName-admin=coconut-leaf - Admin +ccn-i18n-pageName-login=coconut-leaf - Login -ccn-header-nav-home=Home -ccn-header-nav-calendar=Calendar -ccn-header-nav-todo=Todo -ccn-header-nav-admin=Admin -ccn-header-user-login=Login -ccn-header-user-logout=Logout -ccn-header-language=Language +ccn-i18n-header-nav-home=Home +ccn-i18n-header-nav-collection=Collection +ccn-i18n-header-nav-calendar=Calendar +ccn-i18n-header-nav-todo=Todo +ccn-i18n-header-nav-admin=Admin +ccn-i18n-header-user-login=Login +ccn-i18n-header-user-logout=Logout +ccn-i18n-header-language=Language -ccn-messagebox-confirm=OK -ccn-messagebox-title=Notification +ccn-i18n-universal-text-year=Year +ccn-i18n-universal-text-month=Month +ccn-i18n-universal-text-day=Day +ccn-i18n-universal-text-hour=Hour +ccn-i18n-universal-text-minute=Minute +ccn-i18n-universal-week-1=Monday +ccn-i18n-universal-week-2=Tuesday +ccn-i18n-universal-week-3=Wednesday +ccn-i18n-universal-week-4=Thursday +ccn-i18n-universal-week-5=Friday +ccn-i18n-universal-week-6=Saturday +ccn-i18n-universal-week-7=Sunday +ccn-i18n-universal-month-1=1月 +ccn-i18n-universal-month-2=2月 +ccn-i18n-universal-month-3=3月 +ccn-i18n-universal-month-4=4月 +ccn-i18n-universal-month-5=5月 +ccn-i18n-universal-month-6=6月 +ccn-i18n-universal-month-7=7月 +ccn-i18n-universal-month-8=8月 +ccn-i18n-universal-month-9=9月 +ccn-i18n-universal-month-10=10月 +ccn-i18n-universal-month-11=11月 +ccn-i18n-universal-month-12=12月 -ccn-js-fail-login=Fail to login. Please check your username or password. -ccn-js-fail-logout=Fail to logout due to unknow reason. Consider refreshing page to solve problem. -ccn-js-fail-get=A get operation failed. It may caused by server internal error or your limited permission. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. -ccn-js-fail-add=An add operation failed. It may caused by wrong arguments. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. -ccn-js-fail-update=An update operation failed. It may caused by wrong arguments or lost target. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. -ccn-js-fail-delete=A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. -ccn-js-success=Operation OK. +ccn-i18n-messagebox-confirm=OK +ccn-i18n-messagebox-title=Notification -ccn-home-desc=

coconut-leaf

A light, self-host calendar system.

Originally, this app is served for yyc12345 personal use.


Pull request / issue / translation are welcomed.

Submit them in our GitHub project.

This project source code is licensed AGPL v3.

+ccn-i18n-js-fail-login=Fail to login. Please check your username or password. +ccn-i18n-js-fail-logout=Fail to logout due to unknow reason. Consider refreshing page to solve problem. +ccn-i18n-js-fail-get=A get operation failed. It may caused by server internal error or your limited permission. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. +ccn-i18n-js-fail-add=An add operation failed. It may caused by wrong arguments. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. +ccn-i18n-js-fail-update=An update operation failed. It may caused by wrong arguments or lost target. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. +ccn-i18n-js-fail-delete=A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data. +ccn-i18n-js-success=Operation OK. -ccn-login-form-username=Username -ccn-login-form-password=Password -ccn-login-form-login=Login +ccn-i18n-home-desc=

coconut-leaf

A light, self-host calendar system.

Originally, this app is served for yyc12345 personal use.


Pull request / issue / translation are welcomed.

Submit them in our GitHub project.

This project source code is licensed AGPL v3.

-ccn-todo-todoList=Todo list +ccn-i18n-login-form-username=Username +ccn-i18n-login-form-password=Password +ccn-i18n-login-form-login=Login -ccn-calendar-calendar-jump=Jump -ccn-calendar-calendar-today=Today -ccn-calendar-calendar-add=Add... -ccn-calendar-calendar-scheduleList=Schedule -ccn-calendar-tabcontrol-tabCalendar=Calendar -ccn-calendar-tabcontrol-tabShared=Shared -ccn-calendar-tabcontrol-tabSharing=Sharing -ccn-calendar-text-year=Year -ccn-calendar-text-month=Month -ccn-calendar-text-day=Day -ccn-calendar-text-hour=Hour -ccn-calendar-text-minute=Minute -ccn-calendar-week-1=Monday -ccn-calendar-week-2=Tuesday -ccn-calendar-week-3=Wednesday -ccn-calendar-week-4=Thursday -ccn-calendar-week-5=Friday -ccn-calendar-week-6=Saturday -ccn-calendar-week-7=Sunday -ccn-calendar-modalEvent-header=Edit Event -ccn-calendar-modalEvent-title=Title -ccn-calendar-modalEvent-description=Description -ccn-calendar-modalEvent-collection=Collection -ccn-calendar-modalEvent-startDateTime=Start Date Time -ccn-calendar-modalEvent-endDateTime=Stop Date Time -ccn-calendar-modalEvent-btnSpot=Spot -ccn-calendar-modalEvent-btnFullDay=Full day -ccn-calendar-modalEvent-loop=Event Loop -ccn-calendar-modalEvent-loop-never=Never -ccn-calendar-modalEvent-loop-day=Day -ccn-calendar-modalEvent-loop-week=Week -ccn-calendar-modalEvent-loop-month=Month -ccn-calendar-modalEvent-loop-year=Year -ccn-calendar-modalEvent-loopDay-span=Day span -ccn-calendar-modalEvent-loopWeek-span=Week span -ccn-calendar-modalEvent-loopWeek-option=Week options -ccn-calendar-modalEvent-loopMonth-span=Month span -ccn-calendar-modalEvent-loopWeek-option=Month mode -ccn-calendar-modalEvent-loopWeek-optionA=Day {0} in month -ccn-calendar-modalEvent-loopWeek-optionB=Day {0} from the end of the month -ccn-calendar-modalEvent-loopWeek-optionC=Week {0}, day {1} in month -ccn-calendar-modalEvent-loopWeek-optionD=Week {0}, day {1} from the end of the month -ccn-calendar-modalEvent-loopYear-span=Year span -ccn-calendar-modalEvent-loopStop=Event Loop Stop -ccn-calendar-modalEvent-loopStop-forever=Forever -ccn-calendar-modalEvent-loopStop-datetime=Date Time -ccn-calendar-modalEvent-loopStop-times=Times -ccn-calendar-modalEvent-timezone-title=Timezone -ccn-calendar-modalEvent-timezone-warning=The timezone of this event is not corresponding with your current timezone. You can choose a timezone option in follwing content. If you are not familar with this, please pick keep timezone. -ccn-calendar-modalEvent-timezone-keep=Keep timezone -ccn-calendar-modalEvent-timezone-replace=Use my timezone -ccn-calendar-modalEvent-strictMode-title=Strict Mode in Event Loop -ccn-calendar-modalEvent-strictMode-warning=You can choose strict mode or rough mode in following content. This is only effect on looped event. -ccn-calendar-modalEvent-strictMode-strict=Strict Mode. If ordered day is not existing, skip it. -ccn-calendar-modalEvent-strictMode-rough=Rough mode. If ordered day is not existing, choose the day closing with original day to arrange event. -ccn-calendar-modalEvent-btnSubmit=Submit -ccn-calendar-modalEvent-btnCancel=Cancel -ccn-calendar-shared-list=Shared -ccn-calendar-owned-list=Owned -ccn-calendar-sharing-list=Sharing target -ccn-calendar-sharing-editing=Editing: -ccn-calendar-sharedItem-sharedBy=Shared by: +ccn-i18n-todo-todoList=Todo list -ccn-admin-tabcontrol-tabProfile=My Profile -ccn-admin-tabcontrol-tabUserList=Manager User -ccn-admin-changePassword=Change Password -ccn-admin-userList=User List -ccn-admin-userItem-newPassword=New Password -ccn-admin-userItem-isAdmin=Is Admin +ccn-i18n-calendar-calendar-jump=Jump +ccn-i18n-calendar-calendar-today=Today +ccn-i18n-calendar-calendar-add=Add... +ccn-i18n-calendar-calendar-scheduleList=Schedule +ccn-i18n-calendar-tabcontrol-tabCalendar=Calendar +ccn-i18n-calendar-tabcontrol-tabCollection=Collection +ccn-i18n-calendar-tabcontrol-tabDisplay=Display + +ccn-i18n-event-header=Edit Event +ccn-i18n-event-title=Title +ccn-i18n-event-description=Description +ccn-i18n-event-collection=Collection +ccn-i18n-event-startDateTime=Start Date Time +ccn-i18n-event-endDateTime=Stop Date Time +ccn-i18n-event-btnSpot=Spot +ccn-i18n-event-btnFullDay=Full day +ccn-i18n-event-loop=Event Loop +ccn-i18n-event-loop-never=Never +ccn-i18n-event-loop-day=Day +ccn-i18n-event-loop-week=Week +ccn-i18n-event-loop-month=Month +ccn-i18n-event-loop-year=Year +ccn-i18n-event-loopDay-span=Day span +ccn-i18n-event-loopWeek-span=Week span +ccn-i18n-event-loopWeek-option=Week options +ccn-i18n-event-loopMonth-span=Month span +ccn-i18n-event-loopWeek-option=Month mode +ccn-i18n-event-loopWeek-optionA=Day {0} in month +ccn-i18n-event-loopWeek-optionB=Day {0} from the end of the month +ccn-i18n-event-loopWeek-optionC=Week {0}, day {1} in month +ccn-i18n-event-loopWeek-optionD=Week {0}, day {1} from the end of the month +ccn-i18n-event-loopYear-span=Year span +ccn-i18n-event-loopStop=Event Loop Stop +ccn-i18n-event-loopStop-forever=Forever +ccn-i18n-event-loopStop-datetime=Date Time +ccn-i18n-event-loopStop-times=Times +ccn-i18n-event-timezone-title=Timezone +ccn-i18n-event-timezone-warning=The timezone of this event is not corresponding with your current timezone. You can choose a timezone option in follwing content. If you are not familar with this, please pick keep timezone. +ccn-i18n-event-timezone-keep=Keep timezone +ccn-i18n-event-timezone-replace=Use my timezone +ccn-i18n-event-strictMode-title=Strict Mode in Event Loop +ccn-i18n-event-strictMode-warning=You can choose strict mode or rough mode in following content. This is only effect on looped event. +ccn-i18n-event-strictMode-strict=Strict Mode. If ordered day is not existing, skip it. +ccn-i18n-event-strictMode-rough=Rough mode. If ordered day is not existing, choose the day closing with original day to arrange event. +ccn-i18n-event-btnSubmit=Submit +ccn-i18n-event-btnCancel=Cancel +ccn-i18n-calendar-shared-list=Shared +ccn-i18n-collection-owned-list=Owned +ccn-i18n-collection-sharing-list=Sharing target +ccn-i18n-collection-sharing-editing=Editing: + +ccn-i18n-sharedItem-sharedBy=Shared by: + +ccn-i18n-admin-tabcontrol-tabProfile=My Profile +ccn-i18n-admin-tabcontrol-tabUserList=Manager User +ccn-i18n-admin-changePassword=Change Password +ccn-i18n-admin-userList=User List +ccn-i18n-userItem-newPassword=New Password +ccn-i18n-userItem-isAdmin=Is Admin diff --git a/src/static/i18n/strings_zh-CN.properties b/src/static/i18n/strings_zh-CN.properties index 7a9d170..3017f07 100644 --- a/src/static/i18n/strings_zh-CN.properties +++ b/src/static/i18n/strings_zh-CN.properties @@ -1,115 +1,124 @@ -ccn-pageName-home=coconut-leaf - 一个轻量的自建日历系统 -ccn-pageName-calendar=coconut-leaf - 日历 -ccn-pageName-todo=coconut-leaf - 待办 -ccn-pageName-admin=coconut-leaf - 管理 -ccn-pageName-login=coconut-leaf - 登录 +ccn-i18n-pageName-home=coconut-leaf - 一个轻量的自建日历系统 +ccn-i18n-pageName-collection=coconut-leaf - 集合 +ccn-i18n-pageName-calendar=coconut-leaf - 日历 +ccn-i18n-pageName-event=coconut-leaf - 事件 +ccn-i18n-pageName-todo=coconut-leaf - 待办 +ccn-i18n-pageName-admin=coconut-leaf - 管理 +ccn-i18n-pageName-login=coconut-leaf - 登录 -ccn-header-nav-home=主页 -ccn-header-nav-calendar=日历 -ccn-header-nav-todo=待办 -ccn-header-nav-admin=管理 -ccn-header-user-login=登录 -ccn-header-user-logout=登出 -ccn-header-language=语言 +ccn-i18n-header-nav-home=主页 +ccn-i18n-header-nav-collection=集合 +ccn-i18n-header-nav-calendar=日历 +ccn-i18n-header-nav-todo=待办 +ccn-i18n-header-nav-admin=管理 +ccn-i18n-header-user-login=登录 +ccn-i18n-header-user-logout=登出 +ccn-i18n-header-language=语言 -ccn-messagebox-confirm=确认 -ccn-messagebox-title=通知 +ccn-i18n-universal-text-year=年 +ccn-i18n-universal-text-month=月 +ccn-i18n-universal-text-day=日 +ccn-i18n-universal-text-hour=时 +ccn-i18n-universal-text-minute=分 +ccn-i18n-universal-week-1=星期一 +ccn-i18n-universal-week-2=星期二 +ccn-i18n-universal-week-3=星期三 +ccn-i18n-universal-week-4=星期四 +ccn-i18n-universal-week-5=星期五 +ccn-i18n-universal-week-6=星期六 +ccn-i18n-universal-week-7=星期日 +ccn-i18n-universal-month-1=1月 +ccn-i18n-universal-month-2=2月 +ccn-i18n-universal-month-3=3月 +ccn-i18n-universal-month-4=4月 +ccn-i18n-universal-month-5=5月 +ccn-i18n-universal-month-6=6月 +ccn-i18n-universal-month-7=7月 +ccn-i18n-universal-month-8=8月 +ccn-i18n-universal-month-9=9月 +ccn-i18n-universal-month-10=10月 +ccn-i18n-universal-month-11=11月 +ccn-i18n-universal-month-12=12月 -ccn-js-fail-login=登陆失败,请检查您的用户名和密码。 -ccn-js-fail-logout=由于未知原因,登出失败,请考虑刷新页面解决问题。 -ccn-js-fail-get=一个获取操作失败了,可能是系统错误或者您的权限不足。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 -ccn-js-fail-add=一个添加操作失败了,可能是您输入的参数有误。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 -ccn-js-fail-update=一个更新操作失败了,可能是没有找到匹配的条目或者您的参数输入错误。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 -ccn-js-fail-delete=一个删除操作失败了,可能是没有找到对应条目。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 -ccn-js-success=操作成功 +ccn-i18n-messagebox-confirm=确认 +ccn-i18n-messagebox-title=通知 -ccn-home-desc=

coconut-leaf

一个轻量的自建日历系统

原本是出于yyc12345的个人使用而制作的。


欢迎提出Pull request / issue / 翻译

将他们提交到我们的GitHub项目.

本工程代码使用AGPL v3授权。

+ccn-i18n-js-fail-login=登陆失败,请检查您的用户名和密码。 +ccn-i18n-js-fail-logout=由于未知原因,登出失败,请考虑刷新页面解决问题。 +ccn-i18n-js-fail-get=一个获取操作失败了,可能是系统错误或者您的权限不足。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 +ccn-i18n-js-fail-add=一个添加操作失败了,可能是您输入的参数有误。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 +ccn-i18n-js-fail-update=一个更新操作失败了,可能是没有找到匹配的条目或者您的参数输入错误。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 +ccn-i18n-js-fail-delete=一个删除操作失败了,可能是没有找到对应条目。刷新页面可能会解决问题。请在刷新页面前备份好自己的数据。 +ccn-i18n-js-success=操作成功 -ccn-login-form-username=用户名 -ccn-login-form-password=密码 -ccn-login-form-login=登录 +ccn-i18n-home-desc=

coconut-leaf

一个轻量的自建日历系统

原本是出于yyc12345的个人使用而制作的。


欢迎提出Pull request / issue / 翻译

将他们提交到我们的GitHub项目.

本工程代码使用AGPL v3授权。

-ccn-todo-todoList=待办列表 +ccn-i18n-login-form-username=用户名 +ccn-i18n-login-form-password=密码 +ccn-i18n-login-form-login=登录 -ccn-calendar-calendar-jump=转到 -ccn-calendar-calendar-today=今天 -ccn-calendar-calendar-add=添加... -ccn-calendar-calendar-scheduleList=日程安排 -ccn-calendar-tabcontrol-tabCalendar=日历 -ccn-calendar-tabcontrol-tabShared=被共享的 -ccn-calendar-tabcontrol-tabSharing=共享给其他人 -ccn-calendar-text-year=年 -ccn-calendar-text-month=月 -ccn-calendar-text-day=日 -ccn-calendar-text-hour=时 -ccn-calendar-text-minute=分 -ccn-calendar-week-1=星期一 -ccn-calendar-week-2=星期二 -ccn-calendar-week-3=星期三 -ccn-calendar-week-4=星期四 -ccn-calendar-week-5=星期五 -ccn-calendar-week-6=星期六 -ccn-calendar-week-7=星期日 -ccn-calendar-month-1=1月 -ccn-calendar-month-2=2月 -ccn-calendar-month-3=3月 -ccn-calendar-month-4=4月 -ccn-calendar-month-5=5月 -ccn-calendar-month-6=6月 -ccn-calendar-month-7=7月 -ccn-calendar-month-8=8月 -ccn-calendar-month-9=9月 -ccn-calendar-month-10=10月 -ccn-calendar-month-11=11月 -ccn-calendar-month-12=12月 -ccn-calendar-modalEvent-header=编辑事件 -ccn-calendar-modalEvent-title=标题 -ccn-calendar-modalEvent-description=描述 -ccn-calendar-modalEvent-collection=集合 -ccn-calendar-modalEvent-startDateTime=开始时间 -ccn-calendar-modalEvent-endDateTime=结束时间 -ccn-calendar-modalEvent-btnSpot=时间点 -ccn-calendar-modalEvent-btnFullDay=全天 -ccn-calendar-modalEvent-loop=事件循环 -ccn-calendar-modalEvent-loop-never=从不 -ccn-calendar-modalEvent-loop-day=按天 -ccn-calendar-modalEvent-loop-week=按周 -ccn-calendar-modalEvent-loop-month=按月 -ccn-calendar-modalEvent-loop-year=按年 -ccn-calendar-modalEvent-loopDay-span=间隔天数 -ccn-calendar-modalEvent-loopWeek-span=间隔周数 -ccn-calendar-modalEvent-loopWeek-option=在下列这些星期上循环 -ccn-calendar-modalEvent-loopMonth-span=间隔月数 -ccn-calendar-modalEvent-loopWeek-option=月份模式 -ccn-calendar-modalEvent-loopWeek-optionA=第{0}天 -ccn-calendar-modalEvent-loopWeek-optionB=倒数第{0}天 -ccn-calendar-modalEvent-loopWeek-optionC=第{0}个星期第{1}天 -ccn-calendar-modalEvent-loopWeek-optionD=倒数第{0}个星期第{1}天 -ccn-calendar-modalEvent-loopYear-span=间隔年数 -ccn-calendar-modalEvent-loopStop=事件循环停止方式 -ccn-calendar-modalEvent-loopStop-forever=永不停止 -ccn-calendar-modalEvent-loopStop-datetime=指定时间 -ccn-calendar-modalEvent-loopStop-times=指定次数 -ccn-calendar-modalEvent-timezone-title=时区设定 -ccn-calendar-modalEvent-timezone-warning=您当前设置的事件的时区与您的时区不匹配,您可以在下面修改您对于此事件的时区选择,如果您不熟悉时区,请选择保持原有时区。 -ccn-calendar-modalEvent-timezone-keep=保持原有时区 -ccn-calendar-modalEvent-timezone-replace=使用我现在的时区 -ccn-calendar-modalEvent-strictMode-title=循环的严格与宽松 -ccn-calendar-modalEvent-strictMode-warning=允许您在严格模式与宽松模式种进行选择,此选择只对循环事件有效。 -ccn-calendar-modalEvent-strictMode-strict=严格模式,严格遵守日期要求,如果日期不存在,就不安排。 -ccn-calendar-modalEvent-strictMode-rough=宽松模式,不在意日期要求的精确性,如果日期不存在,则找到最近的符合条件的日子安排。 -ccn-calendar-modalEvent-btnSubmit=提交 -ccn-calendar-modalEvent-btnCancel=取消 -ccn-calendar-shared-list=被共享的集合 -ccn-calendar-owned-list=我的集合 -ccn-calendar-sharing-list=分享目标 -ccn-calendar-sharing-editing=正在编辑集合: -ccn-calendar-sharedItem-sharedBy=共享人: +ccn-i18n-todo-todoList=待办列表 -ccn-admin-tabcontrol-tabProfile=我的资料 -ccn-admin-tabcontrol-tabUserList=管理用户 -ccn-admin-changePassword=更改密码 -ccn-admin-userList=用户列表 -ccn-admin-userItem-newPassword=新密码 -ccn-admin-userItem-isAdmin=是管理员 +ccn-i18n-calendar-calendar-jump=转到 +ccn-i18n-calendar-calendar-today=今天 +ccn-i18n-calendar-calendar-add=添加... +ccn-i18n-calendar-calendar-scheduleList=日程安排 +ccn-i18n-calendar-tabcontrol-tabCalendar=日历 +ccn-i18n-calendar-tabcontrol-tabCollection=集合 +ccn-i18n-calendar-tabcontrol-tabDisplay=显示设置 +ccn-i18n-calendar-owned-list=我的集合 +ccn-i18n-calendar-shared-list=被共享的集合 + +ccn-i18n-collection-owned-list=我的集合 +ccn-i18n-collection-sharing-list=分享目标 +ccn-i18n-collection-sharing-editing=正在编辑集合: + +ccn-i18n-event-header=编辑事件 +ccn-i18n-event-title=标题 +ccn-i18n-event-description=描述 +ccn-i18n-event-collection=集合 +ccn-i18n-event-startDateTime=开始时间 +ccn-i18n-event-endDateTime=结束时间 +ccn-i18n-event-btnSpot=时间点 +ccn-i18n-event-btnFullDay=全天 +ccn-i18n-event-loop=事件循环 +ccn-i18n-event-loop-never=从不 +ccn-i18n-event-loop-day=按天 +ccn-i18n-event-loop-week=按周 +ccn-i18n-event-loop-month=按月 +ccn-i18n-event-loop-year=按年 +ccn-i18n-event-loopDay-span=间隔天数 +ccn-i18n-event-loopWeek-span=间隔周数 +ccn-i18n-event-loopWeek-option=在下列这些星期上循环 +ccn-i18n-event-loopMonth-span=间隔月数 +ccn-i18n-event-loopWeek-option=月份模式 +ccn-i18n-event-loopWeek-optionA=第{0}天 +ccn-i18n-event-loopWeek-optionB=倒数第{0}天 +ccn-i18n-event-loopWeek-optionC=第{0}个星期第{1}天 +ccn-i18n-event-loopWeek-optionD=倒数第{0}个星期第{1}天 +ccn-i18n-event-loopYear-span=间隔年数 +ccn-i18n-event-loopStop=事件循环停止方式 +ccn-i18n-event-loopStop-forever=永不停止 +ccn-i18n-event-loopStop-datetime=指定时间 +ccn-i18n-event-loopStop-times=指定次数 +ccn-i18n-event-timezone-title=时区设定 +ccn-i18n-event-timezone-warning=您当前设置的事件的时区与您的时区不匹配,您可以在下面修改您对于此事件的时区选择,如果您不熟悉时区,请选择保持原有时区。 +ccn-i18n-event-timezone-keep=保持原有时区 +ccn-i18n-event-timezone-replace=使用我现在的时区 +ccn-i18n-event-strictMode-title=循环的严格与宽松 +ccn-i18n-event-strictMode-warning=允许您在严格模式与宽松模式种进行选择,此选择只对循环事件有效。 +ccn-i18n-event-strictMode-strict=严格模式,严格遵守日期要求,如果日期不存在,就不安排。 +ccn-i18n-event-strictMode-rough=宽松模式,不在意日期要求的精确性,如果日期不存在,则找到最近的符合条件的日子安排。 +ccn-i18n-event-btnSubmit=提交 +ccn-i18n-event-btnCancel=取消 + +ccn-i18n-sharedItem-sharedBy=共享人: + +ccn-i18n-admin-tabcontrol-tabProfile=我的资料 +ccn-i18n-admin-tabcontrol-tabUserList=管理用户 +ccn-i18n-admin-changePassword=更改密码 +ccn-i18n-admin-userList=用户列表 + +ccn-i18n-userItem-newPassword=新密码 +ccn-i18n-userItem-isAdmin=是管理员 diff --git a/src/static/js/datetimepicker.js b/src/static/js/datetimepicker.js new file mode 100644 index 0000000..ed80719 --- /dev/null +++ b/src/static/js/datetimepicker.js @@ -0,0 +1,74 @@ +function ccn_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_datetimepicker_Sync); + + $('.datetimepicker-month').attr('min', 1) + .attr('max', 12) + .attr('step', 1) + .val(nowtime.getMonth() + 1) + .bind('propertychange', ccn_datetimepicker_Sync); + + $('.datetimepicker-day').attr('min', 1) + .attr('step', 1) + .each(function(){ + ccn_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_datetimepicker_Sync() { + var pickerIndex = $(this).attr("datetimepicker"); + ccn_datetimepicker_SyncEx(pickerIndex); +} + +function ccn_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_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_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); +} diff --git a/src/static/js/headerNav.js b/src/static/js/headerNav.js index 04f9edf..652d407 100644 --- a/src/static/js/headerNav.js +++ b/src/static/js/headerNav.js @@ -6,6 +6,7 @@ function ccn_headerNav_LoggedRefresh() { if (ccn_api_common_tokenValid()) { // logged, show all nav button and logout button $("#ccn-header-nav-home").show(); + $("#ccn-header-nav-collection").show(); $("#ccn-header-nav-calendar").show(); $("#ccn-header-nav-todo").show(); $("#ccn-header-nav-admin").show(); @@ -14,6 +15,7 @@ function ccn_headerNav_LoggedRefresh() { $("#ccn-header-user-logout").show(); } else { $("#ccn-header-nav-home").show(); + $("#ccn-header-nav-collection").hide(); $("#ccn-header-nav-calendar").hide(); $("#ccn-header-nav-todo").hide(); $("#ccn-header-nav-admin").hide(); @@ -42,7 +44,7 @@ function ccn_headerNav_BindEvents() { window.location.href = '/web/home'; return; - } else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-logout")); + } else ccn_messagebox_Show($.i18n.prop("ccn-i18n-js-fail-logout")); }); // bind burger menu diff --git a/src/static/js/i18n.js b/src/static/js/i18n.js index a2605ff..b50c353 100644 --- a/src/static/js/i18n.js +++ b/src/static/js/i18n.js @@ -5,7 +5,9 @@ var ccn_pages_enumPages = { calendar: 1, todo: 2, admin: 3, - login: 4 + login: 4, + collection: 5, + event: 6 }; var ccn_pages_currentPage = ccn_pages_enumPages.home; @@ -46,19 +48,25 @@ function ccn_i18n_ApplyLanguage() { //set title switch(ccn_pages_currentPage) { case ccn_pages_enumPages.home: - $('#ccn-pageName').html($.i18n.prop('ccn-pageName-home')); + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-home')); break; case ccn_pages_enumPages.calendar: - $('#ccn-pageName').html($.i18n.prop('ccn-pageName-calendar')); + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-calendar')); break; case ccn_pages_enumPages.todo: - $('#ccn-pageName').html($.i18n.prop('ccn-pageName-todo')); + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-todo')); break; case ccn_pages_enumPages.admin: - $('#ccn-pageName').html($.i18n.prop('ccn-pageName-admin')); + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-admin')); break; case ccn_pages_enumPages.login: - $('#ccn-pageName').html($.i18n.prop('ccn-pageName-login')); + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-login')); + break; + case ccn_pages_enumPages.collection: + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-collection')); + break; + case ccn_pages_enumPages.event: + $('#ccn-pageName').html($.i18n.prop('ccn-i18n-pageName-event')); break; } } diff --git a/src/static/js/page/admin.js b/src/static/js/page/admin.js index 096f578..0017930 100644 --- a/src/static/js/page/admin.js +++ b/src/static/js/page/admin.js @@ -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 diff --git a/src/static/js/page/calendar.js b/src/static/js/page/calendar.js index 0d32d84..360889c 100644 --- a/src/static/js/page/calendar.js +++ b/src/static/js/page/calendar.js @@ -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(); + } +} diff --git a/src/static/js/page/collection.js b/src/static/js/page/collection.js new file mode 100644 index 0000000..7927ed9 --- /dev/null +++ b/src/static/js/page/collection.js @@ -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; + } +} + diff --git a/src/static/js/page/event.js b/src/static/js/page/event.js new file mode 100644 index 0000000..52546c3 --- /dev/null +++ b/src/static/js/page/event.js @@ -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() { + +} diff --git a/src/static/js/page/login.js b/src/static/js/page/login.js index 494898c..004c7f8 100644 --- a/src/static/js/page/login.js +++ b/src/static/js/page/login.js @@ -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"); diff --git a/src/static/js/page/todo.js b/src/static/js/page/todo.js index bc70b3b..e9ca5ec 100644 --- a/src/static/js/page/todo.js +++ b/src/static/js/page/todo.js @@ -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); } diff --git a/src/static/js/template.js b/src/static/js/template.js index bc25458..cb8df2b 100644 --- a/src/static/js/template.js +++ b/src/static/js/template.js @@ -4,7 +4,8 @@ var ccn_template_calendarItem = undefined; var ccn_template_scheduleItem = undefined; var ccn_template_ownedItem = undefined; var ccn_template_sharingItem = undefined; -var ccn_template_sharedItem = undefined; +var ccn_template_displayOwnedItem = undefined; +var ccn_template_displaySharedItem = undefined; var ccn_template_userItem = undefined; var ccn_template_todoItem = undefined; @@ -47,27 +48,19 @@ function ccn_template_Load() { } }); $.ajax({ - url: $("#jsrender-tmpl-ownedItem").attr('src'), + url: $("#jsrender-tmpl-displayOwnedItem").attr('src'), type: "GET", async: false, success: function (data) { - ccn_template_ownedItem = $.templates(data); + ccn_template_displayOwnedItem = $.templates(data); } }); $.ajax({ - url: $("#jsrender-tmpl-sharingItem").attr('src'), + url: $("#jsrender-tmpl-displaySharedItem").attr('src'), type: "GET", async: false, success: function (data) { - ccn_template_sharingItem = $.templates(data); - } - }); - $.ajax({ - url: $("#jsrender-tmpl-sharedItem").attr('src'), - type: "GET", - async: false, - success: function (data) { - ccn_template_sharedItem = $.templates(data); + ccn_template_displaySharedItem = $.templates(data); } }); break; @@ -93,5 +86,24 @@ function ccn_template_Load() { break; case ccn_pages_enumPages.login: break; + case ccn_pages_enumPages.collection: + $.ajax({ + url: $("#jsrender-tmpl-ownedItem").attr('src'), + type: "GET", + async: false, + success: function (data) { + ccn_template_ownedItem = $.templates(data); + } + }); + $.ajax({ + url: $("#jsrender-tmpl-sharingItem").attr('src'), + type: "GET", + async: false, + success: function (data) { + ccn_template_sharingItem = $.templates(data); + } + }); + case ccn_pages_enumPages.event: + break; } } \ No newline at end of file diff --git a/src/static/tmpl/calendarItem.tmpl b/src/static/tmpl/calendarItem.tmpl index a925c4e..d03f7af 100644 --- a/src/static/tmpl/calendarItem.tmpl +++ b/src/static/tmpl/calendarItem.tmpl @@ -1,10 +1,10 @@ {{for start=0 end=6 step=1 itemVar="~row"}}
{{for start=0 end=7 step=1 itemVar="~column"}} -
-

 

-

 

-

 

+
+

 

+

 

+

 

{{/for}}
diff --git a/src/static/tmpl/displayOwnedItem.tmpl b/src/static/tmpl/displayOwnedItem.tmpl new file mode 100644 index 0000000..85e22df --- /dev/null +++ b/src/static/tmpl/displayOwnedItem.tmpl @@ -0,0 +1,12 @@ +
+
+

{{>name}}

+
+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/src/static/tmpl/displaySharedItem.tmpl b/src/static/tmpl/displaySharedItem.tmpl new file mode 100644 index 0000000..26a1f63 --- /dev/null +++ b/src/static/tmpl/displaySharedItem.tmpl @@ -0,0 +1,16 @@ +
+
+ {{>name}} +

+ + {{>username}} +

+
+ +
+ +
+
+ +
+
\ No newline at end of file diff --git a/src/static/tmpl/headerNav.tmpl b/src/static/tmpl/headerNav.tmpl index 87d67d4..195bef4 100644 --- a/src/static/tmpl/headerNav.tmpl +++ b/src/static/tmpl/headerNav.tmpl @@ -14,22 +14,23 @@