first commit
This commit is contained in:
3
src/static/js/api.js
Normal file
3
src/static/js/api.js
Normal file
@@ -0,0 +1,3 @@
|
||||
function cnn_api_tokenValid() {
|
||||
return true;
|
||||
}
|
||||
11
src/static/js/headerNav.js
Normal file
11
src/static/js/headerNav.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function cnn_headerNav_Insert() {
|
||||
$.ajax({
|
||||
url: $("#jsrender-tmpl-headerNav").attr('src'),
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
var tmpl = $.templates(data);
|
||||
$('body').prepend(tmpl.render());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
55
src/static/js/i18n.js
Normal file
55
src/static/js/i18n.js
Normal file
@@ -0,0 +1,55 @@
|
||||
var ccn_i18n_i18nSupported = ['en-US', 'zh-CN'];
|
||||
var ccn_i18n_currentLanguage = 'en-US';
|
||||
|
||||
// judge current language
|
||||
ccn_i18n_currentLanguage = ccn_localstorageAssist_Get('ccn-i18n', 'en-US');
|
||||
if (ccn_i18n_i18nSupported.indexOf(ccn_i18n_currentLanguage) == -1){
|
||||
ccn_localstorageAssist_Set('ccn-i18n', 'en-US');
|
||||
ccn_i18n_currentLanguage = 'en-US';
|
||||
}
|
||||
|
||||
function ccn_i18n_ChangeLanguage(newLang) {
|
||||
if (ccn_i18n_i18nSupported.indexOf(newLang) == -1) return false;
|
||||
ccn_i18n_currentLanguage = newLang;
|
||||
ccn_localstorageAssist_Set('ccn-i18n', newLang);
|
||||
return true;
|
||||
}
|
||||
|
||||
function ccn_i18n_ApplyLanguage() {
|
||||
$.i18n.properties({
|
||||
name: 'strings_' + ccn_i18n_currentLanguage,
|
||||
path: 'i18n/',
|
||||
mode: 'map',
|
||||
language: ccn_i18n_currentLanguage,
|
||||
callback: function() {
|
||||
//set usual block
|
||||
var cache = $(".ccn-i18n");
|
||||
cache.each(function() {
|
||||
$(this).html($.i18n.prop($(this).attr('name')));
|
||||
});
|
||||
|
||||
//set unusual block
|
||||
//set title
|
||||
switch(ccn_pages_currentPage) {
|
||||
case ccn_pages_enumPages.home:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-home'))
|
||||
break;
|
||||
case ccn_pages_enumPages.user:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-user'))
|
||||
break;
|
||||
case ccn_pages_enumPages.userinfo:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-userinfo'))
|
||||
break;
|
||||
case ccn_pages_enumPages.map:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-map'))
|
||||
break;
|
||||
case ccn_pages_enumPages.mapinfo:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-mapinfo'))
|
||||
break;
|
||||
case ccn_pages_enumPages.about:
|
||||
$('#ccn-pageName').html($.i18n.prop('ccn-pageName-about'))
|
||||
break;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
11
src/static/js/localStorageAssist.js
Normal file
11
src/static/js/localStorageAssist.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function ccn_localstorageAssist_Get(index, defaultValue) {
|
||||
var cache = localStorage.getItem(index);
|
||||
if (cache == null) {
|
||||
ccn_localstorageAssist_Set(index, defaultValue);
|
||||
return defaultValue;
|
||||
} else return cache;
|
||||
}
|
||||
|
||||
function ccn_localstorageAssist_Set(index, value) {
|
||||
localStorage.setItem(index, value);
|
||||
}
|
||||
0
src/static/js/page/admin.js
Normal file
0
src/static/js/page/admin.js
Normal file
0
src/static/js/page/calendar.js
Normal file
0
src/static/js/page/calendar.js
Normal file
4
src/static/js/page/home.js
Normal file
4
src/static/js/page/home.js
Normal file
@@ -0,0 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
// insert nav first
|
||||
cnn_headerNav_Insert();
|
||||
});
|
||||
0
src/static/js/page/login.js
Normal file
0
src/static/js/page/login.js
Normal file
0
src/static/js/page/todo.js
Normal file
0
src/static/js/page/todo.js
Normal file
Reference in New Issue
Block a user