-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
227 lines (196 loc) Β· 5.64 KB
/
test.js
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
/**
* @file jquery.paging.js
* @brief μν리카 λͺ¨λ°μΌ μ΄λ²€νΈ νμ΄μ§ νλ¬κ·ΈμΈ / jsonλ°μ΄ν° νμ±ν
* @author MoonHS
* @bug [ ]
* @todo [ νμ΄μ§ λμμΈ λ³κ²½νμ. ex)λ²νΌ μ΄λ―Έμ§ ]
* @warning [ ]
*
*/
(function($) {
// Private Values
// νμ΄μ§ κ΄λ ¨ λ³μ
var _nCurrentPageNo = 1; // νμ¬ νμ΄μ§ λ²νΈ
var _nLimit = 50; // νμ΄μ§ λΉ λ
ΈμΆμν¬ λ μ½λ κ°μ
var _nTotalListCnt= -1; // κ²μλ μ΄ λ°©μ‘λ‘κ·Έ κ°μ
var _nTotalPage = -1; // μ΄ νμ΄μ§ λ²νΈ
var _nBlockCnt = 5; // νμ΄μ§ λΈλ κ°μ
var _szPrintDivName = ""; // νμ΄μ§ 리μ€νΈλ₯Ό λ
ΈμΆμν¬ DOM ID
var _fnCallBack = null; // νμ΄μ§ μ΄λμ μνν ν¨μ
var _szStartDate = '';
var _szEndDate= '';
///////////////////////////////////
// νμ΄μ§ μ€λΈμ νΈ
$.paging = {
/////////////////////////////////////
// Getter
getCurrentPageNo: function()
{
return _nCurrentPageNo;
},
getRowLimit: function()
{
return _nLimit;
},
getTotalListCnt: function()
{
return _nTotalListCnt;
},
getTotalPage: function()
{
return getTotalPage;
},
getBlockCnt: function()
{
return _nBlockCnt;
},
getCallback: function()
{
return _fnCallBack;
},
getStartNo: function()
{
if(_nCurrentPageNo>1)
{
var nStartNo = ((_nCurrentPageNo-1)*_nLimit);
}
else
{
var nStartNo = 0;
}
return (nStartNo>0)?nStartNo:0;
},
getEndNo: function()
{
var nEndNo = ($.paging.getStartNo()) +_nLimit;
return (nEndNo<_nTotalListCnt)?nEndNo:_nTotalListCnt;
},
//////////////////////////////////////
// setter
setPrintDivName: function(szDivName)
{
_szPrintDivName = szDivName;
},
setCurrentPageNo: function(nCurrentPageNo)
{
_nCurrentPageNo = nCurrentPageNo;
},
setRowLimit: function(nLimit)
{
_nLimit = nLimit;
},
setTotalListCnt: function(nTotalListCnt)
{
_nTotalListCnt = nTotalListCnt;
},
setTotalPage: function(nTotalPage)
{
_nTotalPage = nTotalPage;
},
setBlockCnt: function(nBlockCnt)
{
_nBlockCnt = nBlockCnt;
},
setCallback: function(fnCallBack)
{
if(typeof fnCallBack == 'function')
_fnCallBack= fnCallBack;
else
alert('ν¨μνμ
μ μΈμκ°μ λ£μ΄μ£ΌμΈμ');
},
setDate: function(szStartDate, szEndDate)
{
_szStartDate = szStartDate;
_szEndDate = szEndDate;
},
///////////////////////////////////////////
// νμ΄μ§ μΆλ ₯
print : function()
{
var _nTotalPage = parseInt(Math.ceil(_nTotalListCnt / _nLimit), 10);
//var szFirstBtn = '<a href="javascript:;" class="pre"><img src="'+ AFREECA +'/images/kfatv/ver2/bul_arw.gif" alt="μ΄μ " style="display:none;" border="0" /></a> ' ;
var szFirstBtn = '' ;
//var szEndBtn = '<a href="javascript:;" class="next"><img src="'+ AFREECA +'/images/kfatv/ver2/bul_arw.gif" alt="λ€μ" style="display:none;" border="0" /></a> ' ;
var szEndBtn = '' ;
var szFirstNum = '' ;
var szEndNum = '' ;
var szPaging = '' ;
var nPreIdx = '' ;
var nNextIdx = '' ;
var tmp_page_num = parseInt(_nCurrentPageNo / _nBlockCnt, 10)+1;
var chk = _nCurrentPageNo % _nBlockCnt;
if(chk==0 && tmp_page_num>1) tmp_page_num = tmp_page_num - 1;
var nStartPageNo = (( tmp_page_num * _nBlockCnt) - _nBlockCnt) + 1;
var nEndPageNo = -1;
// Last Page Block Number
if(_nTotalPage > (tmp_page_num * _nBlockCnt))
{
nEndPageNo = tmp_page_num*_nBlockCnt;
}
else
{
nEndPageNo = _nTotalPage;
}
if(nStartPageNo > _nBlockCnt) nPreIdx = nStartPageNo - 1;
if(nEndPageNo != _nTotalPage) nNextIdx = nEndPageNo + 1;
if(nPreIdx)
{
szFirstBtn = '<a href="javascript:$.paging.move(' + nPreIdx + ');" class="pre" >'
+ '<img src="' + AFREECA + '/images/kfatv/ver2/btn_page_pre.gif" alt"μ΄μ " border="0" /></a>';
szFirstNum = '<font class=pagination><a href="javascript:$.paging.move(1);"> 1</a></font><span> ... </span>';
}
if(nNextIdx)
{
szEndBtn = ' <a href="javascript:$.paging.move(' + nNextIdx + ');" class="next">'
+ '<img src="' + AFREECA + '/images/kfatv/ver2/btn_page_next.gif" alt="λ€μ" border="0" /></a>';
szEndNum = '<span> ... </span><a href="javascript:$.paging.move('+ _nTotalPage + ');">' + _nTotalPage + '</a>';
}
for(var idx = nStartPageNo; idx<=nEndPageNo; idx++)
{
if(_nCurrentPageNo == idx)
{
if(nStartPageNo == idx)
szPaging += '<strong class="first">' + idx + '</strong>';
else
szPaging += '<strong>' + idx + '</strong>';
}
else
{
if(nStartPageNo == idx)
szPaging += ' <a href="javascript:$.paging.move(' + idx + ');" class="first">' + idx + '</a> ';
else
szPaging += ' <a href="javascript:$.paging.move(' + idx + ');">' + idx + '</a> ';
}
}
if(!szPaging) szPaging = '<strong class="first"> 1 </strong>';
//alert(szFirstBtn + szFirstNum + szPaging + szEndNum + szEndBtn);
$("#"+ _szPrintDivName).html(szFirstBtn + szFirstNum + szPaging + szEndNum + szEndBtn);
},
////////////////////////////////////
//νμ΄μ§ μ΄λ
move : function(nMovePageNo)
{
if(nMovePageNo > _nTotalListCnt)
{
_nCurrentPageNo = _nTotalPage;
}
else if(nMovePageNo< 1 )
{
_nCurrentPageNo = 1;
}
else
{
_nCurrentPageNo = nMovePageNo;
}
$("#"+_szPrintDivName).html('');
// νμ΄μ§ μ΄λ ν μ€νν ν¨μ(μνν μ‘μ
)
//var fnCallBackFunc= $.paging.getCallback();
try{
_fnCallBack('ulList', _szStartDate, _szEndDate, $.paging.getStartNo(), $.paging.getEndNo());
}catch(e)
{
alert(e.description);
}
}
};
})(jQuery)