nightly commit
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
// the api use bool to return status: fail: return false, true: return data(including true and false)
|
||||
// the api use other type to return data: fail: return undefined, true: return data(if the returned value have change be null, return undefined instaed).
|
||||
|
||||
// var cached_salt = undefined
|
||||
|
||||
/*
|
||||
function cnn_api_common_salt(_username) {
|
||||
function ccn_api_common_salt(_username) {
|
||||
// true or false
|
||||
// gotten salt store in cached_salt.
|
||||
var gotten_data = undefined;
|
||||
@@ -23,7 +26,7 @@ function cnn_api_common_salt(_username) {
|
||||
} else return false;
|
||||
}
|
||||
|
||||
function cnn_api_common_login(_username, password) {
|
||||
function ccn_api_common_login(_username, password) {
|
||||
// return true or false, token is managed by this js file self.
|
||||
// if cached_salt is undefined, return false directly
|
||||
if (typeof(cached_salt) == undefined) return false;
|
||||
@@ -51,7 +54,7 @@ function cnn_api_common_login(_username, password) {
|
||||
|
||||
// ====================================================== common
|
||||
|
||||
function cnn_api_common_webLogin(_username, password) {
|
||||
function ccn_api_common_webLogin(_username, password) {
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
url: '/api/common/webLogin',
|
||||
@@ -71,7 +74,7 @@ function cnn_api_common_webLogin(_username, password) {
|
||||
} else return false;
|
||||
}
|
||||
|
||||
function cnn_api_common_logout() {
|
||||
function ccn_api_common_logout() {
|
||||
// return true or false
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
@@ -86,13 +89,13 @@ function cnn_api_common_logout() {
|
||||
}
|
||||
});
|
||||
|
||||
if (IsResponseOK(gotten_data)) {
|
||||
if (IsResponseOK(gotten_data) && gotten_data['data']) {
|
||||
SetApiToken('');
|
||||
return true;
|
||||
} return false;
|
||||
}
|
||||
|
||||
function cnn_api_common_tokenValid() {
|
||||
function ccn_api_common_tokenValid() {
|
||||
// get from local database first, then judge it via post
|
||||
// return true or false
|
||||
var gotten_token = GetApiToken();
|
||||
@@ -111,7 +114,7 @@ function cnn_api_common_tokenValid() {
|
||||
}
|
||||
});
|
||||
|
||||
if (IsResponseOK(gotten_data)) return true;
|
||||
if (IsResponseOK(gotten_data) && gotten_data['data']) return true;
|
||||
else {
|
||||
SetApiToken('');
|
||||
return false;
|
||||
@@ -130,7 +133,7 @@ function cnn_api_common_tokenValid() {
|
||||
|
||||
// ====================================================== todo
|
||||
|
||||
function cnn_api_todo_getFull() {
|
||||
function ccn_api_todo_getFull() {
|
||||
// return data or undefined
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
@@ -149,7 +152,7 @@ function cnn_api_todo_getFull() {
|
||||
else return undefined;
|
||||
}
|
||||
|
||||
function cnn_api_todo_add() {
|
||||
function ccn_api_todo_add() {
|
||||
// return data or undefined
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
@@ -168,7 +171,7 @@ function cnn_api_todo_add() {
|
||||
else return undefined;
|
||||
}
|
||||
|
||||
function cnn_api_todo_update(_uuid, _data, _lastChange) {
|
||||
function ccn_api_todo_update(_uuid, _data, _lastChange) {
|
||||
// return data or undefined
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
@@ -190,7 +193,7 @@ function cnn_api_todo_update(_uuid, _data, _lastChange) {
|
||||
else return undefined;
|
||||
}
|
||||
|
||||
function cnn_api_todo_delete(_uuid, _lastChange) {
|
||||
function ccn_api_todo_delete(_uuid, _lastChange) {
|
||||
// return true or false
|
||||
var gotten_data = undefined;
|
||||
$.ajax({
|
||||
@@ -207,7 +210,7 @@ function cnn_api_todo_delete(_uuid, _lastChange) {
|
||||
}
|
||||
});
|
||||
|
||||
return IsResponseOK(gotten_data);
|
||||
return (IsResponseOK(gotten_data) && gotten_data['data']);
|
||||
}
|
||||
|
||||
// ====================================================== admin
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
function cnn_headerNav_Insert() {
|
||||
function ccn_headerNav_Insert() {
|
||||
$('body').prepend(ccn_template_headerNav.render());
|
||||
}
|
||||
|
||||
function cnn_headerNav_LoggedRefresh() {
|
||||
if (cnn_api_common_tokenValid()) {
|
||||
function ccn_headerNav_LoggedRefresh() {
|
||||
if (ccn_api_common_tokenValid()) {
|
||||
// logged, show all nav button and logout button
|
||||
$("#cnn-header-nav-home").show();
|
||||
$("#cnn-header-nav-calendar").show();
|
||||
$("#cnn-header-nav-todo").show();
|
||||
$("#cnn-header-nav-admin").show();
|
||||
$("#ccn-header-nav-home").show();
|
||||
$("#ccn-header-nav-calendar").show();
|
||||
$("#ccn-header-nav-todo").show();
|
||||
$("#ccn-header-nav-admin").show();
|
||||
|
||||
$("#cnn-header-user-login").hide();
|
||||
$("#cnn-header-user-logout").show();
|
||||
$("#ccn-header-user-login").hide();
|
||||
$("#ccn-header-user-logout").show();
|
||||
} else {
|
||||
$("#cnn-header-nav-home").show();
|
||||
$("#cnn-header-nav-calendar").hide();
|
||||
$("#cnn-header-nav-todo").hide();
|
||||
$("#cnn-header-nav-admin").hide();
|
||||
$("#ccn-header-nav-home").show();
|
||||
$("#ccn-header-nav-calendar").hide();
|
||||
$("#ccn-header-nav-todo").hide();
|
||||
$("#ccn-header-nav-admin").hide();
|
||||
|
||||
$("#cnn-header-user-login").show();
|
||||
$("#cnn-header-user-logout").hide();
|
||||
$("#ccn-header-user-login").show();
|
||||
$("#ccn-header-user-logout").hide();
|
||||
}
|
||||
}
|
||||
|
||||
// bind language process and internal process function such as logout and expand menu
|
||||
function cnn_headerNav_BindEvents() {
|
||||
function ccn_headerNav_BindEvents() {
|
||||
// bind function
|
||||
$("#cnn-header-language > *").each(function(){
|
||||
$("#ccn-header-language > *").each(function(){
|
||||
$(this).click(function(){
|
||||
ccn_i18n_ChangeLanguage($(this).attr("language"));
|
||||
ccn_i18n_ApplyLanguage();
|
||||
@@ -34,14 +34,14 @@ function cnn_headerNav_BindEvents() {
|
||||
});
|
||||
|
||||
// bind logout
|
||||
$("#cnn-header-user-logout").click(function() {
|
||||
if (cnn_api_common_logout()) {
|
||||
$("#ccn-header-user-logout").click(function() {
|
||||
if (ccn_api_common_logout()) {
|
||||
// ok, logout
|
||||
// jump into home page again
|
||||
window.location.href = '/web/home';
|
||||
return;
|
||||
|
||||
} else alert($.i18n.prop("ccn-js-failToLogout"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-logout"));
|
||||
});
|
||||
|
||||
// bind burger menu
|
||||
|
||||
19
src/static/js/messagebox.js
Normal file
19
src/static/js/messagebox.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function ccn_messagebox_Insert() {
|
||||
$('body').append(ccn_template_messagebox.render());
|
||||
}
|
||||
|
||||
function ccn_messagebox_Show(/*title,*/ info) {
|
||||
//$('#ccn-messagebox-title').text(title);
|
||||
$('#ccn-messagebox-body').text(info);
|
||||
|
||||
$('#ccn-messagebox-modal').addClass('is-active');
|
||||
}
|
||||
|
||||
function ccn_messagebox_BindEvent() {
|
||||
$('#ccn-messagebox-btnClose').click(ccn_messagebox_Hide);
|
||||
$('#ccn-messagebox-btnConfirm').click(ccn_messagebox_Hide);
|
||||
}
|
||||
|
||||
function ccn_messagebox_Hide() {
|
||||
$('#ccn-messagebox-modal').removeClass('is-active');
|
||||
}
|
||||
@@ -5,9 +5,13 @@ $(document).ready(function() {
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
cnn_headerNav_Insert();
|
||||
cnn_headerNav_BindEvents();
|
||||
cnn_headerNav_LoggedRefresh();
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_ApplyLanguage();
|
||||
|
||||
@@ -5,10 +5,14 @@ $(document).ready(function() {
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
cnn_headerNav_Insert();
|
||||
cnn_headerNav_BindEvents();
|
||||
cnn_headerNav_LoggedRefresh();
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// process calendar it self
|
||||
ccn_calendar_LoadCalendarBody();
|
||||
|
||||
|
||||
@@ -5,10 +5,14 @@ $(document).ready(function() {
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
cnn_headerNav_Insert();
|
||||
cnn_headerNav_BindEvents();
|
||||
cnn_headerNav_LoggedRefresh();
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_ApplyLanguage();
|
||||
});
|
||||
@@ -5,9 +5,13 @@ $(document).ready(function() {
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
cnn_headerNav_Insert();
|
||||
cnn_headerNav_BindEvents();
|
||||
cnn_headerNav_LoggedRefresh();
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_ApplyLanguage();
|
||||
@@ -28,23 +32,23 @@ function ccn_login_startLogin() {
|
||||
|
||||
/*
|
||||
// try get salt
|
||||
if (cnn_api_common_salt(username)) {
|
||||
if (ccn_api_common_salt(username)) {
|
||||
// continue login
|
||||
if (cnn_api_common_login(username, password)) {
|
||||
if (ccn_api_common_login(username, password)) {
|
||||
// ok, logged
|
||||
// jump into home page again
|
||||
window.location.href = '/web/home';
|
||||
|
||||
} else alert($.i18n.prop("ccn-js-failToLogin"));
|
||||
} else alert($.i18n.prop("ccn-js-failToLogin"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
*/
|
||||
if (cnn_api_common_webLogin(username, password)) {
|
||||
if (ccn_api_common_webLogin(username, password)) {
|
||||
// ok, logged
|
||||
// jump into home page again
|
||||
window.location.href = '/web/home';
|
||||
return;
|
||||
|
||||
} else alert($.i18n.prop("ccn-js-failToLogin"));
|
||||
} else ccn_messagebox_Show($.i18n.prop("ccn-js-fail-login"));
|
||||
|
||||
// retore ui
|
||||
$("#ccn-login-form-login").removeAttr("disabled");
|
||||
|
||||
@@ -7,9 +7,13 @@ $(document).ready(function() {
|
||||
ccn_template_Load();
|
||||
|
||||
// nav process
|
||||
cnn_headerNav_Insert();
|
||||
cnn_headerNav_BindEvents();
|
||||
cnn_headerNav_LoggedRefresh();
|
||||
ccn_headerNav_Insert();
|
||||
ccn_headerNav_BindEvents();
|
||||
ccn_headerNav_LoggedRefresh();
|
||||
|
||||
// messagebox process
|
||||
ccn_messagebox_Insert();
|
||||
ccn_messagebox_BindEvent();
|
||||
|
||||
// apply i18n
|
||||
ccn_i18n_ApplyLanguage();
|
||||
@@ -26,7 +30,7 @@ function ccn_todo_RefreshCacheList() {
|
||||
// clean list cache first
|
||||
ccn_todo_todoListCache = new Array();
|
||||
|
||||
var result = cnn_api_todo_getFull();
|
||||
var result = ccn_api_todo_getFull();
|
||||
if(typeof(result) != 'undefined') {
|
||||
for(var index in result) {
|
||||
ccn_todo_todoListCache[result[index][0]] = result[index];
|
||||
@@ -96,10 +100,10 @@ function ccn_todo_Refresh() {
|
||||
}
|
||||
|
||||
function ccn_todo_Add() {
|
||||
var result = cnn_api_todo_add();
|
||||
var result = ccn_api_todo_add();
|
||||
if (typeof(result) == 'undefined') {
|
||||
// fail
|
||||
alert($.i18n.prop("ccn-js-failToOperate"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-operate"));
|
||||
} else {
|
||||
// add into cache
|
||||
ccn_todo_todoListCache[result[0]] = result;
|
||||
@@ -138,14 +142,14 @@ function ccn_todo_ItemEdit() {
|
||||
function ccn_todo_ItemDelete() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var result = cnn_api_todo_delete(
|
||||
var result = ccn_api_todo_delete(
|
||||
uuid,
|
||||
ccn_todo_todoListCache[uuid][3]
|
||||
);
|
||||
|
||||
if(typeof(result) == 'undefined') {
|
||||
// fail
|
||||
alert($.i18n.prop("ccn-js-failToOperate"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-operate"));
|
||||
} else {
|
||||
// remove body
|
||||
$("#ccn-todo-todoItem-" + uuid).remove();
|
||||
@@ -156,7 +160,7 @@ function ccn_todo_ItemUpdate() {
|
||||
var uuid = $(this).attr("uuid");
|
||||
|
||||
var newData = $("#ccn-todo-todoItem-textarea-" + uuid).val();
|
||||
var result = cnn_api_todo_update(
|
||||
var result = ccn_api_todo_update(
|
||||
uuid,
|
||||
newData,
|
||||
ccn_todo_todoListCache[uuid][3]
|
||||
@@ -164,7 +168,7 @@ function ccn_todo_ItemUpdate() {
|
||||
|
||||
if (typeof(result) == 'undefined') {
|
||||
// fail
|
||||
alert($.i18n.prop("ccn-js-failToOperate"));
|
||||
ccn_messagebox_Show($.i18n.prop("ccn-js-fail-operate"));
|
||||
} else {
|
||||
// safely update data & lastChanged and control
|
||||
ccn_todo_todoListCache[uuid][2] = newData;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var ccn_template_headerNav = undefined;
|
||||
var ccn_template_messagebox = undefined;
|
||||
var ccn_template_calendarItem = undefined;
|
||||
var ccn_template_scheduleItem = undefined;
|
||||
var ccn_template_userItem = undefined;
|
||||
@@ -13,6 +14,14 @@ function ccn_template_Load() {
|
||||
ccn_template_headerNav = $.templates(data);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-messagebox").attr('src'),
|
||||
type: "GET",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
ccn_template_messagebox = $.templates(data);
|
||||
}
|
||||
});
|
||||
|
||||
switch(ccn_pages_currentPage) {
|
||||
case ccn_pages_enumPages.home:
|
||||
|
||||
Reference in New Issue
Block a user