9506572ebfb13b304cabcd7217bd2d20314f4b7f.svn-base
5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
WPUtil = function(){} ;
WPUtil.log =
function(nm,str,org)
{
var tmp = "[" + nm + "] " + str + " :: Error = " + org ;
alert(tmp) ;
}
// obj 를 무조건 array 으로 변환한다. 데이터 타입을 마추기 위해 사용한다.
WPUtil.safeArray =
function(obj) {
obj = ( obj == undefined ) ? new Array() : obj ;
// select 객체는 자체 length 메쏘드를 가지고 있다.
if( obj.tagName != undefined && obj.tagName.toLowerCase() == "select" )
{
obj = new Array(obj)
}
else
obj = ( obj.length == undefined ) ? new Array(obj) : obj ;
return obj ;
}
// 인자로 String 으로 들어온 것 역시 배열로 리턴한다. V0.7
WPUtil.toArray =
function(obj)
{
var array = new Array() ;
if( typeof(obj) == "string" )
array.push(obj) ;
else
array = obj ;
return array ;
}
/* my Own Object Closure
/* 객체 메쏘드를 이벤트 핸들러로 사용하면 Switching Context 가 발생하기 때문에 사용한다. */
WPUtil.safeContext =
function(obj,method)
{
return function() {
eval("obj." + method + "()") ; }
}
WPUtil.safeContext2 =
function(obj,methodStr)
{
return function() {
eval("obj." + methodStr) ; }
}
// 메세지 alert 처리
WPUtil.alert =
function(msg,param)
{
var prefix = "WP Exception : " ;
alert(prefix + msg) ;
}
// 숫자에 컴마 제거하기
WPUtil.removeComma =
function(str)
{
while(str.indexOf(",") > -1) {
str = str.replace(",", "");
}
return str ;
}
// 숫자에 컴마 넣기
WPUtil.addComma =
function(str)
{
var iNum = WPUtil.removeComma(str.toString());
var aNum = iNum.split(".");
var num = "";
for(var i=0;i<aNum[0].length;i++) {
if(i > 1 && ((i+1) % 3) == 1) {
num = "," + num;
}
num = aNum[0].substr(aNum[0].length-i-1, 1) + num;
}
if(aNum.length > 1) {
return num + "." + aNum[1];
} else {
return num;
}
}
// text 필드에 자동으로 ',' 처리하기
WPUtil.autoCommaHandler =
function()
{
var num = event.srcElement.value;
if (event.srcElement.value.length >= 4) {
re = /^$|,/g;
// "$" and "," 입력 제거
num = num.replace(re, "");
var fl="" ;
if(num==0) return num
if(num<0){
num=num*(-1) ;
fl="-" ;
}
else
num=num*1 //처음 입력값이 0부터 시작할때 이것을 제거한다.
num = new String(num)
temp=""
co=3
num_len=num.length
while (num_len>0){
num_len=num_len-co
if(num_len<0){co=num_len+co;num_len=0}
temp=","+num.substr(num_len,co)+temp
}
event.srcElement.value = fl+temp.substr(1);
}
}
WPUtil.pop =
function(doURI,cmd,param,width,height,isScroll) {
if( isScroll == true ) {
mypop = window.open(
goPageURL,
goPageName,
'width='+goPageWidth+',height='+goPageHeight+',menubar=no, scrollbars=yes, resizable=yes'
);
mypop.focus() ;
}
else {
mypop = window.open(goPageURL,goPageName,'width='+goPageWidth+',height='+goPageHeight+',menubar=no, scrollbars=no, resizable=no');
mypop.focus() ;
return mypop ;
}
}
WPUtil.modalPop =
function(url, name,width,height){ // 모달 창
var myObject = new Object();
myObject.win = window;
var sFeatures="dialogHeight: " + height + "px;dialogWidth: " + width + "px;status:0;dialogHide:1;help: No;scroll:No;resizable:No";
window.showModalDialog(url, myObject, sFeatures)
}
WPUtil.IsWinXPSP2 =
function()
{
try
{
var info = window.clientInformation;
var reg1 = /[^A-Z0-9]MSIE[ ]+6.0[^A-Z0-9]/i;
var reg2 = /[^A-Z0-9]WINDOWS[ ]+NT[ ]+5.1[^A-Z0-9]/i;
if ((info.appMinorVersion.replace(/\s/g,"").toUpperCase().indexOf(";SP2;") >= 0) &&
(reg1.test(info.userAgent) == true) && (reg2.test(info.userAgent) == true))
{
return true;
}
}
catch(e)
{
return false;
}
return false;
}
// static
WPUtil.nullRadio =
function(target) {
target = WPUtil.safeArray(target) ;
var checkTrue = false ;
for(var i = 0 ; i < target.length ; i++ ) {
if( target[i].checked == true )
return true ;
}
return false ;
}
WPUtil.bin2hex =
function(s)
{
var i = 0, f = s.length, a = [];
for(;i<f;i++) a[i] = s.charCodeAt(i).toString(16);
return a.join('');
}
WPUtil.getCookie =
function(s)
{
var nameOfCookie = name + "=";
var x = 0;
while ( x <= document.cookie.length )
{
var y = (x+nameOfCookie.length);
if ( document.cookie.substring( x, y ) == nameOfCookie ) {
if ( (endOfCookie = document.cookie.indexOf( ";", y )) == -1 ) {
endOfCookie = document.cookie.length;
}
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 ) break;
}
return "";
}
WPUtil.setCookie =
function(name,value)
{
var argv = arguments;
var argc = arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "") ;
}