util.js
3.53 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
function aeClass(name,event,fn)
{
$("." + name).bind(event, eval(fn)).css({cursor : "pointer"}) ;
}
function aeId(name,event,fn)
{
$("#" + name).bind(event, eval(fn)).css({cursor : "pointer"}) ;
}
function aeClassNc(name,event,fn)
{
$("." + name).bind(event, eval(fn)) ;
}
function aeIdNc(name,event,fn)
{
$("#" + name).bind(event, eval(fn)) ;
}
function toggleHTML()
{
var dp = $(".sHtml").css("display") ;
if( dp == "none" )
$(".sHtml").show() ;
else
$(".sHtml").hide() ;
}
function go(url)
{
location.href = url + makeQueryString(sParam) ;
}
function goPage(url)
{
var arrEptKey = new Array("rurl") ;
location.href = url + makeQueryStringEptKey(sParam,arrEptKey) ;
}
function goRurl()
{
if( sParam == undefined )
go(LIST_SC) ;
else
location.href = decodeURIComponent(sParam["rurl"]) ;
}
function jsonAjax(type,url,params,fn,evtFn)
{
$.ajax({type:"POST",
data:params,
dataType:"json",
url:url,
success:function(data,status){
if( data == null )
{
alert("결과 데이터가 없거나 프로세스에 문제가 있습니다.") ;
return ;
}
var listData = data[0] ; //리스트 데이터셋
var retData = data[1] ; //아웃풋 데이터셋
fn(listData,retData,status) ;
if( evtFn != null )
evtFn() ;
},
error:function(request,status){
alert("AJAX 사용 문법을 점검하시기 바랍니다.\n\n" + request.responseText);
}
}) ;
}
function makeQueryString(param)
{
jQuery.extend(param) ;
var queryString = "?" ;
var isFirst = true ;
for( var key in param )
{
if( !isFirst )
queryString += "&" ;
queryString += key + "=" + encodeURIComponent(param[key]) ;
isFirst = false ;
}
return queryString ;
}
//제외할 key를 제어하여 쿼리스트링 만듦
function makeQueryStringEptKey(param,arrEptKey)
{
jQuery.extend(param) ;
var queryString = "?" ;
var isFirst = true ;
for( var key in param )
{
if( jQuery.inArray(key,arrEptKey) < 0 )
{
if( !isFirst )
queryString += "&" ;
queryString += key + "=" + encodeURIComponent(param[key]) ;
isFirst = false ;
}
}
return queryString ;
}
//값 세팅
function setValue(infoData,clsName)
{
var arrInfoForm = jQuery.makeArray($("."+clsName)) ;
var objInfoForm ;
var isFilter ;
$.each(arrInfoForm,function(){
objInfoForm = $(this).attr("fid") ;
isFilter = ( $(this).attr("filter") != undefined ) ;
if( isFilter )
{
eval($(this).attr("filter"))() ;
}
$("#"+objInfoForm).val(( infoData == null ) ? "" : infoData[objInfoForm]) ;
}) ;
}
function debug(param)
{
document.write("http://www.nowniz.com/action.php" + makeQueryString(param) );
}
function setVisibility(arrVis)
{
$.each(jQuery.makeArray($(".action")),function(){
if( jQuery.inArray($(this).attr("id"),arrVis) >= 0 )
{
$(this).show() ;
}
}) ;
}
function progress(isExec)
{
if( isExec )
$("#progress").show() ;
else
$("#progress").hide() ;
}
function popup(popId,css,isCenter,isModal)
{
if( isModal )
{
$("body").append( $("<div id=\"bgdiv\"/>").css({"background":"#333333","position":"absolute","top":0,"left":0,"z-index":10,"opacity":"0.7"}).hide().width("100%").height("100%") ) ;
$("#bgdiv").show();
}
$("#" + popId).css(css) ;
if( isCenter )
{
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#" + popId).height();
var popupWidth = $("#" + popId).width();
$("#" + popId).css({"top":windowHeight/2-popupHeight/2,"left":windowWidth/2-popupWidth/2}) ;
}
return $("#" + popId) ;
}