/*****************************************************************
* 01. 업무구분 : 출입관리
* 02. 화면명 : 자바스크립트 공통 함수 모듈
* 03. 설명 : 자바스크립트 공통 함수 모듈
* 04. 작성 일자 : 2012.06.20
* 05. 작성자 : 정동호
****************************************************************/
//= 117) && (event.keyCode <= 123))) // function
// F5
{
event.keyCode = 0;
event.cancelBubble = true;
event.returnValue = false;
}
}
};
document.onkeydown = doNotReload;
DU.locale = function() {
return gJavaLocale;
};
DU.viewManual = function(url) {
if (DU.isEmpty(url)) {
url = url || 'this';
DU.alert(url + " is no Manual");
}
else {
window.open('/jsp/tc/tcz/manual/manual.jsp?request=' + url + "&", '_blank',
'titlebar=1,width=950pt,scrollbars=1,height=660px,toolbar=0,menubar=0,status=0,resizable=0,location=0,directories=0,copyhistory=0');
}
};
var ds_Setup =new DU.data.LJsonDataSet({
id: 'ds_Setup'
, fields: [
{id: 'code'}
, {id: 'value'}
]
});
DU.setup = function(id) {
return ds_Setup.getAt(ds_Setup.findRow("code", id, 0)).get("value");
};
DU.helperDesk = function() {
var tell = "";
var admin = "";
tell = tell || DU.setup("VISIT_MANAGER_TEL");
admin = admin || DU.setup("VISIT_CONTROL_MESSAGE");
DU.alert("시스템에 문제가 생겼을 경우 관리자 또는 " + admin + "☎ : " + tell);
};
DU.requestExp = function(s) {
return s.replace(/^'+|'+$/g, "");
};
DU.makeParameter = function(params, name, value) {
params = params || "";
if (params == "") {
params += name + "=" + value;
}
else {
params += "&" + name + "=" + value;
}
return params;
};
DU.getMakeURL = function(url, params) {
return (url + "?" + params);
};
DU.namespace("DU.util");
/**
* @description 메세지 관련 창 띄우기
* @author 정동호
* @creation 2012.06.28
*
*/
DU.util.LMessage = {
alert : function (option) {
var msgBox = DU.widget.LMessageBox;
var Ev = DU.util.LEvent;
var option = option || {};
if(typeof option == 'string') {
option = {
text : option,
handler : DU.emptyFn
};
}
option = DU.applyIf(option, {
buttons: [
{ text:"OK", handler:function(){
this.hideMask();
option.handler.call(this, window.event);
this.destroy();
}, isDefault:true }
]
});
msgBox.createMessageBox(option).show();
},
/*******************************************************************************************************************
* 설명 : DU.prompt를 베이스로한 customized prompt
* 작성일자 : 2012.06.28
* 작성자 : 정동호
******************************************************************************************************************/
prompt : function(option) {
var msgBox = DU.widget.LMessageBox;
var Ev = DU.util.LEvent;
var promptId = DU.id() ;
var option = option || {};
if(typeof option == 'string') {
option = {
text : option,
value: '',
handler: DU.emptyFn
};
}
option = DU.applyIf(option, {
buttons: [
{ text:"OK", handler:function(){
this.hideMask();
option.handler.call(this, DU.get(promptId).getValue());
this.destroy();
}, isDefault:true }/*
* , { text:"Cancel", handler:function(){ this.destroy(); } }
*/
]
});
option.text += "
";
msgBox.createMessageBox(option).show();
},
/*******************************************************************************************************************
* 설명 : DU.confirm을 베이스로한 customized confirm
* 작성일자 : 2012.06.28
* 작성자 : 정동호
******************************************************************************************************************/
confirm : function(option) {
var msgBox = DU.widget.LMessageBox;
var Ev = DU.util.LEvent;
var option = option || {};
if(typeof option == 'string') {
option = {
text : option,
icon: '',
handleYes:DU.emptyFn,
handleNo:DU.emptyFn
};
}
option = DU.applyIf(option, {
title:"Question",
buttons: [
{ text:"Yes", handler:function(){
this.hideMask();
option.handlerYes.call(this);
this.destroy();
}, isDefault:true } ,
{ text:"No", handler:function(){
this.hideMask();
option.handlerNo.call(this);
this.destroy();
}}
]
});
msgBox.createMessageBox(option).show();
},
/*******************************************************************************************************************
* 설명 : DU.widget.LSimgpleDialog를 베이스로한 WaitPanel
* 작성일자 : 2012.06.28
* 작성자 : 정동호
******************************************************************************************************************/
waitPanel : function(option) {
var option = DU.applyIf(option, {
title:"Information",
width:300,
fixedcenter: true,
draggable: true,
visible: false,
close: false,
modal:true,
constraintoviewport: true,
isDefaultCSS:true,
zindex:99999
});
var WaitPanel = new DU.widget.LSimpleDialog("messageBox", option);
WaitPanel.setHeader("");
WaitPanel.render(document.body);
return WaitPanel;
}
};
/***********************************************************************************************************************
* 설명 : 정규식과 패턴으로 원하는 String으로 변환
* 작성자 : 정동호
* 작성일 : 2012.06.25
* ************************************************************************/
/**
* @type : function
* @access : public
* @desc : 정규식과 패턴으로 원하는 String으로 변환
* @sig : rgExp, rgStr, strPattern
* @param :
* rgExp required 정규식 설정 rgStr required 문자열 strPattern required 변환 패턴 정의
* @param :
* rgExp에 쓰일 정규식은 http://evolt.org/node/36435 참조(영문)
* @return : 치환된 데이트 스트링
* @author : 정동호
*/
var gf_RegularMake = function(rgExp, rgStr, strPattern)
{
var oldStr = String(rgStr);
var newStr = oldStr.replace(rgExp, strPattern);
return newStr;
};
/***********************************************************************************************************************
* 설명 : javascript로 구현한 Request
* 작성일자 : 2012.06.27
* 작성자 : 정동호
**********************************************************************************************************************/
var gf_Request = function(valuename) // javascript로 구현한 Request
{
var rtnval = "";
var nowAddress = unescape(location.href);
var parameters = (nowAddress.slice(nowAddress.indexOf("?")+1,nowAddress.length)).split("&");
for(var i = 0 ; i < parameters.length ; i++){
var varName = parameters[i].split("=")[0];
if(varName.toUpperCase() == valuename.toUpperCase())
{
rtnval = parameters[i].split(varName + "=")[1];;
break;
}
}
return rtnval;
};
/***********************************************************************************************************************
* 설명 : 등록 후 쉽게 조회를 돕기 위한 성명,생년월일 포스트 전송
* 작성일자 : 2012.06.28
* 작성자 : 정동호
**********************************************************************************************************************/
var createForm = function(frmId, methodId, actionId, targetId) {
var f = document.createElement("form");
f.name = frmId;
f.method = methodId || "GET";
f.action = actionId || "";
f.target = targetId || "";
return f;
};
var addHidden = function(frmId, name, value) {
var i = document.createElement("input");
i.type = "hidden";
i.name = name || "";
i.value = value || "";
frmId.insertBefore(i);
return frm;
};
DU.applyObject(DU.util.LDate, {
/*******************************************************************************************************************
* 설명 : 날짜 관련 오류 체크
* 작성일자 : 2012.07.17
* 작성자 : 정동호
******************************************************************************************************************/
/**
* @author 정동호
* @creation 2012.07.17
* @return void
* @param {Object}
* f_obj 체크할 객체
* @param {LEvent}
* e 이벤트 객체
* @param {Boolean}
* f_msg Alert 메세지를 보여 줄 것인지 설정
* @param {Function}
* f_fn 수행 후 실행할 함수
* @param {String}
* f_param 함수에 넘겨질 파라메터
*/
validDate : function(f_obj, e, f_msg, f_fn, f_param) {
var Ev = DU.util.LEvent;
switch(e.keyCode) {
case 13:
try {
Ev.stopEvent(e);
}
catch(e) {
cfAlertMsg("tc.info.com.callAdmin");
}
case 9:
var obj = f_obj;
var value = (obj.getValue()).trim();
if (DU.isEmpty(value) || (value.length == 0)) {
if (f_msg) {
DU.alert({
text: cfGetMsg("tc.err.com.dataFormat")
, handler: function() {
obj.setValue("");
obj.focus();
}
});
}
return;
}
if (f_fn) f_fn(f_param);
break;
}
},
/**
* @description Today 날짜 구하기
* @param {Integer} option
* 현재 날짜에서 더하거나 뺄 수
* @return {Date}
* @author 정동호
* @creation: 2012.07.02
*
*
**/ toDay : function(option) { var newDate = new Date(); if (!DU.isEmpty(option)) newDate.setDate(newDate.getDate() + (option)); return newDate; } }); DU.applyObject(DU.util.LRenderer, { /******************************************************************************************************************* * 설명 : 연락처 렌더링 * 작성일자 : 2012.07.04 * 작성자 : 정동호 ******************************************************************************************************************/ contactRenderer : function() { return function(v) { if (DU.isUndefined(v)) v = ""; v = String(v); var length = v.length; switch(length) { case 10: case 11: v = v.insert(3, '-'); v = v.insert(v.length - 4, '-'); break; default: v = v; } return v; }; }, /** * 여러번 real number 형식을 재사용할 수 있는 real number rendering 함수를 리턴한다. * @method pointRenderer * @param * @return {function} */ pointRenderer : function() { return function(v){ var oConfig = { //decimalPlaces: 3, decimalSeparator: ".", thousandsSeparator: "," }; if (!DU.isUndefined(v) && !DU.isNull(v) && v != 0) { v = DU.util.LFormat.numberFormat(Number(v), oConfig); } return v; }; } }); DU.util.LQuery = { /******************************************************************************************************************* * 설명 : Make xmlquery url * 작성일자 : 2012.06.20 * 작성자 : 정동호 ******************************************************************************************************************/ makeQuery : function(xml, work, jndi) { if (jndi == 0) { // default return "/tc/tca/d01/common/retrieveSingleData.ajax?work="+ work + "&xmlquery=" + xml + "&jndi=0"; } else if (jndi == 1) { // ds_tc return "/tc/tca/d01/common/retrieveSingleData.ajax?work="+ work + "&xmlquery=" + xml + "&jndi=1"; } else if (jndi == 2) { // json return "/jsp/tc/tcz/" + work + "/" + xml + ".json"; } }, /** * @description 단순 ajax 호출 * @param url * 호출 url * @param param * 호출 param * @param syncType * ajax sync / async * @param protocol * get / post * @return String * @author 정동호 * *
**/ callUrl : function(url, urlQuery, syncType, protocol) { var params; if(!protocol) protocol = "GET"; if (typeof(urlQuery) != 'string') { params = urlQuery; urlQuery = ''; protocol = "POST"; } else { url = url + "?" + urlQuery; } if (syncType != 'async') { var result; DU.LConnect.syncRequest(protocol, url, { success : function(e) { result = e.responseText; }, failure : function(e) { result = e.responseText; } }, params); return result; } else { DU.LConnect.asyncRequest(protocol, url, { success : function(e) { }, failure : function(e) { } }, params); } } }; DU.namespace("DU.data"); /** * @type : function * @access : public * @desc : 단순 ajax 호출 */ DU.data.LJdhDataSet = function(config) { DU.data.LJdhDataSet.superclass.constructor.call(this, config); /** * @description 데이터 처리 방식 (1:Json); * @property dataSetType * @private * @type {Int} */ this.dataSetType = DU.data.LJsonDataSet.DATA_TYPE; }; DU.extend(DU.data.LJdhDataSet, DU.data.LJsonDataSet, { /** * @description 콤보를 읽어서 세션에 저장 * @methmod session * @param (Object} target 콤보 객체 * @param {String} qId ajax navi ID * @return void * @creation 2012.07.19 * @author 정동호 */ session: function(target, qId) { if (this.getCount() == 0) { // get 함수에 decodeURIComponent 가 되어서 리턴되어야 하나, 무슨 이유인지 encode 상태로 반환되어, decodeURIComponent 함수로 둘러 쌈 var dataCd = decodeURIComponent(DU.util.LCookie.get(this.id)); if (dataCd == "null") { var ret = DU.util.LQuery.callUrl(qId, null, 'sync'); var data = DU.util.LJson.decode(ret.trim()); this.loadData(data[0]); DU.util.LCookie.set(this.id, ret, {path: "/"}); } else { var data = DU.util.LJson.decode(dataCd); this.loadData(data[0]); } if (this.getCount() > 0) { target.repaint(); target.doExpand(); } } }, /** * @description state값을 리턴하는 메소드 * @method getState * @protected * @return {String} */ getState : function(row) { var record = this.getAt(row); switch (record.state) { case DU.data.LRecord.STATE_INSERT: return 'I'; break; case DU.data.LRecord.STATE_UPDATE: return 'U'; break; case DU.data.LRecord.STATE_DELETE: return 'D'; break; } return ''; } }); DU.namespace("DU.data"); /** * LTransactionManager 확장 * * @namespace DU.data * @class LTransactionManagerEx * @extends DU.util.LEventProvider * @constructor LTransactionManagerEx * @param {Object} * oConfig The initial LTransactionManagerEx. */ DU.data.LTransactionManagerEx = function(oConfig){ DU.data.LTransactionManagerEx.superclass.constructor.call(this); var config = oConfig || {}; config = DU.util.LDom.applyIfProperties(config, '$.base.transactionManager'); config = DU.applyIf(config, { text: '잠시만 기다려 주십시오.' }); /** * @description field의 id * @property id * @public * @type {String} */ this.id = config.formId; DU.applyObject(this, config, true); }; DU.extend(DU.data.LTransactionManagerEx, DU.data.LTransactionManager, { /** * @description {DU.data.LDataSet}의 변경정보를 가지고 url로 서버를 호출하는 메소드 *
* var options = {
* dataSets:[dataSet],
* url:'test.dev',
* params:{},
* callback:{}
* }
*
* Sample: 보기
* @method updateDataSet * @public * @param {Object} options 호출할때 전달할 Option정보 객체 * * @return void * * @description 커스터마이징 */ updateDataSet : function(options) { var config = options || {}; config = DU.applyIf(config, { dataSets:[], url:null, params:{}, callback:{}, isCheckedUpdate:this.isCheckedUpdate }); var dataSets = config.dataSets; if(!this.filterTask) this.filterTask = new DU.util.LDelayedTask(DU.util.LFunction.createDelegate(function() {this.doUpdateDataSet(config, dataSets);}, this)); this.filterTask.delay(0); }, /** * @description 호출하게 되면 트랜잭션 작업을 null로 만듬 * @method taskKill * @public * @return {String} */ taskKill : function() { this.filterTask = null; } }); DU.namespace("DU.widget"); /*********************************************************************************************************************** * 설명 : IE가 아닌 브라우져에서는 width가 다르기 때문에 * width에서 border width인 1px을 뺀 것을 설정 * 을 위해 커스터마이징을 함 * 작성일자 : 2012.07.13 * 작성자 : 정동호 **********************************************************************************************************************/ DU.applyObject(DU.widget.LGridView.prototype, { getColGroupHtml : function(domTable,isMultiHeader) { var colWidths = new Array(); var colCount = this.columnModel.getColumnCount(); for(var i = 0 ; i < colCount; i++) { var column = this.columnModel.getColumnAt(i); colWidths.push({ id: column.getId(), hidden: column.isHidden(), width: this.adjustColumnWidth(column.getWidth(), true) }); } colWidths = this.adjustColGroupWidths(colWidths,domTable); var colgroup = '