Commit 058280d6 by Masaru Abe

リファクタリング

parent f7a6fa25
......@@ -2702,6 +2702,9 @@ COMMON.convertToDate = function(input) {
var strTemp = input;
var nIndex;
dateResult = new Date();
try {
// Get year
nIndex = strTemp.indexOf("-");
nYear = Number(strTemp.substr(0, nIndex));
......@@ -2726,14 +2729,19 @@ COMMON.convertToDate = function(input) {
nIndex = strTemp.indexOf(".");
nSecond = Number(strTemp.substr(0, nIndex));
dateResult = new Date();
dateResult.setYear(nYear);
dateResult.setMonth(nMonth-1);
dateResult.setDate(nDay);
dateResult.setHours(nHour);
dateResult.setMinutes(nMinute);
dateResult.setSeconds(nSecond);
} catch(e) {
//
}
return dateResult;
};
/*
......
......@@ -99,7 +99,7 @@ I18N.loadLanguage = function(lang) {
I18N.replaceText(jsonLangData);
// 言語設定、言語データをストレージにキャッシュしておく
storeCurrentLanguage(lang, jsonLangData);
I18N.storeCurrentLanguage(lang, jsonLangData);
},
error: function(xhr, txtStatus, errorThrown) {
var error = 'Could not load a language file ' + langfile + '. please check it.';
......@@ -118,7 +118,7 @@ I18N.replaceText = function(jsonLangData) {
var obj = $('.lang:eq(' + i + ')');
var langId = obj.attr('lang');
if(langId) {
var langText = getLangText(jsonLangData, langId);
var langText = I18N.getLangText(jsonLangData, langId);
var tn = obj.get()[0].localName;
if(tn == 'input') {
if(obj.attr('type') == 'button' || obj.attr('type') == 'submit') {
......@@ -153,14 +153,14 @@ I18N.i18nText = function(key) {
var value = storage.getItem(I18N.avwsys_storagekey);
if(value) {
var json = JSON.parse(value);
return getLangText(json, key);
return I18N.getLangText(json, key);
}
}
return "undefined";
};
/* 言語データのキー値から文字列を取得 */
function getLangText(jsonLangData, key) {
I18N.getLangText = function(jsonLangData, key) {
if(jsonLangData) {
var text = jsonLangData[key];
return text;
......@@ -169,7 +169,7 @@ function getLangText(jsonLangData, key) {
};
/* 言語データの切り替え */
function changeLanguage(lang) {
I18N.changeLanguage = function(lang) {
// 言語の切替を行った場合のみ選択言語をストアする
var storage = window.localStorage;
......@@ -182,7 +182,7 @@ function changeLanguage(lang) {
};
/* 設定言語の保存 */
function storeCurrentLanguage(lang, langData) {
I18N.storeCurrentLanguage = function(lang, langData) {
var ss = window.sessionStorage;
if(ss) {
// language data
......@@ -192,7 +192,7 @@ function storeCurrentLanguage(lang, langData) {
}
};
/* 設定言語の取得 */
function getCurrentLanguage() {
I18N.getCurrentLanguage = function() {
var lang;
var storage = window.sessionStorage;
if(storage) {
......@@ -203,3 +203,4 @@ function getCurrentLanguage() {
}
return lang;
};

var messageLevel = {};
//名前空間用のオブジェクトを用意する
var LIMIT_ACCESS_CONTENT = {};
function checkLimitContent(contentId, funcOk, funcCancel, isNotUnlockScreen) {
LIMIT_ACCESS_CONTENT.messageLevel = {};
var levelContent = parseInt(messageLevel[contentId].alertMessageLevel);
LIMIT_ACCESS_CONTENT.checkLimitContent = function(contentId, funcOk, funcCancel, isNotUnlockScreen) {
var levelContent = parseInt(LIMIT_ACCESS_CONTENT.messageLevel[contentId].alertMessageLevel);
if (levelContent == 1) {
if ($('#limit_level1').length <= 0) {
......@@ -31,7 +34,7 @@ function checkLimitContent(contentId, funcOk, funcCancel, isNotUnlockScreen) {
COMMON.lockLayout();
$('#limit_level1 .message').html(messageLevel[contentId].alertMessage);
$('#limit_level1 .message').html(LIMIT_ACCESS_CONTENT.messageLevel[contentId].alertMessage);
$('#limit_level1').show().center();
$('#limit_level1 .deletebtn .ok').unbind('click').click(
function () {
......
......@@ -260,7 +260,7 @@ CONTENTSEARCH.renderContent = function(id, text, division, type, order, from, to
//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type to array to manage.
// save alert message level
messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
LIMIT_ACCESS_CONTENT.messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
//Check if user has read this content or not.
CONTENTSEARCH.checkUserHasReadContent(post.contentId, post.resourceVersion, post.metaVersion);
......@@ -304,7 +304,7 @@ CONTENTSEARCH.renderContent = function(id, text, division, type, order, from, to
//Toggle scroll to top Control
CONTENTSEARCH.handleBackToTop();
//changeLanguage(ClientData.userInfo_language());
//I18N.changeLanguage(ClientData.userInfo_language());
I18N.i18nReplaceText();
});
};
......@@ -335,7 +335,7 @@ CONTENTSEARCH.handleBackToTop = function(){
//Handle language
CONTENTSEARCH.handleLanguage = function(){
if (getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko)
if (I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko)
{
$('#control-sort-titlekana').css('display','none');
$('#separate').css('display','none');
......@@ -738,7 +738,7 @@ CONTENTSEARCH.readSubmenuFunction = function(e){
}
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
CONTENTSEARCH.readSubmenuFunction_callback(contentId);
......@@ -1286,7 +1286,7 @@ CONTENTSEARCH.refreshGrid = function(){
//format text display more record
CONTENTSEARCH.formatDisplayMoreRecord = function(){
I18N.i18nReplaceText();
//changeLanguage(ClientData.userInfo_language());
//I18N.changeLanguage(ClientData.userInfo_language());
$('#control-nextrecord').html(AVWEB.format(I18N.i18nText('dspViewMore'), CONTENTSEARCH.returnNumberDispRecordForList()));
};
......@@ -1321,7 +1321,7 @@ CONTENTSEARCH.displayResultNoRecord = function(){
$('#control-nextrecord').css('visibility','hidden');
$('.control_sort_on').hide();
$('.control_sort_off').show();
if(getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko){
if(I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko){
/*$('#control-sort-titlekana').hide();*/
$('#separate').hide();
$('#control-sort-titlekana').hide();
......@@ -1331,7 +1331,7 @@ CONTENTSEARCH.displayResultNoRecord = function(){
CONTENTSEARCH.enableSort = function(){
$('.control_sort_on').show();
$('.control_sort_off').hide();
if(getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko){
if(I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko){
$('#control-sort-titlekana').hide();
$('#separate').hide();
}
......@@ -1373,7 +1373,7 @@ CONTENTSEARCH.showContentShareDlgFunction = function(e) {
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
SHARE.contentId = contentId;
......
......@@ -130,7 +130,7 @@ Event groups [start]
DETAIL.contentdetail_dspRead_Click = function(e) {
e.preventDefault();
var outputId = ClientData.contentInfo_contentId();
checkLimitContent(outputId,
LIMIT_ACCESS_CONTENT.checkLimitContent(outputId,
function () {
DETAIL.contentdetail_dspRead_Click_callback(outputId);
},
......
......@@ -274,7 +274,7 @@ HEADER.homeClickFunction = function(){
//Change Language Japanese function
HEADER.changeLanguageJa = function(){
changeLanguage(COMMON.Consts.ConstLanguage_Ja);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_Ja);
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_Ja);
//$('#control-sort-titlekana').css('display','inline-block');
//$('#separate').css('display','inline-block');
......@@ -287,7 +287,7 @@ HEADER.changeLanguageJa = function(){
//Change Language English functions
HEADER.changeLanguageEn = function(){
changeLanguage(COMMON.Consts.ConstLanguage_En);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_En);
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_En);
//$('#control-sort-titlekana').css('display','none');
//$('#separate').css('display','none');
......@@ -300,7 +300,7 @@ HEADER.changeLanguageEn = function(){
//Change Language English function
HEADER.changeLanguageKo = function(){
changeLanguage(COMMON.Consts.ConstLanguage_Ko);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_Ko);
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_Ko);
//$('#control-sort-titlekana').css('display','none');
//$('#separate').css('display','none');
......
......@@ -187,7 +187,7 @@ HISTORY.renderContent = function(id, text, division, type, order, from, to, cate
var viewdate = HISTORY.renderViewDate(post.contentId);
// save alert message level
messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
LIMIT_ACCESS_CONTENT.messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
if (viewdate != null && viewdate != 'undefined' && viewdate != '') {
......@@ -241,7 +241,7 @@ HISTORY.renderContent = function(id, text, division, type, order, from, to, cate
HISTORY.handleLanguage = function(){
//if(ClientData.userInfo_language() == COMMON.Consts.ConstLanguage_En || ClientData.userInfo_language() == COMMON.Consts.ConstLanguage_Ko)
if (getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko)
if (I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko)
{
$('#control-sort-titlekana').css('display','none');
$('#control-sort-titlekana-off').css('display','none');
......@@ -591,7 +591,7 @@ HISTORY.readSubmenuFunction = function(e){
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
HISTORY.readSubmenuFunction_callback(contentId);
......@@ -1478,7 +1478,7 @@ HISTORY.showContentShareDlgFunction = function(e) {
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
SHARE.contentId = contentId;
......
......@@ -459,7 +459,7 @@ HOME.canvasClickFunction = function(e) {
var contentId = $(this).attr('id');
var outputId = contentId.substring(17);
checkLimitContent(outputId,
LIMIT_ACCESS_CONTENT.checkLimitContent(outputId,
function(){
HOME.canvasClickFunction_callback(outputId);
},
......@@ -1213,7 +1213,7 @@ HOME.readSubmenuFunction = function(e) {
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
HOME.readSubmenuFunction_callback(contentId);
......@@ -1553,7 +1553,7 @@ HOME.sortByReleaseDateFunction = function() {
//Handle language
HOME.handleLanguage = function() {
if (getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko) {
if (I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_En || I18N.getCurrentLanguage() == COMMON.Consts.ConstLanguage_Ko) {
$('#control-sort-titlekana').css('display', 'none');
$('#separate').css('display', 'none');
$('#titlekana-sorttype').html('');
......@@ -1675,7 +1675,7 @@ HOME.renderContent = function(id, text, division, type, order, from, to, cateid,
//End Function : No.12 -- Editor : Le Long -- Date : 07/31/2013 -- Summary : Assign content type to array to manage.
// save alert message level
messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
LIMIT_ACCESS_CONTENT.messageLevel[post.contentId] = { alertMessageLevel:post.alertMessageLevel, alertMessage:post.alertMessage};
//Check if user has read this content or not.
HOME.checkUserHasReadContent(post.contentId, post.resourceVersion, post.metaVersion);
......@@ -1721,7 +1721,7 @@ HOME.renderContent = function(id, text, division, type, order, from, to, cateid,
//Toggle scroll to top Control
HOME.handleBackToTop();
//changeLanguage(ClientData.userInfo_language());
//I18N.changeLanguage(ClientData.userInfo_language());
I18N.i18nReplaceText();
});
};
......@@ -2157,7 +2157,7 @@ HOME.refreshGrid = function() {
//format text display more record
HOME.formatDisplayMoreRecord = function() {
//changeLanguage(ClientData.userInfo_language());
//I18N.changeLanguage(ClientData.userInfo_language());
I18N.i18nReplaceText();
if (HOME.isShowBookShelf) {
......@@ -2560,7 +2560,7 @@ HOME.showContentShareDlgFunction = function(e) {
var contentId = $(this).attr('contentid');
// check limit of content
checkLimitContent(contentId,
LIMIT_ACCESS_CONTENT.checkLimitContent(contentId,
function()
{
SHARE.contentId = contentId;
......
......@@ -40,7 +40,7 @@ LOGIN.initialScreen = function() {
//check Save Login Info
LOGIN.saveLoginInfo = function() {
var lang = getCurrentLanguage();
var lang = I18N.getCurrentLanguage();
//clear session of old user
//SessionStorageUtils.clear();
......@@ -49,7 +49,7 @@ LOGIN.saveLoginInfo = function() {
//AVWEB.avwCreateUserSession();
// load language
changeLanguage(lang);
I18N.changeLanguage(lang);
// Set flag コンテンツデータチェックフラグ = true to sync local with server
ClientData.common_contentDataChkFlg(true);
......@@ -377,7 +377,7 @@ LOGIN.changePasswordProcess = function(){
//Change Language Japanese
LOGIN.changeLanguageJa = function(){
changeLanguage(COMMON.Consts.ConstLanguage_Ja);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_Ja);
document.title = I18N.i18nText('dspLogin') + ' | ' + I18N.i18nText('sysAppTitle');
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_Ja);
if (LOGIN.login_errorMessage != ""){
......@@ -387,7 +387,7 @@ LOGIN.changeLanguageJa = function(){
//Change Language Korean
LOGIN.changeLanguageKo = function(){
changeLanguage(COMMON.Consts.ConstLanguage_Ko);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_Ko);
document.title = I18N.i18nText('dspLogin') + ' | ' + I18N.i18nText('sysAppTitle');
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_Ko);
if (LOGIN.login_errorMessage != ""){
......@@ -397,7 +397,7 @@ LOGIN.changeLanguageKo = function(){
//Change Language English
LOGIN.changeLanguageEn = function(){
changeLanguage(COMMON.Consts.ConstLanguage_En);
I18N.changeLanguage(COMMON.Consts.ConstLanguage_En);
document.title = I18N.i18nText('dspLogin') + ' | ' + I18N.i18nText('sysAppTitle');
//ClientData.userInfo_language(COMMON.Consts.ConstLanguage_En);
if (LOGIN.login_errorMessage != ""){
......@@ -851,10 +851,10 @@ LOGIN.showContentViewByOpenUrl = function(strContentId) {
//Go to Conten view page
//アラート表示組み込めるか
messageLevel[data.contentData.contentId] = { alertMessageLevel:data.contentData.alertMessageLevel, alertMessage:data.contentData.alertMessage};
LIMIT_ACCESS_CONTENT.messageLevel[data.contentData.contentId] = { alertMessageLevel:data.contentData.alertMessageLevel, alertMessage:data.contentData.alertMessage};
// check limit of content
checkLimitContent(
LIMIT_ACCESS_CONTENT.checkLimitContent(
data.contentData.contentId,
function()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment