Commit 58721861 by Takumi Imai

ローディング

parent f1a599f0
...@@ -11,1318 +11,1330 @@ ...@@ -11,1318 +11,1330 @@
* *
* @since cms:1.4.3.2&1.4.3.3 web:1.0 * @since cms:1.4.3.2&1.4.3.3 web:1.0
*/ */
var COMMON = {}; var COMMON = {};
COMMON.loginCheckPageList = [CONSTANT.PAGE_NAME.DEFAULT, CONSTANT.PAGE_NAME.DASHBOARD, CONSTANT.PAGE_NAME.REPORT_LIST, CONSTANT.PAGE_NAME.REPORT_FORM, COMMON.loginCheckPageList = [
CONSTANT.PAGE_NAME.MESSAGE_DETAIL, CONSTANT.PAGE_NAME.MESSAGE_LIST, CONSTANT.PAGE_NAME.SEND_MESSAGE, CONSTANT.PAGE_NAME.SETTING, CONSTANT.PAGE_NAME.DEFAULT,
CONSTANT.PAGE_NAME.PICKUP, CONSTANT.PAGE_NAME.PDF_PRINT]; CONSTANT.PAGE_NAME.DASHBOARD,
CONSTANT.PAGE_NAME.REPORT_LIST,
COMMON.hasErrorKey = 'AVW_HASERR'; CONSTANT.PAGE_NAME.REPORT_FORM,
$(document).ready(function() { CONSTANT.PAGE_NAME.MESSAGE_DETAIL,
const checkUrl = location.href.substring(location.href.lastIndexOf('/') + 1 ,location.href.lastIndexOf(".html")); CONSTANT.PAGE_NAME.MESSAGE_LIST,
if (COMMON.loginCheckPageList.includes(checkUrl)) { CONSTANT.PAGE_NAME.SEND_MESSAGE,
if (!COMMON.checkLogin(CONSTANT.PAGE_NAME.LOGIN)){ CONSTANT.PAGE_NAME.SETTING,
return; CONSTANT.PAGE_NAME.PICKUP,
} CONSTANT.PAGE_NAME.PDF_PRINT,
} ];
})
/** COMMON.hasErrorKey = 'AVW_HASERR';
* page transition without outputting a warning message $(document).ready(function () {
* @param {*} url const checkUrl = location.href.substring(location.href.lastIndexOf('/') + 1, location.href.lastIndexOf('.html'));
*/ if (COMMON.loginCheckPageList.includes(checkUrl)) {
COMMON.avwScreenMove = function (url) { if (!COMMON.checkLogin(CONSTANT.PAGE_NAME.LOGIN)) {
COMMON.showLoading(); return;
window.onbeforeunload = null; }
window.location = url; }
}; });
/**
/** * page transition without outputting a warning message
* show loading dialog * @param {*} url
* show msg by key */
* COMMON.avwScreenMove = function (url) {
* @param {String} key COMMON.showLoading();
*/ window.onbeforeunload = null;
COMMON.showLoading = function () { window.location = url;
console.log("kdh check showLoading"); };
$('#loader').css( {
'width': $(window).width(), /**
'height': $(window).height() * show loading dialog
}); * show msg by key
document.getElementById('loader').style.display = 'block'; *
}; * @param {String} key
*/
/** COMMON.showLoading = function () {
* close loading console.log('kdh check showLoading');
*/ $('#loader').css({
COMMON.closeLoading = function () { width: $(window).width(),
setTimeout(function(){ height: $(window).height(),
document.getElementById('loader').style.display = 'none'; });
}, 1000); document.getElementById('loader').style.display = 'block';
}; };
/** /**
* show confirm modal with yes, no buttons * close loading
* @param {Object} data - Object with {title, message, confirmYes, confirmNo} */
* @param {callback} confirmCallback - The callback that handles the confirm button clicked COMMON.closeLoading = function () {
*/ setTimeout(function () {
COMMON.showConfirmModal = function (data, confirmCallback) { document.getElementById('loader').style.display = 'none';
if (data) { $('#loadingNone').show();
let title = ''; }, 1000);
if (data.title) { };
title = data.title;
} /**
$('#confirm-modal .modal-title').text(title); * show confirm modal with yes, no buttons
let message = ''; * @param {Object} data - Object with {title, message, confirmYes, confirmNo}
if (data.message) { * @param {callback} confirmCallback - The callback that handles the confirm button clicked
message = data.message; */
} COMMON.showConfirmModal = function (data, confirmCallback) {
$('#confirm-modal #msgModel').text(message); if (data) {
if (data.confirmYes) { let title = '';
$('#confirm-modal #confirmYes').text(data.confirmYes); if (data.title) {
$('#confirm-modal #confirmYes').removeClass('d-none'); title = data.title;
$('#confirm-modal #confirmYes').off('click');//remove all old click handlers }
$('#confirm-modal #confirmYes').click(function() { $('#confirm-modal .modal-title').text(title);
$('#confirm-modal .close').click(); let message = '';
if (confirmCallback) { if (data.message) {
//timeout for animation modal close message = data.message;
setTimeout(function() { }
confirmCallback(); $('#confirm-modal #msgModel').text(message);
}, 500); if (data.confirmYes) {
} $('#confirm-modal #confirmYes').text(data.confirmYes);
}); $('#confirm-modal #confirmYes').removeClass('d-none');
} else { $('#confirm-modal #confirmYes').off('click'); //remove all old click handlers
$('#confirm-modal #confirmYes').addClass('d-none'); $('#confirm-modal #confirmYes').click(function () {
} $('#confirm-modal .close').click();
if (data.confirmNo) { if (confirmCallback) {
$('#confirm-modal #confirmNo').text(data.confirmNo); //timeout for animation modal close
$('#confirm-modal #confirmNo').removeClass('d-none'); setTimeout(function () {
} else { confirmCallback();
$('#confirm-modal #confirmNo').addClass('d-none'); }, 500);
} }
} });
$('#showConfirmModalButton').click(); } else {
}; $('#confirm-modal #confirmYes').addClass('d-none');
}
/** if (data.confirmNo) {
* Show confirm modal with defaults: title, yes, no $('#confirm-modal #confirmNo').text(data.confirmNo);
* @param {string} messageCode $('#confirm-modal #confirmNo').removeClass('d-none');
* @param {callback} confirmCallback - The callback that handles the confirm button clicked } else {
* @param {Object} options - Object with {titleCode, message, confirmYesCode, confirmNoCode} $('#confirm-modal #confirmNo').addClass('d-none');
*/ }
COMMON.showConfirm = function (messageCode, confirmCallback, options = {}) { }
const defaultParams = { $('#showConfirmModalButton').click();
titleCode: 'confirmation', };
confirmYesCode: 'confirmYes',
confirmNoCode: 'confirmNo' /**
} * Show confirm modal with defaults: title, yes, no
const params = Object.assign(defaultParams, options); * @param {string} messageCode
let message = ''; * @param {callback} confirmCallback - The callback that handles the confirm button clicked
if (messageCode) { * @param {Object} options - Object with {titleCode, message, confirmYesCode, confirmNoCode}
message = I18N.i18nText(messageCode); */
if (typeof message === 'undefined') { COMMON.showConfirm = function (messageCode, confirmCallback, options = {}) {
//lang of messageCode undefined, use message or messageCode const defaultParams = {
if (params.message) { titleCode: 'confirmation',
message = params.message; confirmYesCode: 'confirmYes',
} else { confirmNoCode: 'confirmNo',
message = messageCode; };
} const params = Object.assign(defaultParams, options);
} let message = '';
} else if (params.message) { if (messageCode) {
message = params.message; message = I18N.i18nText(messageCode);
} if (typeof message === 'undefined') {
let title = I18N.i18nText(params.titleCode); //lang of messageCode undefined, use message or messageCode
if (params.title) { if (params.message) {
title = params.title; message = params.message;
} } else {
COMMON.showConfirmModal({ message = messageCode;
message: message, }
title: title, }
confirmYes: I18N.i18nText(params.confirmYesCode), } else if (params.message) {
confirmNo: I18N.i18nText(params.confirmNoCode) message = params.message;
}, confirmCallback); }
}; let title = I18N.i18nText(params.titleCode);
if (params.title) {
/** title = params.title;
* show alert message by confirm modal html }
* @param {String} messageCode COMMON.showConfirmModal(
* @param {string} titleCode {
* @param {Object} options - Data Options {message, titleCode, confirmNoCode} message: message,
*/ title: title,
COMMON.showAlert = function (messageCode, titleCode = 'error', options = {}) { confirmYes: I18N.i18nText(params.confirmYesCode),
const defaultParams = { confirmNo: I18N.i18nText(params.confirmNoCode),
titleCode: titleCode ? titleCode : 'error', },
confirmYesCode: null, confirmCallback,
confirmNoCode: 'close', );
} };
const params = Object.assign(defaultParams, options);
COMMON.showConfirm(messageCode, null, params); /**
}; * show alert message by confirm modal html
* @param {String} messageCode
/** * @param {string} titleCode
* close alert * @param {Object} options - Data Options {message, titleCode, confirmNoCode}
*/ */
COMMON.alertClose = function () { COMMON.showAlert = function (messageCode, titleCode = 'error', options = {}) {
$('.alert-overlay').addClass('d-none'); const defaultParams = {
$('.alert-area').addClass('d-none'); titleCode: titleCode ? titleCode : 'error',
$('body').css('overflow', 'visible'); confirmYesCode: null,
}; confirmNoCode: 'close',
};
/** const params = Object.assign(defaultParams, options);
* go Url page With Current Params COMMON.showConfirm(messageCode, null, params);
* };
* ios will remove all web types data when reopen webview
* need add common parameters: app, lang, debug, mobile_flg, isChat, ... /**
* * close alert
* @param {String} url */
* @param {Object} params COMMON.alertClose = function () {
*/ $('.alert-overlay').addClass('d-none');
COMMON.goUrlWithCurrentParams = function (url, params) { $('.alert-area').addClass('d-none');
if (!params) { $('body').css('overflow', 'visible');
location.href = CONSTANT.URL.WEB.BASE + url; };
}
/**
const mixParams = Object.assign(COMMON.getUrlParameter(), params); * go Url page With Current Params
if (url.includes('?')) { *
location.href = url + '&' + new URLSearchParams(mixParams); * ios will remove all web types data when reopen webview
} else { * need add common parameters: app, lang, debug, mobile_flg, isChat, ...
location.href = url + '?' + new URLSearchParams(mixParams); *
} * @param {String} url
}; * @param {Object} params
*/
/** COMMON.goUrlWithCurrentParams = function (url, params) {
* get url parameter if (!params) {
* location.href = CONSTANT.URL.WEB.BASE + url;
*/ }
COMMON.getUrlParameter = function () {
var ret = {}; const mixParams = Object.assign(COMMON.getUrlParameter(), params);
if (location.search) { if (url.includes('?')) {
var param = {}; location.href = url + '&' + new URLSearchParams(mixParams);
location.search } else {
.substring(1) location.href = url + '?' + new URLSearchParams(mixParams);
.split('&') }
.forEach(function (val) { };
var kv = val.split('=');
param[kv[0]] = kv[1]; /**
}); * get url parameter
ret = param; *
} */
console.log({ ret: ret }); COMMON.getUrlParameter = function () {
return ret; var ret = {};
}; if (location.search) {
var param = {};
/** location.search
* get sid in local Storage .substring(1)
* .split('&')
*/ .forEach(function (val) {
COMMON.getSid = function () { var kv = val.split('=');
return ClientData.userInfo_sid(); param[kv[0]] = kv[1];
}; });
ret = param;
/** }
* cms communication console.log({ ret: ret });
* return ret;
* @param {String} url };
* @param {Json} param
* @param {boolean} async /**
* @param {Object} callback * get sid in local Storage
* @param {Object} errorCallback *
* @param {number} type */
*/ COMMON.getSid = function () {
COMMON.cmsAjax = function (url, param, async = true, callback, errorCallback, type) { return ClientData.userInfo_sid();
var sysSettings = new COMMON.sysSetting(); };
if (url) {
$.ajax({ /**
type: 'post', * cms communication
url: url, *
data: param, * @param {String} url
dataType: type ? type : 'json', * @param {Json} param
cache: false, * @param {boolean} async
async: async, * @param {Object} callback
crossDomain: true, * @param {Object} errorCallback
beforeSend: function (xhr) { * @param {number} type
xhr.setRequestHeader('X-AGT-AppId', sysSettings.appName); */
xhr.setRequestHeader('X-AGT-AppVersion', sysSettings.appVersion); COMMON.cmsAjax = function (url, param, async = true, callback, errorCallback, type) {
}, var sysSettings = new COMMON.sysSetting();
success: function (result) { if (url) {
if (type == 'text') { $.ajax({
if (callback) callback(result); type: 'post',
return; url: url,
} data: param,
if (result.httpStatus == '200') { dataType: type ? type : 'json',
if (callback) callback(result); cache: false,
} else if (errorCallback) { async: async,
errorCallback(result); crossDomain: true,
} else if (result.httpStatus == '401') { beforeSend: function (xhr) {
COMMON.goUrlWithCurrentParams(CONSTANT.PAGE_NAME.LOGIN); xhr.setRequestHeader('X-AGT-AppId', sysSettings.appName);
} else if (result.httpStatus == '403') { xhr.setRequestHeader('X-AGT-AppVersion', sysSettings.appVersion);
COMMON.closeLoading(); },
COMMON.showAlert('errorOccurred'); success: function (result) {
} else { if (type == 'text') {
COMMON.closeLoading(); if (callback) callback(result);
COMMON.showAlert(result.message); return;
} }
}, if (result.httpStatus == '200') {
error: function (XMLHttpRequest, textStatus, errorThrown) { if (callback) callback(result);
if (errorCallback) { } else if (errorCallback) {
errorCallback(XMLHttpRequest, textStatus, errorThrown); errorCallback(result);
} else { } else if (result.httpStatus == '401') {
COMMON.closeLoading(); COMMON.goUrlWithCurrentParams(CONSTANT.PAGE_NAME.LOGIN);
COMMON.showAlert('errorCommunicationFailed'); } else if (result.httpStatus == '403') {
} COMMON.closeLoading();
}, COMMON.showAlert('errorOccurred');
}); } else {
} else { COMMON.closeLoading();
if (errorCallback) { COMMON.showAlert(result.message);
errorCallback(); }
} else { },
COMMON.closeLoading(); error: function (XMLHttpRequest, textStatus, errorThrown) {
COMMON.showAlert('errorOccurred'); if (errorCallback) {
} errorCallback(XMLHttpRequest, textStatus, errorThrown);
} } else {
}; COMMON.closeLoading();
COMMON.showAlert('errorCommunicationFailed');
/** }
* Check if user is logged in },
* });
* @param {boolean} async } else {
*/ if (errorCallback) {
COMMON.checkAuth = function (async = true) { errorCallback();
let params = {}; } else {
console.log("kdh check"); COMMON.closeLoading();
params.sid = COMMON.getSid; COMMON.showAlert('errorOccurred');
const url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.API.AUTH_SESSION; }
COMMON.cmsAjax(url, params, async, null, function () { }
COMMON.goUrlWithCurrentParams(CONSTANT.PAGE_NAME.LOGIN); };
});
}; /**
* Check if user is logged in
var ClientData = { *
// Local :userInfo_account path:String * @param {boolean} async
userInfo_accountPath: function (data) { */
if (arguments.length > 0) { COMMON.checkAuth = function (async = true) {
COMMON.userSetting().set(CONSTANT.KEYS.userInfo_accountPath, data); let params = {};
} else { console.log('kdh check');
return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath); params.sid = COMMON.getSid;
} const url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.API.AUTH_SESSION;
}, COMMON.cmsAjax(url, params, async, null, function () {
COMMON.goUrlWithCurrentParams(CONSTANT.PAGE_NAME.LOGIN);
// Local :userInfo_loginID:String });
userInfo_loginId: function (data) { };
if (arguments.length > 0) {
COMMON.userSetting().set(CONSTANT.KEYS.userInfo_loginId, data); var ClientData = {
} else { // Local :userInfo_account path:String
return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId); userInfo_accountPath: function (data) {
} if (arguments.length > 0) {
}, COMMON.userSetting().set(CONSTANT.KEYS.userInfo_accountPath, data);
} else {
// Local :userInfo_Account Information Storage Flag:Char(Y:Available, N:Not Available) return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath);
userInfo_rememberLogin: function (data) { }
if (arguments.length > 0) { },
COMMON.userSetting().set(CONSTANT.KEYS.userInfo_rememberLogin, data);
} else { // Local :userInfo_loginID:String
return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_rememberLogin); userInfo_loginId: function (data) {
} if (arguments.length > 0) {
}, COMMON.userSetting().set(CONSTANT.KEYS.userInfo_loginId, data);
} else {
// Session :userInfo_loginID:String return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId);
userInfo_loginId_session: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.userInfo_loginId, data);
} else { // Local :userInfo_Account Information Storage Flag:Char(Y:Available, N:Not Available)
return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_loginId); userInfo_rememberLogin: function (data) {
} if (arguments.length > 0) {
}, COMMON.userSetting().set(CONSTANT.KEYS.userInfo_rememberLogin, data);
} else {
// Session :userInfo_account path:String return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_rememberLogin);
userInfo_accountPath_session: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.userInfo_accountPath, data);
} else { // Session :userInfo_loginID:String
return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_accountPath); userInfo_loginId_session: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.userInfo_loginId, data);
} else {
// Session return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_loginId);
userInfo_userName: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.userInfo_userName, data);
} else { // Session :userInfo_account path:String
return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_userName); userInfo_accountPath_session: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.userInfo_accountPath, data);
} else {
// Local :userInfo_Last login date and time:Datetime return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_accountPath);
userInfo_lastLoginTime: function (data) { }
if (arguments.length > 0) { },
COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_lastLoginTime, undefined);
} else { // Session
return COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_lastLoginTime, undefined); userInfo_userName: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.userInfo_userName, data);
} else {
// Session:userInfo_SessionID:String return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_userName);
userInfo_sid: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.userInfo_sid, data);
// COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid, data); // Local :userInfo_Last login date and time:Datetime
} else { userInfo_lastLoginTime: function (data) {
// return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid); if (arguments.length > 0) {
if (COMMON.userSession()) { COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_lastLoginTime, undefined);
return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_sid); } else {
} return COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_lastLoginTime, undefined);
return null; }
} },
},
// Session:userInfo_SessionID:String
// Local: userInfo_SessionID:String userInfo_sid: function (data) {
userInfo_sid_local: function (data) { if (arguments.length > 0) {
if (arguments.length > 0) { SessionStorageUtils.set(CONSTANT.KEYS.userInfo_sid, data);
COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid_local, data); // COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid, data);
} else { } else {
return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid_local); // return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid);
} if (COMMON.userSession()) {
}, return SessionStorageUtils.get(CONSTANT.KEYS.userInfo_sid);
}
// Local: Session ID backup return null;
userInfo_sid_local_bak: function (data) { }
if (arguments.length > 0) { },
COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid_bak, data);
} else { // Local: userInfo_SessionID:String
return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid_bak); userInfo_sid_local: function (data) {
} if (arguments.length > 0) {
}, COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid_local, data);
} else {
// Session :Notification information (pushInfo)_Number of new arrivals:Interger return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid_local);
pushInfo_newMsgNumber: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.pushInfo_newMsgNumber, data);
} else { // Local: Session ID backup
return SessionStorageUtils.get(CONSTANT.KEYS.pushInfo_newMsgNumber); userInfo_sid_local_bak: function (data) {
} if (arguments.length > 0) {
}, COMMON.userSetting().set(CONSTANT.KEYS.userInfo_sid_bak, data);
} else {
// apiUrl return COMMON.userSetting().get(CONSTANT.KEYS.userInfo_sid_bak);
conf_apiUrl: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.conf_apiUrl, data);
} else { // Session :Notification information (pushInfo)_Number of new arrivals:Interger
return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiUrl); pushInfo_newMsgNumber: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.pushInfo_newMsgNumber, data);
} else {
// api login url return SessionStorageUtils.get(CONSTANT.KEYS.pushInfo_newMsgNumber);
conf_apiLoginUrl: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.conf_apiLoginUrl, data);
} else { // apiUrl
return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiLoginUrl); conf_apiUrl: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.conf_apiUrl, data);
} else {
//check api url return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiUrl);
conf_checkApiUrl: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.conf_checkApiUrl, data);
} else { // api login url
return SessionStorageUtils.get(CONSTANT.KEYS.conf_checkApiUrl); conf_apiLoginUrl: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.conf_apiLoginUrl, data);
} else {
// api resorce dl url return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiLoginUrl);
conf_apiResourceDlUrl: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.conf_apiResourceDlUrl, data);
} else { //check api url
return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiResourceDlUrl); conf_checkApiUrl: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.conf_checkApiUrl, data);
} else {
// Local :userInfo_password_skip_datetime:Datetime return SessionStorageUtils.get(CONSTANT.KEYS.conf_checkApiUrl);
userInfo_pwdSkipDt: function (data) { }
if (arguments.length > 0) { },
COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_pwdSkipDt, undefined);
} else { // api resorce dl url
return COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_pwdSkipDt, undefined); conf_apiResourceDlUrl: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.conf_apiResourceDlUrl, data);
} else {
// Session :Business Option (serviceOpt)_ABookCheck:Char(Y:Enable, N:Disable) return SessionStorageUtils.get(CONSTANT.KEYS.conf_apiResourceDlUrl);
serviceOpt_abook_check: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_abook_check, data);
} else { // Local :userInfo_password_skip_datetime:Datetime
return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_abook_check); userInfo_pwdSkipDt: function (data) {
} if (arguments.length > 0) {
}, COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_pwdSkipDt, undefined);
} else {
// Session : Tenant Service_Option(serviceOpt)_ChatFunction:Char(Y:Use, N:Unused) return COMMON.operateData(arguments, CONSTANT.KEYS.userInfo_pwdSkipDt, undefined);
serviceOpt_chat_function: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_abook_check, data);
} else { // Session :Business Option (serviceOpt)_ABookCheck:Char(Y:Enable, N:Disable)
return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_abook_check); serviceOpt_abook_check: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_abook_check, data);
} else {
// Session :Business Option(serviceOpt)_Forced password change at first login:Integer(0:None, 1:Prompt, 2:Forced) return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_abook_check);
serviceOpt_force_pw_change_on_login: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_force_pw_change_on_login, data);
} else { // Session : Tenant Service_Option(serviceOpt)_ChatFunction:Char(Y:Use, N:Unused)
return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_force_pw_change_on_login); serviceOpt_chat_function: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_abook_check, data);
} else {
// Session :Business Option(serviceOpt)_Forced password change at regular login:Integer(0:None, 1:Prompt, 2:Forced) return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_abook_check);
serviceOpt_force_pw_change_periodically: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_force_pw_change_periodically, data);
} else { // Session :Business Option(serviceOpt)_Forced password change at first login:Integer(0:None, 1:Prompt, 2:Forced)
return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_force_pw_change_periodically); serviceOpt_force_pw_change_on_login: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_force_pw_change_on_login, data);
} else {
// Session :Business option (serviceOpt)_arbitrary push message:Char(Y:possible, N:not possible) return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_force_pw_change_on_login);
serviceOpt_usable_push_message: function (data) { }
if (arguments.length > 0) { },
SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_usable_push_message, data);
} else { // Session :Business Option(serviceOpt)_Forced password change at regular login:Integer(0:None, 1:Prompt, 2:Forced)
return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_usable_push_message); serviceOpt_force_pw_change_periodically: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_force_pw_change_periodically, data);
} else {
// Local return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_force_pw_change_periodically);
JumpQueue: function (data) { }
if (arguments.length > 0) { },
COMMON.operateData(arguments, CONSTANT.KEYS.JumpQueue, []);
} else { // Session :Business option (serviceOpt)_arbitrary push message:Char(Y:possible, N:not possible)
return COMMON.operateData(arguments, CONSTANT.KEYS.JumpQueue, []); serviceOpt_usable_push_message: function (data) {
} if (arguments.length > 0) {
}, SessionStorageUtils.set(CONSTANT.KEYS.serviceOpt_usable_push_message, data);
} else {
// Local return SessionStorageUtils.get(CONSTANT.KEYS.serviceOpt_usable_push_message);
IsJumpBack: function (data) { }
if (arguments.length > 0) { },
COMMON.operateData(arguments, CONSTANT.KEYS.IsJumpBack, undefined);
} else { // Local
return COMMON.operateData(arguments, CONSTANT.KEYS.IsJumpBack, undefined); JumpQueue: function (data) {
} if (arguments.length > 0) {
}, COMMON.operateData(arguments, CONSTANT.KEYS.JumpQueue, []);
}; } else {
return COMMON.operateData(arguments, CONSTANT.KEYS.JumpQueue, []);
/* }
* Variables },
*/
COMMON.userSessionObj = null; // Local
COMMON.userSettingObj = null; IsJumpBack: function (data) {
COMMON.sysSettingObj = null; if (arguments.length > 0) {
COMMON.operateData(arguments, CONSTANT.KEYS.IsJumpBack, undefined);
/* } else {
* User Settings Class Definition return COMMON.operateData(arguments, CONSTANT.KEYS.IsJumpBack, undefined);
*/ }
var UserSetting = function () { },
this.US_KEY = 'AVWUS'; };
this.userSetting = this.load();
}; /*
/* get user setting from localStorage */ * Variables
UserSetting.prototype.load = function () { */
var storage = window.localStorage; COMMON.userSessionObj = null;
var value = null; COMMON.userSettingObj = null;
var js = null; COMMON.sysSettingObj = null;
if (storage) {
var value = storage.getItem(this.US_KEY); /*
if (!value) { * User Settings Class Definition
value = '{}'; // empty JSON string */
} var UserSetting = function () {
js = JSON.parse(value); this.US_KEY = 'AVWUS';
} this.userSetting = this.load();
return js; };
}; /* get user setting from localStorage */
UserSetting.prototype.load = function () {
/** var storage = window.localStorage;
* store user setting var value = null;
* @param {*} key var js = null;
* @param {*} value if (storage) {
*/ var value = storage.getItem(this.US_KEY);
UserSetting.prototype.set = function (key, value) { if (!value) {
this.userSetting = this.load(); value = '{}'; // empty JSON string
var values = this.userSetting; }
if (!values) { js = JSON.parse(value);
values = { key: value }; }
} else { return js;
values[key] = value; };
}
var storage = window.localStorage; /**
if (storage) { * store user setting
var jsonStr = JSON.stringify(values); * @param {*} key
storage.setItem(this.US_KEY, jsonStr); * @param {*} value
} */
this.userSetting = values; UserSetting.prototype.set = function (key, value) {
}; this.userSetting = this.load();
var values = this.userSetting;
/** if (!values) {
* grab user setting values = { key: value };
* @param {*} key } else {
* @returns values[key] = value;
*/ }
UserSetting.prototype.get = function (key) { var storage = window.localStorage;
this.userSetting = this.load(); if (storage) {
var values = this.userSetting; var jsonStr = JSON.stringify(values);
if (values) { storage.setItem(this.US_KEY, jsonStr);
return values[key]; }
} this.userSetting = values;
return null; };
};
/**
/** * grab user setting
* show user setting object list * @param {*} key
* @param {*} elmid * @returns
*/ */
UserSetting.prototype.show = function (elmid) { UserSetting.prototype.get = function (key) {
var storage = window.localStorage; this.userSetting = this.load();
var tags = '<p>'; var values = this.userSetting;
if (storage) { if (values) {
var value = storage.getItem(this.US_KEY); return values[key];
if (value) { }
var js = JSON.parse(value); return null;
$.each(js, function (k, v) { };
tags = tags + '<b>' + k + '</b>:' + v + '<br />';
}); /**
} * show user setting object list
tags = tags + '</p>'; * @param {*} elmid
$(elmid).html(tags); */
} UserSetting.prototype.show = function (elmid) {
}; var storage = window.localStorage;
/* Retrieve a list of user-set keys */ var tags = '<p>';
UserSetting.prototype.keys = function () { if (storage) {
var storage = window.localStorage; var value = storage.getItem(this.US_KEY);
var keyList = []; if (value) {
if (storage) { var js = JSON.parse(value);
var value = storage.getItem(this.US_KEY); $.each(js, function (k, v) {
if (value) { tags = tags + '<b>' + k + '</b>:' + v + '<br />';
var js = JSON.parse(value); });
var i = 0; }
$.each(js, function (k, v) { tags = tags + '</p>';
keyList[i++] = k; $(elmid).html(tags);
}); }
} };
return keyList; /* Retrieve a list of user-set keys */
} UserSetting.prototype.keys = function () {
return null; var storage = window.localStorage;
}; var keyList = [];
if (storage) {
/** var value = storage.getItem(this.US_KEY);
* Delete user settings if (value) {
* @param {*} key var js = JSON.parse(value);
*/ var i = 0;
UserSetting.prototype.remove = function (key) { $.each(js, function (k, v) {
var storage = window.localStorage; keyList[i++] = k;
if (storage) { });
var value = storage.getItem(this.US_KEY); }
if (value) { return keyList;
var js = JSON.parse(value); }
if (js) { return null;
delete js[key]; };
storage.setItem(this.US_KEY, JSON.stringify(js));
} /**
} * Delete user settings
} * @param {*} key
}; */
/* Delete all user settings */ UserSetting.prototype.remove = function (key) {
UserSetting.prototype.removeAll = function () { var storage = window.localStorage;
var storage = window.localStorage; if (storage) {
if (storage) { var value = storage.getItem(this.US_KEY);
storage.remove(this.US_KEY); if (value) {
} var js = JSON.parse(value);
}; if (js) {
delete js[key];
/* storage.setItem(this.US_KEY, JSON.stringify(js));
* User Session Class Definition }
*/ }
var UserSession = function () { }
this.available = false; };
}; /* Delete all user settings */
UserSetting.prototype.removeAll = function () {
/** var storage = window.localStorage;
* Initialize User Session if (storage) {
* @param {*} option storage.remove(this.US_KEY);
*/ }
UserSession.prototype.init = function (option) { };
this.available = false;
if (option == 'restore') { /*
var value = null; * User Session Class Definition
try { */
value = this._get('init'); var UserSession = function () {
} catch (e) { this.available = false;
value = null; };
} finally {
if (value) { /**
this.available = true; * Initialize User Session
} * @param {*} option
} */
} else { UserSession.prototype.init = function (option) {
this.set('init', new Date().toLocaleString()); this.available = false;
this.available = true; if (option == 'restore') {
} var value = null;
}; try {
value = this._get('init');
/** } catch (e) {
* store key, value item to user session value = null;
* @param {*} key } finally {
* @param {*} value if (value) {
*/ this.available = true;
UserSession.prototype.set = function (key, value) { }
var storage = window.sessionStorage; }
if (storage) { } else {
if (this.available == false) { this.set('init', new Date().toLocaleString());
if (key == 'init') { this.available = true;
storage.setItem('AVWS_' + key, value); }
} else { };
throw new Error('Session destoryed.');
} /**
} else { * store key, value item to user session
storage.setItem('AVWS_' + key, value); * @param {*} key
} * @param {*} value
} */
}; UserSession.prototype.set = function (key, value) {
var storage = window.sessionStorage;
/** if (storage) {
* get session item value if (this.available == false) {
* @param {*} key if (key == 'init') {
* @returns storage.setItem('AVWS_' + key, value);
*/ } else {
UserSession.prototype.get = function (key) { throw new Error('Session destoryed.');
var value = null; }
if (this.available) { } else {
value = this._get(key); storage.setItem('AVWS_' + key, value);
} else { }
throw new Error('Session Destroyed.'); }
} };
return value;
}; /**
* get session item value
/** * @param {*} key
* get item value from session storage * @returns
* @param {*} key */
* @returns UserSession.prototype.get = function (key) {
*/ var value = null;
UserSession.prototype._get = function (key) { if (this.available) {
var storage = window.sessionStorage; value = this._get(key);
var value = null; } else {
if (storage) { throw new Error('Session Destroyed.');
value = storage.getItem('AVWS_' + key); }
} return value;
return value; };
};
/* destroy user session */ /**
UserSession.prototype.destroy = function () { * get item value from session storage
var storage = window.sessionStorage; * @param {*} key
if (storage) { * @returns
storage.clear(); */
this.available = false; UserSession.prototype._get = function (key) {
} var storage = window.sessionStorage;
}; var value = null;
if (storage) {
/** value = storage.getItem('AVWS_' + key);
* show user session object list }
* @param {*} elmid return value;
*/ };
UserSession.prototype.show = function (elmid) { /* destroy user session */
var storage = window.sessionStorage; UserSession.prototype.destroy = function () {
var tags = '<p>'; var storage = window.sessionStorage;
if (storage) { if (storage) {
for (var i = 0; i < storage.length; i++) { storage.clear();
var key = storage.key(i); this.available = false;
var value = storage.getItem(key); }
tags = tags + '<b>' + key + '</b>:' + value + '<br />'; };
}
tags = tags + '</p>'; /**
$(elmid).html(tags); * show user session object list
} * @param {*} elmid
}; */
UserSession.prototype.show = function (elmid) {
/* Initialize system */ var storage = window.sessionStorage;
$(function () { var tags = '<p>';
// Determine the path where the system configuration files are located if (storage) {
for (var i = 0; i < storage.length; i++) {
var location = window.location.toString().toLowerCase(); var key = storage.key(i);
var value = storage.getItem(key);
var sysFile = ''; tags = tags + '<b>' + key + '</b>:' + value + '<br />';
if (location.indexOf('/abweb') < 0) { }
sysFile = '../abweb/common/json/sys/conf.json'; tags = tags + '</p>';
} else { $(elmid).html(tags);
sysFile = '../common/json/sys/conf.json'; }
} };
// Read the system configuration file /* Initialize system */
$.ajax({ $(function () {
url: sysFile, // Determine the path where the system configuration files are located
async: false,
cache: false, var location = window.location.toString().toLowerCase();
dataType: 'json',
success: function (data) { var sysFile = '';
COMMON.sysSettingObj = data; if (location.indexOf('/abweb') < 0) {
}, sysFile = '../abweb/common/json/sys/conf.json';
error: function (xmlHttpRequest, txtStatus, errorThrown) { } else {
var error = 'Could not load the system configuration file. Please check it.'; sysFile = '../common/json/sys/conf.json';
error += '\n' + xmlHttpRequest.status + ' ' + txtStatus + ' ' + errorThrown + ' : ' + sysFile; }
alert(error);
}, // Read the system configuration file
}); $.ajax({
url: sysFile,
// Clear error conditions once at load time. async: false,
COMMON.clearError(); cache: false,
dataType: 'json',
//#31919 [Investigation] Business meeting support system GoogleChrome does not work with Bitch in/out. success: function (data) {
navigator.pointerEnabled = navigator.maxTouchPoints > 0; // Edge 17 touch support workaround COMMON.sysSettingObj = data;
document.documentElement.ontouchstart = navigator.maxTouchPoints > 0 ? function () {} : undefined; // Chrome 70 touch support workaround },
}); error: function (xmlHttpRequest, txtStatus, errorThrown) {
var error = 'Could not load the system configuration file. Please check it.';
// Hide the locking layout error += '\n' + xmlHttpRequest.status + ' ' + txtStatus + ' ' + errorThrown + ' : ' + sysFile;
COMMON.unlockLayout = function () { alert(error);
$('#avw-sys-modal').hide(); },
}; });
// Show the locking layout // Clear error conditions once at load time.
COMMON.lockLayout = function () { COMMON.clearError();
if (document.getElementById('avw-sys-modal')) {
$('#avw-sys-modal').show(); //#31919 [Investigation] Business meeting support system GoogleChrome does not work with Bitch in/out.
} else { navigator.pointerEnabled = navigator.maxTouchPoints > 0; // Edge 17 touch support workaround
var tags = '<div id="avw-sys-modal"></div>'; document.documentElement.ontouchstart = navigator.maxTouchPoints > 0 ? function () {} : undefined; // Chrome 70 touch support workaround
$('body').prepend(tags); });
$('#avw-sys-modal').css({
opacity: 0.7, // Hide the locking layout
position: 'fixed', COMMON.unlockLayout = function () {
top: '0', $('#avw-sys-modal').hide();
left: '0', };
width: $(window).width(),
height: $(window).height(), // Show the locking layout
background: '#999', COMMON.lockLayout = function () {
'z-index': 100, if (document.getElementById('avw-sys-modal')) {
}); $('#avw-sys-modal').show();
// resize error page } else {
$(window).resize(function () { var tags = '<div id="avw-sys-modal"></div>';
$('#avw-sys-modal').css({ $('body').prepend(tags);
width: $(window).width(), $('#avw-sys-modal').css({
height: $(window).height(), opacity: 0.7,
}); position: 'fixed',
}); top: '0',
} left: '0',
}; width: $(window).width(),
height: $(window).height(),
/* Clear error condition */ background: '#999',
COMMON.clearError = function () { 'z-index': 100,
var session = window.sessionStorage; });
if (session) { // resize error page
session.setItem(COMMON.hasErrorKey, false); $(window).resize(function () {
} $('#avw-sys-modal').css({
}; width: $(window).width(),
/* Get error status */ height: $(window).height(),
COMMON.hasError = function () { });
var session = window.sessionStorage; });
var isError = false; }
if (session) { };
isError = session.getItem(COMMON.hasErrorKey);
} /* Clear error condition */
return isError == 'true'; COMMON.clearError = function () {
}; var session = window.sessionStorage;
/* Set to error condition */ if (session) {
COMMON.setErrorState = function () { session.setItem(COMMON.hasErrorKey, false);
var session = window.sessionStorage; }
if (session) { };
session.setItem(COMMON.hasErrorKey, true); /* Get error status */
} COMMON.hasError = function () {
}; var session = window.sessionStorage;
var isError = false;
/* get user session object */ if (session) {
COMMON.userSession = function () { isError = session.getItem(COMMON.hasErrorKey);
if (!COMMON.userSessionObj) { }
var obj = new UserSession(); return isError == 'true';
obj.init('restore'); };
if (obj.available) { /* Set to error condition */
COMMON.userSessionObj = obj; COMMON.setErrorState = function () {
return COMMON.userSessionObj; var session = window.sessionStorage;
} else { if (session) {
return null; session.setItem(COMMON.hasErrorKey, true);
} }
} };
return COMMON.userSessionObj;
}; /* get user session object */
/* create user session object */ COMMON.userSession = function () {
COMMON.createUserSession = function () { if (!COMMON.userSessionObj) {
if (COMMON.userSessionObj) { var obj = new UserSession();
COMMON.userSessionObj.destroy(); obj.init('restore');
} else { if (obj.available) {
COMMON.userSessionObj = new UserSession(); COMMON.userSessionObj = obj;
COMMON.userSessionObj.init(); return COMMON.userSessionObj;
} } else {
return COMMON.userSessionObj; return null;
}; }
}
/* get user setting object */ return COMMON.userSessionObj;
COMMON.userSetting = function () { };
if (COMMON.userSettingObj == null) { /* create user session object */
COMMON.userSettingObj = new UserSetting(); COMMON.createUserSession = function () {
} if (COMMON.userSessionObj) {
return COMMON.userSettingObj; COMMON.userSessionObj.destroy();
}; } else {
COMMON.userSessionObj = new UserSession();
/* get system setting object */ COMMON.userSessionObj.init();
COMMON.sysSetting = function () { }
return COMMON.sysSettingObj; return COMMON.userSessionObj;
}; };
/* /* get user setting object */
* Operations for session storage [start] COMMON.userSetting = function () {
*/ if (COMMON.userSettingObj == null) {
COMMON.userSettingObj = new UserSetting();
var SessionStorageUtils = { }
login: function () { return COMMON.userSettingObj;
if (COMMON.userSession()) { };
// Skip this case
} else { /* get system setting object */
COMMON.avwCreateUserSession(); COMMON.sysSetting = function () {
} return COMMON.sysSettingObj;
}, };
get: function (strKey) {
return COMMON.userSession().get(strKey); /*
}, * Operations for session storage [start]
set: function (strKey, objValue) { */
COMMON.userSession().set(strKey, objValue);
}, var SessionStorageUtils = {
clear: function () { login: function () {
if (COMMON.userSession()) { if (COMMON.userSession()) {
COMMON.userSession().destroy(); // Skip this case
} } else {
}, COMMON.avwCreateUserSession();
remove: function (strKey) { }
COMMON.userSession().set(strKey, null); },
}, get: function (strKey) {
}; return COMMON.userSession().get(strKey);
},
/* set: function (strKey, objValue) {
* Operations for local storage COMMON.userSession().set(strKey, objValue);
*/ },
var LocalStorageUtils = { clear: function () {
getUniqueId: function () { if (COMMON.userSession()) {
var uniqueId = ''; COMMON.userSession().destroy();
}
if (COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath)) { },
uniqueId += COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath); remove: function (strKey) {
} COMMON.userSession().set(strKey, null);
if (COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId)) { },
uniqueId += '.' + COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId); };
}
if (uniqueId != '') { /*
uniqueId += '.'; * Operations for local storage
} */
var LocalStorageUtils = {
return uniqueId; getUniqueId: function () {
}, var uniqueId = '';
get: function (strKey) {
var key = this.getUniqueId() + strKey; if (COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath)) {
uniqueId += COMMON.userSetting().get(CONSTANT.KEYS.userInfo_accountPath);
return COMMON.userSetting().get(key); }
}, if (COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId)) {
set: function (strKey, objValue) { uniqueId += '.' + COMMON.userSetting().get(CONSTANT.KEYS.userInfo_loginId);
var key = this.getUniqueId() + strKey; }
COMMON.userSetting().set(key, objValue); if (uniqueId != '') {
}, uniqueId += '.';
remove: function (strKey) { }
var key = this.getUniqueId() + strKey;
COMMON.userSetting().remove(key); return uniqueId;
SessionStorageUtils.remove(strKey); },
}, get: function (strKey) {
clear: function () { var key = this.getUniqueId() + strKey;
var localStorageKeys = COMMON.userSetting().keys();
for (var nIndex = 0; nIndex < localStorageKeys.length; nIndex++) { return COMMON.userSetting().get(key);
var strKey = localStorageKeys[nIndex]; },
set: function (strKey, objValue) {
if ((strKey + '').contains(this.getUniqueId())) { var key = this.getUniqueId() + strKey;
COMMON.userSetting().remove(strKey); COMMON.userSetting().set(key, objValue);
} },
} remove: function (strKey) {
}, var key = this.getUniqueId() + strKey;
existKey: function (strKey) { COMMON.userSetting().remove(key);
var keys = COMMON.userSetting().keys(); SessionStorageUtils.remove(strKey);
var findKey = this.getUniqueId() + strKey; },
var isExisted = false; clear: function () {
if (keys != null && keys != undefined) { var localStorageKeys = COMMON.userSetting().keys();
for (var nIndex = 0; nIndex < keys.length; nIndex++) { for (var nIndex = 0; nIndex < localStorageKeys.length; nIndex++) {
if (keys[nIndex] == findKey) { var strKey = localStorageKeys[nIndex];
isExisted = true;
break; if ((strKey + '').contains(this.getUniqueId())) {
} COMMON.userSetting().remove(strKey);
} }
} }
return isExisted; },
}, existKey: function (strKey) {
}; var keys = COMMON.userSetting().keys();
var findKey = this.getUniqueId() + strKey;
/** var isExisted = false;
* String.format function def. if (keys != null && keys != undefined) {
* @param {*} fmt for (var nIndex = 0; nIndex < keys.length; nIndex++) {
* @returns if (keys[nIndex] == findKey) {
*/ isExisted = true;
COMMON.format = function (fmt) { break;
for (var i = 1; i < arguments.length; i++) { }
var reg = new RegExp('\\{' + (i - 1) + '\\}', 'g'); }
fmt = fmt.replace(reg, arguments[i]); }
} return isExisted;
return fmt; },
}; };
/** /**
* Get param url * String.format function def.
* @param {*} name * @param {*} fmt
* @param {*} url * @returns
* @returns */
*/ COMMON.format = function (fmt) {
COMMON.getUrlParam = function (name, url) { for (var i = 1; i < arguments.length; i++) {
if (!url) { var reg = new RegExp('\\{' + (i - 1) + '\\}', 'g');
url = window.location.href; fmt = fmt.replace(reg, arguments[i]);
} }
return fmt;
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); };
var regexS = '[\\?&]' + name + '=([^&#]*)';
var regex = new RegExp(regexS); /**
var results = regex.exec(url); * Get param url
if (results == null) { * @param {*} name
return ''; * @param {*} url
} else { * @returns
return results[1]; */
} COMMON.getUrlParam = function (name, url) {
}; if (!url) {
url = window.location.href;
// Toogle Logout Nortice }
COMMON.ToogleLogoutNortice = function () {
window.onbeforeunload = function (event) { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var message = I18N.i18nText('sysInfoWithoutLogout'); var regexS = '[\\?&]' + name + '=([^&#]*)';
var e = event || window.event; var regex = new RegExp(regexS);
if (e) { var results = regex.exec(url);
e.returnValue = message; if (results == null) {
} return '';
return message; } else {
}; return results[1];
}; }
};
/**
* * Get data from localstorage and sessionstorage synchronization If has any // Toogle Logout Nortice
* param (args.length > 0) -> setter If has not param (args.length = 0) -> COMMON.ToogleLogoutNortice = function () {
* getter . Get from session: + if it existed and key existed in localstorage -> window.onbeforeunload = function (event) {
* return result + else: set value from local to sessionstorage -> return value var message = I18N.i18nText('sysInfoWithoutLogout');
* of sessionstorage if value is not empty, otherwise, return default result. var e = event || window.event;
* @param {*} args if (e) {
* @param {*} strKey e.returnValue = message;
* @param {*} returnDefaultData }
* @returns return message;
*/ };
COMMON.operateData = function (args, strKey, returnDefaultData) { };
if (args.length > 0) {
var data = args[0]; /**
LocalStorageUtils.set(strKey, data); * * Get data from localstorage and sessionstorage synchronization If has any
SessionStorageUtils.set(strKey, JSON.stringify(data)); * param (args.length > 0) -> setter If has not param (args.length = 0) ->
} else { * getter . Get from session: + if it existed and key existed in localstorage ->
if ( * return result + else: set value from local to sessionstorage -> return value
SessionStorageUtils.get(strKey) != 'undefined' && * of sessionstorage if value is not empty, otherwise, return default result.
SessionStorageUtils.get(strKey) != undefined && * @param {*} args
SessionStorageUtils.get(strKey) != '' && * @param {*} strKey
SessionStorageUtils.get(strKey) != null && * @param {*} returnDefaultData
SessionStorageUtils.get(strKey) != 'null' * @returns
) { */
if (LocalStorageUtils.existKey(strKey) == true) { COMMON.operateData = function (args, strKey, returnDefaultData) {
return JSON.parse(SessionStorageUtils.get(strKey)); if (args.length > 0) {
} else { var data = args[0];
return returnDefaultData; LocalStorageUtils.set(strKey, data);
} SessionStorageUtils.set(strKey, JSON.stringify(data));
} else { } else {
if (LocalStorageUtils.existKey(strKey) == true) { if (
SessionStorageUtils.set(strKey, JSON.stringify(LocalStorageUtils.get(strKey))); SessionStorageUtils.get(strKey) != 'undefined' &&
return JSON.parse(SessionStorageUtils.get(strKey)); SessionStorageUtils.get(strKey) != undefined &&
} SessionStorageUtils.get(strKey) != '' &&
return returnDefaultData; SessionStorageUtils.get(strKey) != null &&
} SessionStorageUtils.get(strKey) != 'null'
} ) {
}; if (LocalStorageUtils.existKey(strKey) == true) {
return JSON.parse(SessionStorageUtils.get(strKey));
/** } else {
* UTC current Time (millisecond) return returnDefaultData;
* }
* @returns UTC time } else {
*/ if (LocalStorageUtils.existKey(strKey) == true) {
COMMON.currentTime = function () { SessionStorageUtils.set(strKey, JSON.stringify(LocalStorageUtils.get(strKey)));
return Date.now(); return JSON.parse(SessionStorageUtils.get(strKey));
}; }
return returnDefaultData;
/** }
* check login information in window.sessionStorage }
* };
* @returns boolean
*/ /**
COMMON.checkLogin = function (option) { * UTC current Time (millisecond)
var userSession = COMMON.userSession(); *
if(!userSession) { * @returns UTC time
*/
/* エラー画面を表示 */ COMMON.currentTime = function () {
var tags = '<div id="avw-auth-error">' + return Date.now();
'<div style="display:table; width:100%; height:100%;">' + };
'<div style="display:table-cell; text-align:center; vertical-align:middle;">' +
'<p><h4>Authentication error</h4>Please use it after login.</p>' + /**
'<div><button id="avw-unauth-ok">OK</button></div>' + * check login information in window.sessionStorage
'</div></div></div>'; *
$('body').prepend(tags); * @returns boolean
$('#avw-auth-error').css({ */
'opacity': 1, COMMON.checkLogin = function (option) {
'position': 'fixed', var userSession = COMMON.userSession();
'top': '0', if (!userSession) {
'left': '0', /* エラー画面を表示 */
'background': "#ffffff", var tags =
'width': $(window).width(), '<div id="avw-auth-error">' +
'height': $(window).height(), '<div style="display:table; width:100%; height:100%;">' +
'zIndex': '10000' '<div style="display:table-cell; text-align:center; vertical-align:middle;">' +
}); '<p><h4>Authentication error</h4>Please use it after login.</p>' +
// resize error page '<div><button id="avw-unauth-ok">OK</button></div>' +
$(window).resize(function() { '</div></div></div>';
$('#avw-auth-error').css( { $('body').prepend(tags);
'width': $(window).width(), $('#avw-auth-error').css({
'height': $(window).height() opacity: 1,
}); position: 'fixed',
}); top: '0',
left: '0',
var returnPage; background: '#ffffff',
if(option) { width: $(window).width(),
returnPage = option height: $(window).height(),
} else { zIndex: '10000',
var sysSetting = COMMON.sysSetting(); });
returnPage = sysSetting.loginPage; // resize error page
} $(window).resize(function () {
/* ログイン画面に戻る */ $('#avw-auth-error').css({
$('#avw-unauth-ok').click(function() { width: $(window).width(),
window.location = returnPage; height: $(window).height(),
}); });
return false; });
}
return true; var returnPage;
} if (option) {
returnPage = option;
/* } else {
* Operations for session storage [ end ] var sysSetting = COMMON.sysSetting();
*/ returnPage = sysSetting.loginPage;
}
// ============================================================================================= /* ログイン画面に戻る */
// Utils for string, date, number [start] $('#avw-unauth-ok').click(function () {
// ============================================================================================= window.location = returnPage;
/* });
* Convert date to JP format date time [start] return false;
*/ }
return true;
/* };
* YYYY/MM/DD HH:MM:SS
*/ /*
Date.prototype.jpDateTimeString = function () { * Operations for session storage [ end ]
var strResult = ''; */
var strYear = this.getFullYear() + '';
var strMonth = this.getMonth() + 1 + ''; // =============================================================================================
var strDayInMonth = this.getDate() + ''; // Utils for string, date, number [start]
var strHour = this.getHours() + ''; // =============================================================================================
var strMinute = this.getMinutes() + ''; /*
var strSecond = this.getSeconds() + ''; * Convert date to JP format date time [start]
*/
strResult += strYear.padLeft('0', 4) + '/' + strMonth.padLeft('0', 2) + '/' + strDayInMonth.padLeft('0', 2);
strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2); /*
return strResult; * YYYY/MM/DD HH:MM:SS
}; */
/* Date.prototype.jpDateTimeString = function () {
* YYYY-MM-DD HH:MM:SS var strResult = '';
*/ var strYear = this.getFullYear() + '';
Date.prototype.jpDateTimeString1 = function () { var strMonth = this.getMonth() + 1 + '';
var strResult = ''; var strDayInMonth = this.getDate() + '';
var strYear = this.getFullYear() + ''; var strHour = this.getHours() + '';
var strMonth = this.getMonth() + 1 + ''; var strMinute = this.getMinutes() + '';
var strDayInMonth = this.getDate() + ''; var strSecond = this.getSeconds() + '';
var strHour = this.getHours() + '';
var strMinute = this.getMinutes() + ''; strResult += strYear.padLeft('0', 4) + '/' + strMonth.padLeft('0', 2) + '/' + strDayInMonth.padLeft('0', 2);
var strSecond = this.getSeconds() + ''; strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2);
return strResult;
strResult += strYear.padLeft('0', 4) + '-' + strMonth.padLeft('0', 2) + '-' + strDayInMonth.padLeft('0', 2); };
strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2); /*
return strResult; * YYYY-MM-DD HH:MM:SS
}; */
/* Date.prototype.jpDateTimeString1 = function () {
* yyyy/MM/dd var strResult = '';
*/ var strYear = this.getFullYear() + '';
Date.prototype.jpDateString = function () { var strMonth = this.getMonth() + 1 + '';
var strResult = ''; var strDayInMonth = this.getDate() + '';
var strYear = this.getFullYear() + ''; var strHour = this.getHours() + '';
var strMonth = this.getMonth() + 1 + ''; var strMinute = this.getMinutes() + '';
var strDayInMonth = this.getDate() + ''; var strSecond = this.getSeconds() + '';
strResult += strYear.padLeft('0', 4) + '/' + strMonth.padLeft('0', 2) + '/' + strDayInMonth.padLeft('0', 2); strResult += strYear.padLeft('0', 4) + '-' + strMonth.padLeft('0', 2) + '-' + strDayInMonth.padLeft('0', 2);
strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2);
return strResult; return strResult;
}; };
/* /*
* HH:mm:ss * yyyy/MM/dd
*/ */
Date.prototype.jpTimeString = function () { Date.prototype.jpDateString = function () {
var strResult = ''; var strResult = '';
var strHour = this.getHours() + ''; var strYear = this.getFullYear() + '';
var strMinute = this.getMinutes() + ''; var strMonth = this.getMonth() + 1 + '';
var strSecond = this.getSeconds() + ''; var strDayInMonth = this.getDate() + '';
strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2); strResult += strYear.padLeft('0', 4) + '/' + strMonth.padLeft('0', 2) + '/' + strDayInMonth.padLeft('0', 2);
return strResult;
}; return strResult;
/* };
* HH:mm /*
*/ * HH:mm:ss
Date.prototype.jpShortTimeString = function () { */
var strResult = ''; Date.prototype.jpTimeString = function () {
var strHour = this.getHours() + ''; var strResult = '';
var strMinute = this.getMinutes() + ''; var strHour = this.getHours() + '';
var strSecond = this.getSeconds() + ''; var strMinute = this.getMinutes() + '';
var strSecond = this.getSeconds() + '';
strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2);
return strResult; strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2) + ':' + strSecond.padLeft('0', 2);
}; return strResult;
/* };
* yyyyMMddHHmmss /*
*/ * HH:mm
Date.prototype.toIdString = function () { */
var strResult = ''; Date.prototype.jpShortTimeString = function () {
var strYear = this.getFullYear() + ''; var strResult = '';
var strMonth = this.getMonth() + 1 + ''; var strHour = this.getHours() + '';
var strDayInMonth = this.getDate() + ''; var strMinute = this.getMinutes() + '';
var strHour = this.getHours() + ''; var strSecond = this.getSeconds() + '';
var strMinute = this.getMinutes() + '';
var strSecond = this.getSeconds() + ''; strResult += ' ' + strHour.padLeft('0', 2) + ':' + strMinute.padLeft('0', 2);
var strMilisecond = this.getMilliseconds() + ''; return strResult;
};
strResult += strYear.padLeft('0', 4) + strMonth.padLeft('0', 2) + strDayInMonth.padLeft('0', 2); /*
strResult += strHour.padLeft('0', 2) + strMinute.padLeft('0', 2) + strSecond.padLeft('0', 2) + strMilisecond.padLeft('0', 3); * yyyyMMddHHmmss
return strResult; */
}; Date.prototype.toIdString = function () {
var strResult = '';
/** var strYear = this.getFullYear() + '';
* Subtract date to get days var strMonth = this.getMonth() + 1 + '';
* @param {*} targetDate var strDayInMonth = this.getDate() + '';
* @returns var strHour = this.getHours() + '';
*/ var strMinute = this.getMinutes() + '';
Date.prototype.subtractByDays = function (targetDate) { var strSecond = this.getSeconds() + '';
var milis = Math.abs(this - targetDate); var strMilisecond = this.getMilliseconds() + '';
var days = Math.floor(milis / (60 * 60 * 24 * 1000));
return days; strResult += strYear.padLeft('0', 4) + strMonth.padLeft('0', 2) + strDayInMonth.padLeft('0', 2);
}; strResult += strHour.padLeft('0', 2) + strMinute.padLeft('0', 2) + strSecond.padLeft('0', 2) + strMilisecond.padLeft('0', 3);
return strResult;
/** };
* add seconds
* @param {*} plusSeconds /**
* @returns * Subtract date to get days
*/ * @param {*} targetDate
Date.prototype.addSeconds = function (plusSeconds) { * @returns
var newDate = new Date(this.getTime() + plusSeconds * 1000); */
return newDate; Date.prototype.subtractByDays = function (targetDate) {
}; var milis = Math.abs(this - targetDate);
var days = Math.floor(milis / (60 * 60 * 24 * 1000));
/** return days;
* Subtract date to get days };
* @param {*} targetDate
* @returns /**
*/ * add seconds
Date.prototype.subtractBySeconds = function (targetDate) { * @param {*} plusSeconds
var milis = Math.abs(this - targetDate); * @returns
var days = Math.floor(milis / 1000); */
return days; Date.prototype.addSeconds = function (plusSeconds) {
}; var newDate = new Date(this.getTime() + plusSeconds * 1000);
return newDate;
/* };
* Convert date to JP format date time [ end ]
*/ /**
* Subtract date to get days
// trimming space from both side of the string * @param {*} targetDate
String.prototype.trim = function () { * @returns
return this.replace(/^\s+|\s+$/g, ''); */
}; Date.prototype.subtractBySeconds = function (targetDate) {
var milis = Math.abs(this - targetDate);
// trimming space from left side of the string var days = Math.floor(milis / 1000);
String.prototype.trimLeft = function () { return days;
return this.replace(/^\s+/, ''); };
};
/*
// trimming space from right side of the string * Convert date to JP format date time [ end ]
String.prototype.trimRight = function () { */
return this.replace(/\s+$/, '');
}; // trimming space from both side of the string
String.prototype.trim = function () {
/** return this.replace(/^\s+|\s+$/g, '');
* String: pads left };
* @param {*} padString
* @param {*} length // trimming space from left side of the string
* @returns String.prototype.trimLeft = function () {
*/ return this.replace(/^\s+/, '');
String.prototype.padLeft = function (padString, length) { };
var str = this;
while (str.length < length) str = padString + str; // trimming space from right side of the string
return str; String.prototype.trimRight = function () {
}; return this.replace(/\s+$/, '');
};
/**
* String: pads right /**
* @param {*} padString * String: pads left
* @param {*} length * @param {*} padString
* @returns * @param {*} length
*/ * @returns
String.prototype.padRight = function (padString, length) { */
var str = this; String.prototype.padLeft = function (padString, length) {
while (str.length < length) str = str + padString; var str = this;
return str; while (str.length < length) str = padString + str;
}; return str;
};
/**
* Check contain string /**
* @param {*} string * String: pads right
* @returns * @param {*} padString
*/ * @param {*} length
String.prototype.contains = function (string) { * @returns
if (this.indexOf(string) != -1) { */
return true; String.prototype.padRight = function (padString, length) {
} var str = this;
return false; while (str.length < length) str = str + padString;
}; return str;
};
/**
* Number: pads left /**
* @param {*} padString * Check contain string
* @param {*} length * @param {*} string
* @returns * @returns
*/ */
Number.prototype.padLeft = function (padString, length) { String.prototype.contains = function (string) {
var str = this + ''; if (this.indexOf(string) != -1) {
return str.padLeft(padString, length); return true;
}; }
return false;
/** };
* Number: pads right
* @param {*} padString /**
* @param {*} length * Number: pads left
* @returns * @param {*} padString
*/ * @param {*} length
Number.prototype.padRight = function (padString, length) { * @returns
var str = this + ''; */
return str.padRight(padString, length); Number.prototype.padLeft = function (padString, length) {
}; var str = this + '';
// Clear data of array return str.padLeft(padString, length);
Array.prototype.clear = function () { };
this.splice(0, this.length);
}; /**
* Number: pads right
// Function to set position of object to center * @param {*} padString
jQuery.fn.center = function () { * @param {*} length
this.css('position', 'fixed'); * @returns
*/
this.css('top', ($(window).height() - this.height()) / 2 + 'px'); Number.prototype.padRight = function (padString, length) {
this.css('left', ($(window).width() - this.width()) / 2 + 'px'); var str = this + '';
return str.padRight(padString, length);
return this; };
}; // Clear data of array
Array.prototype.clear = function () {
\ No newline at end of file this.splice(0, this.length);
};
// Function to set position of object to center
jQuery.fn.center = function () {
this.css('position', 'fixed');
this.css('top', ($(window).height() - this.height()) / 2 + 'px');
this.css('left', ($(window).width() - this.width()) / 2 + 'px');
return this;
};
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