Commit 7ecf8186 by Kang Donghun

solved comflict

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