$util
- Description:
유틸리티 함수 모음
Members
(static, readonly) reportUrl :string
- Description:
현재 구동중인 report서버의 Url주소
현재 구동중인 report서버의 Url주소
Type:
- string
Example
var url = $util.reportUrl
(static, readonly) serverTime :string
- Description:
Database의 현재 날짜 및 시간(ms까지)
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#serverTime
Database의 현재 날짜 및 시간(ms까지)
Type:
- string
Example
var serverTime = $util.serverTime;
(static, readonly) serverUrl :string
- Description:
현재 구동중인 server의 Url주소
현재 구동중인 server의 Url주소
Type:
- string
Example
var url = $util.serverUrl
(static, readonly) today :string
- Description:
Client의 현재 날짜(숫자8자리)
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#today
Client의 현재 날짜(숫자8자리)
Type:
- string
Example
var date = $util.today;
(static, readonly) todayTime :string
- Description:
Client의 현재 날짜 및 시간(ms까지)
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#todayTime
Client의 현재 날짜 및 시간(ms까지)
Type:
- string
Example
var dateTime = $util.todayTime;
Methods
(static) anyEmpty(…val) → {boolean}
- Description:
값들 중 null, undefined, 공백문자열이거나 띄어쓰기만 있는 문자열, 빈 Object인 값이 하나라도 있는지 확인한다.
Example
var obj = {};
var value = this.Edit00.value;
var isNull = $util.anyEmpty(obj, value);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
val |
any |
<repeatable> |
비어있는지 여부를 체크할 object |
Returns:
비어있는 항목이 존재하는지 여부
- Type
- boolean
(static) anyNull(…val) → {boolean}
- Description:
값들 중 null, undefined 또는 빈문자열인 값이 하나라도 있는지 확인한다.
Example
var value1 = this.Edit00.value;
var value2 = this.Edit01.value;
var isNull = $util.anyNull(value1, value2);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
val |
any |
<repeatable> |
null, undefined 또는 공백문자열인지 확인할 object |
Returns:
null 인 항목이 존재하는지 여부
- Type
- boolean
(static) calcDate(year, month, dateopt) → {string}
- Description:
년 월 일을 입력받아 날짜를 계산한다.
비정상적이거나 존재하지 않는 범위의 년,월,일 값을 올바른 값으로 만들수도 있습니다
ex) 2020,02,31 -> 20200302
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#calcDate
Example
var dateTime = $util.calcDate(2020,02,31);
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
year |
number | string | 년도 |
||
month |
number | string | 월 |
||
date |
number | string |
<optional> |
1
|
일 |
Returns:
계산된 날짜(숫자8자리)
- Type
- string
(static) debounce(cfn, waitopt, formopt) → {function}
- Description:
누적 지연 호출용 함수 생성
생성된 함수는 마지막 호출 시점으로부터 특정 시간(ms)대기후 한번만 실행된다. 대기시간중 재호출시 대기시간을 다시 계산한뒤 최종 1번만 호출한다.
감싸진 함수는 결과를 직접 리턴받을 수 없습니다. (필요한 경우 함수의 파라미터로 콜백 함수를 주입하시기 바랍니다.)
Example
this.fnUpdate = $util.debounce(function(){ ... }, 200); //200ms대기
this.fnUpdate();
this.fnUpdate2 = $util.debounce(function(cfn){ cfn() })
this.fnUpdate2(() => {});
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
cfn |
function | 최종 대기 후 실행할 함수 |
||
wait |
number |
<optional> |
200
|
대기시간(ms) |
form |
nexacro.FormBase |
<optional> |
this값에 해당하는 form |
Returns:
생성된 지연 함수
- Type
- function
(static) diffDay(stdt, eddt) → {number}
- Description:
두 날짜 사이의 일 수 를 계산한다.
비교종료일보다 비교시작일이 클 경우, 음수가 반환됩니다.
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#diffDay
Example
var dateA = "19450815"
var dateB = "20000815"
var days = $util.diffDay(dateA,dateB);
Parameters:
| Name | Type | Description |
|---|---|---|
stdt |
string | 비교시작일(숫자8자리) |
eddt |
string | 비교종료일(숫자8자리) |
Returns:
두 날짜 사이의 일 수
- Type
- number
(static) diffMonth(stdt, eddt) → {number}
- Description:
두 날짜 사이의 월 수 를 계산한다.
비교종료일보다 비교시작일이 클 경우, 음수가 반환됩니다.
- Deprecated:
- Date 유틸리티를 사용 바랍니다.$date#diffMonth
Example
var dateA = "19450815"
var dateB = "20000815"
var days = $util.diffMonth(dateA,dateB);
Parameters:
| Name | Type | Description |
|---|---|---|
stdt |
string | 비교시작일(숫자8자리) |
eddt |
string | 비교종료일(숫자8자리) |
Returns:
두 날짜 사이의 달 수
- Type
- number
(static) everyEmpty(…val) → {boolean}
- Description:
값이 모두 null, undefined, 공백문자열이거나 띄어쓰기만 있는 문자열, 빈 Object인지 여부.
Example
var obj = {};
var value = this.Edit00.value;
var isNull = $util.everyEmpty(obj, value);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
val |
any |
<repeatable> |
비어있는지 여부를 체크할 object |
Returns:
모든 값이 비어있는지 여부
- Type
- boolean
(static) everyNull(…val) → {boolean}
- Description:
값들이 모두 null, undefined 또는 빈문자열인 값인지 확인한다. 하나라도 notNull이 존재하면 false
Example
var value1 = this.Edit00.value;
var value2 = this.Edit01.value;
var isNull = $util.everyNull(value1, value2);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
val |
any |
<repeatable> |
null, undefined 또는 공백문자열인지 확인할 object |
Returns:
모든 값이 null인지 여부
- Type
- boolean
(static) findFromPath(root, path) → {any}
- Description:
특정 경로의 Object 가져오기
Example
$util.findFromPath(this, "grd_list._headcells[0]");
Parameters:
| Name | Type | Description |
|---|---|---|
root |
Object | 최상위 부모 |
path |
string | 아이템 경로 |
Returns:
해당 경로의 object
- Type
- any
(static) format(text, mask) → {string}
- Description:
문자열에 마스킹을 적용해 새로운 문자열로 만든다.
nexacro의 MaskEditer의 기능을 이용합니다.
마스킹 문자열은 nexacro.MaskEditer의 strStringmask규칙을 따릅니다.
Example
var origin = "ms86@ezinc.co.kr";
var mask = $util.mask("email",origin,true);
var mailAddress = $util.format(origin,mask);
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | 마스킹 대상 문자열 |
mask |
string | 마스크용 format 문자열 |
Returns:
마스킹 적용된 문자열
- Type
- string
(static) getFirstFocusableComp(root) → {nexacro.Components}
- Description:
해당 컴포넌트 내부 가장 처음 포커싱 가능한 컴포넌트 찾음
- Deprecated:
- Comp 유틸리티를 사용 바랍니다.$comp#getFirstFocusable
Example
$util.getFirstFocusableComp(this.Div00)
Parameters:
| Name | Type | Description |
|---|---|---|
root |
nexacro.Components | 최상위 부모 |
Returns:
처음 포커싱 가능한 컴포넌트
- Type
- nexacro.Components
(static) getFirstStrMathedValue(target, value) → {string}
- Description:
특정 문자열(target)에 다른 문자열의 값(value)이 존재하는지 확인한 후 처음으로 일치하는 요소를 리턴합니다.
- Deprecated:
- String 유틸리티를 사용 바랍니다.$str#getFirstMathedValue
Example
var str = $util.getFirstStrMathedValue("다람쥐 쳇바퀴에 타고파", "생쥐,쳇바퀴,타고") // "쳇바퀴"
Parameters:
| Name | Type | Description |
|---|---|---|
target |
string | 특정 문자열이 속해 있는지 검사할 문자열 |
value |
string | Array.<string> | 검사에 사용할 문자열, 여러 문자열일 경우 ','을 삽입해 구분하거나 문자열의 배열을 입력 |
Returns:
처음으로 일치하는 요소
- Type
- string
(static) getLastFocusableComp(root) → {nexacro.Components}
- Description:
해당 컴포넌트 내부 가장 마지막 포커싱 가능한 컴포넌트 찾음
- Deprecated:
- Comp 유틸리티를 사용 바랍니다.$comp#getLastFocusable
Example
$util.getLastFocusableComp(this.Div00)
Parameters:
| Name | Type | Description |
|---|---|---|
root |
nexacro.Components | 최상위 부모 |
Returns:
마지막 포커싱 가능한 컴포넌트
- Type
- nexacro.Components
(static) getSystemId(compopt) → {string}
- Description:
시스템 고유 식별자
Example
var system = $util.getSystemId(this);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
comp |
nexacro.Components |
<optional> |
컴포넌트, 생략시 로컬 사용자 정보의 시스템구분코드를 따름, 입력시 해당 컴포넌트가 속한 화면의 시스템구분코드를 따름 |
Returns:
해당 컴포넌트의 속한 화면의 system 구분 코드
- Type
- string
(static) getUser() → {Object}
- Description:
현재 접속중인 유저 정보를 Object로 return.
Example
var userInfo = $util.getUser();
Returns:
현재 접속중인 사용자 정보
- Type
- Object
(static) getUserId() → {string}
- Description:
현재 접속중인 유저 ID return.
로그인 상태가 아니라면 undefined를 return합니다.
Example
var userId = $util.getUserId();
Returns:
현재 접속중인 유저 ID
- Type
- string
(static) getUserIp() → {string}
- Description:
현재 접속중인 유저 IP return.
Example
var userId = $util.getUserIp();
Returns:
현재 접속중인 유저 IP
- Type
- string
(static) isDesktop() → {boolean}
- Description:
현재 어플리케이션의 스크린유형이 desktop인지 여부
Returns:
스크린유형이 desktop인지 여부
- Type
- boolean
(static) isDesktopDevice() → {boolean}
- Description:
현재 어플리케이션의 기기유형이 desktop인지 여부
Returns:
기기유형이 desktop인지 여부
- Type
- boolean
(static) isEmpty(val) → {boolean}
- Description:
Object가 null, undefined, 공백문자열이거나 띄어쓰기만 있는 문자열, 빈 Object인지 확인한다.
Example
var obj = {}
var isEmpty = $util.isEmpty(obj);
Parameters:
| Name | Type | Description |
|---|---|---|
val |
any | 비어있는지 여부를 체크할 object |
Returns:
비어있는지 여부
- Type
- boolean
(static) isInstanceOf(inst, clsNameopt) → {boolean}
- Description:
객체가 특정 클래스의 인스턴스인지 확인한다 opener가 nexacro인경우, opener의 클래스와도 비교한다.
Example
var isDataset = $util.isInstanceOf(ds, "nexacro.Dataset");
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
inst |
object | 인스턴스 |
|
clsName |
string |
<optional> |
비교할 클래스명, globalThis 기준 |
Returns:
해당 클래스의 인스턴스여부
- Type
- boolean
(static) isMobile() → {boolean}
- Description:
현재 어플리케이션의 스크린유형이 mobile인지 여부
- mobile_large, mobile_medium, mobile_small 모두 mobile로 취급합니다.
Returns:
스크린유형이 mobile인지 여부
- Type
- boolean
(static) isMobileDevice() → {boolean}
- Description:
현재 어플리케이션의 기기유형이 mobile인지 여부
Returns:
기기유형이 mobile인지 여부
- Type
- boolean
(static) isMobileLarge() → {boolean}
- Description:
현재 어플리케이션의 스크린유형이 mobile_large인지 여부
Returns:
스크린유형이 mobile_large인지 여부
- Type
- boolean
(static) isMobileMedium() → {boolean}
- Description:
현재 어플리케이션의 스크린유형이 mobile_medium인지 여부
Returns:
스크린유형이 mobile_medium인지 여부
- Type
- boolean
(static) isMobileSmall() → {boolean}
- Description:
현재 어플리케이션의 스크린유형이 mobile_small인지 여부
Returns:
스크린유형이 mobile_small인지 여부
- Type
- boolean
(static) isNull(val) → {boolean}
- Description:
Object가 null, undefined 또는 빈문자열인지 확인한다.
Example
var value = this.Edit00.value;
var isNull = $util.isNull(value);
Parameters:
| Name | Type | Description |
|---|---|---|
val |
any | null, undefined 또는 공백문자열인지 확인할 object |
Returns:
null 여부
- Type
- boolean
(static) jsonToParam(obj) → {string}
- Description:
Object를 Parameter용 문자열로 만듭니다.
Example
var obj = {a : "test", b : "code"};
var param = $util.jsonToParam(obj);
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | Param문자열로 만들 json객체 |
Returns:
param문자열
- Type
- string
(static) jsonToString(obj)
- Description:
Object의 내용을 Json형식의 문자열로 만듭니다
디버깅을 위해 제공하는 함수입니다.
실제 운영시에는 심각한 속도 저하를 동반할 수 있으니 디버깅 완료후 반드시 삭제하도록 합니다.
Example
this.onitemchanged = function(obj:nexacro.Combo,e:nexacro.ItemChangeEventInfo){
var str = $util.jsonToString(obj);
$logger.info(str);
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | json문자열로 만들 객체 |
(static) mask(type, text, doHidingopt) → {string}
- Description:
마스킹용 문자열 생성
값을 수정 해야 할 경우가 아니라면, 데이터베이스에서 값을 가져올 때 마스킹 처리를 해서 가져오는것을 기본으로 합니다
마스킹 처리를 하더라도 브라우저의 디버깅 툴을 통해 마스킹 되지 않은 내용을 볼 수 있음에 주의합니다.
생성된 mask format은 nexacro.MaskEditer의 strStringmask규칙을 따르고 있습니다.
Example
var origin = "ms86@ezinc.co.kr";
var mask = $util.mask("email",origin,true);
var mailAddress = $util.format(origin,mask);
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
type |
"jumin" | "card" | "passport" | "account" | "phone" | "id" | "email" | 마스크유형
|
||
text |
string | 마스킹 대상 문자열 |
||
doHiding |
boolean |
<optional> |
true
|
일부 숨김 처리 여부 |
Returns:
마스크용 format 문자열(nexacro.MaskEditer의 strStringmask규칙을 따름)
- Type
- string
(static) nameMasking(text) → {string}
- Description:
이름을 마스킹 처리합니다.(기본 마스크는 한글이 지원되지 않습니다.)
Example
var origin = "이지아이앤씨";
var maskedName = $util.nameMasking(origin);
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | 마스킹 대상 이름 |
Returns:
마스킹 적용된 이름
- Type
- string
(static) nvl(val, defaultVal) → {any}
- Description:
특정 값이 null/undefined/공백문자열에 해당하면 , 대체값을, 아니라면 원본값을 return하는 함수
Example
var origin = this.Calendar00.value;
var value = $util.nvl(origin,"20000101");
Parameters:
| Name | Type | Description |
|---|---|---|
val |
any | 원본 값 |
defaultVal |
any | 원본이 null/undefined/공백문자열에 해당할 경우, 대체할 대체값 |
Returns:
대체 처리된 값
- Type
- any
(static) nvl2(val, notNullVal, nullVal) → {any}
- Description:
특정 값이 null/undefined/공백문자열이 아니면 첫번째 대체값을, null/undefined/공백문자열에 해당하면 두번째 대체값을 return하는 함수
Example
var origin = this.Edit00.value;
var value = $util.nvl2(origin,"["+origin+"]","[입력없음]");
Parameters:
| Name | Type | Description |
|---|---|---|
val |
any | 원본 값 |
notNullVal |
any | 원본이 null/undefined/공백문자열이 아닐경우 대체할 값 |
nullVal |
any | null/undefined/공백문자열일경우 대체할 값 |
Returns:
대체 처리된 값
- Type
- any
(static) paramToJson(text) → {Object}
- Description:
Param형태의 문자열을 Json객체로 만듭니다.
Example
var text = 'a="안녕 하세요" b=\'HI~\' c= d="안녕=하세요" "e"="test"';
var obj = $util.paramToJson(text);
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | Json으로 만들 문자열 |
Returns:
Json객체화된 param정보
- Type
- Object
(static) patchField(origin, field) → {string}
- Description:
특정 문자열(target)에 바인딩 처리를 수행합니다.
- Deprecated:
- String 유틸리티를 사용 바랍니다.$str#patchField
Example
var origin = "[{0}님에게 메시지] {0}님의 {1}을 축하합니다";
var arr = ["홍길동","생일"];
var result = $util.patchField(origin, arr);
//[홍길동님에게 메시지] 홍길동님의 생일을 축하합니다.
var origin = "{0}<은/는> {1}<이/가> 아닙니다. {2}<와/과> {3}<을/를> 지참하여 관련 부서에 문의하세요"
var arr = ["신입생","신청대상","확인증","신청서"];
var result = $util.patchField(origin, arr);
//신입생은 신청대상이 아닙니다. 확인증과 신청서를 지참하여 관련 부서에 문의하세요
Parameters:
| Name | Type | Description |
|---|---|---|
origin |
string | 바인딩 가능한 문자열, 바인딩하고자 하는 요소는 {index} 형태로 기입, 바인딩 요소중 해당 index의 값이 바인딩됨, |
field |
Array.<string> | 바인딩 요소의 배열, |
Returns:
바인딩 처리된 문자열
- Type
- string
(static) printJson(obj)
- Description:
Object의 내용을 console창에 Json형식의 문자열로 출력
디버깅을 위해 제공하는 함수입니다.
실제 운영시에는 심각한 속도 저하 혹은 재귀현상을 동반할 수 있으니 디버깅 완료후 반드시 삭제하도록 합니다.
Example
this.onitemchanged = function(obj:nexacro.Combo,e:nexacro.ItemChangeEventInfo){
$util.printJson(e);
};
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object |
(static) random(lengthopt, typeopt) → {string}
- Description:
random 숫자와 알파뱃이 섞인 랜덤한 문자열을 생성
Example
var str = $util.random(10);
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
length |
number | string |
<optional> |
10
|
숫자일경우 생성할 문자열 길이, 문자일경우 해당 문자열의 길이에 해당하는 문자열이 생성됨 |
type |
string |
<optional> |
'nul'
|
n이 포함되어있을경우 숫자를 포함, u이 포함되어있을경우 대문자포함, l이포함되어있을경우 소문자 포함 |
Returns:
컴포넌트 경로
- Type
- string
(static) testExpr(ds, row, expr)
- Description:
expr형태의 문장을 해석해 값을 만든다.
Example
var expr = "CD > 0 ? 'text' : 'none'";
var value = $util.testExpr(this.Dataset00,0,expr);
Parameters:
| Name | Type | Description |
|---|---|---|
ds |
nexacro.Dataset | expr해석에 사용할 데이터셋 |
row |
number | expr해석에 사용할 데이터가 있는 row |
expr |
string | expr문장 |
(static) toBoolean() → {boolean}
- Description:
입력값을 boolean으로 변경한다.
Returns:
boolean변경된 값, true, "false"나 "NaN"이외의 문자, 0이 아닌 숫자는 true가된다.
- Type
- boolean
(static) uuid() → {string}
- Description:
uuid v4 생성
Example
var str = $util.uuid();
Returns:
생성된 UUID
- Type
- string
(static) waitCursor(cfn, formopt) → {function}
- Description:
waitCursor 래핑 함수
감싸진 함수는 실행 전 waitCursor를 표시하고 실행 완료후(에러포함) waitCursor가 사라진다.
감싸진 함수는 결과를 직접 리턴받을 수 없습니다. (필요한 경우 함수의 파라미터로 콜백 함수를 주입하시기 바랍니다.)
Example
this.fnUpdate = $util.waitCursor(function(){ ... });
this.fnUpdate();
this.fnUpdate2 = $util.waitCursor(function(cfn){ cfn() })
this.fnUpdate2(() => {});
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cfn |
function | 최종 대기 후 실행할 함수 |
|
form |
nexacro.FormBase |
<optional> |
this값에 해당하는 form, 생략시 함수의 this가 사용됨 단, 이 경우 함수의 this는 Form이거나 mainframe이어야함 |
Returns:
생성된 래핑 함수
- Type
- function
(static) withProgress(cfn, optionopt, formopt) → {function}
- Description:
프로그래스바 컨트롤 함수 전달된 배열의 수 만큼 콜백 함수를 실행하며 프로그래스바의 진행도를 조정한다.
Example
this.fnUpdate = $util.withProgress(function(){ ... });
this.fnUpdate([0, 1, 2]);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cfn |
function | 반복 실행할 함수 |
|
option |
EzUtil.ProgressOption |
<optional> |
커스텀 옵션 |
form |
nexacro.FormBase |
<optional> |
this값에 해당하는 form |
Returns:
생성된 컨트롤 함수, 첫 번째 인자로 배열을 받는다.
- Type
- function