1(function ($) { 2 var iPager = function (opts) { 3 4 if (!(this instanceof iPager)) return new iPager(opts); 5 6 var pp = this; 7 8 /* 9 * é»è®¤åæ° 10 * all_countï¼æ»æ¡æ° 11 * current_indexï¼æ°æ®çåºå·,ä»1å¼å§ 12 * all_pageï¼æ»é¡µç 13 * site_idï¼ç«ç¹id 14 * channel_idï¼é¢éid 15 * hasChildï¼æ¯å¦éè¦åèç¹ç¨¿ä»¶ 0-ä¸éè¦ï¼1-éè¦ 16 * page_noï¼é¡µç ï¼æ¥å£åå¼ä»0å¼å§ 17 * page_sizeï¼æ¯é¡µæ¡æ° 18 * stateï¼ç¨¿ä»¶ç¶æï¼é»è®¤30ï¼å·²åï¼ 19 * pager_modeï¼0-ä¸éè¦é¡µç æé®,1-éè¦é¡µç æé®ï¼ç¬¬2页æå¼å§ä»æ¥å£è·åæ°æ®ï¼2-éè¦é¡µç æé®ï¼ç¬¬1页å¼å§ä»æ¥å£è·åæ°æ®ï¼3-ç¹å»å è½½æ´å¤æ¨¡å¼;4-ç¹å»å è½½æ´å¤æ¨¡å¼,第1页仿¥å£è·å 20 * button_container_idï¼å页æé®å®¹å¨id 21 * list_container_idï¼åé¡µæ°æ®å®¹å¨idï¼é»è®¤ä¸ºPageList 22 * template_container_idï¼æ¨¡æ¿å®¹å¨Idï¼é»è®¤ä¸ºPageTemplate 23 * isClearï¼æ¯å¦æ¸ 空åé¡µæ°æ®å®¹å¨ï¼é»è®¤ä¸ºtrueæ¸ ç©º 24 * serverï¼æ¥å£åå 25 * apiUrlï¼æ¥å£å°å 26 * apiFunï¼æ¥å£åæ°è·åæ¹æ³ 27 * pb_first_textï¼é¦é¡µæé®æå 28 * pb_pre_textï¼ä¸ä¸é¡µæé®æå 29 * pb_next_textï¼ä¸ä¸é¡µæé®æå 30 * pb_last_textï¼å°¾é¡µæé®æå 31 * pb_more_textï¼å è½½æ´å¤æé®æå 32 * pb_confirm_textï¼è·³è½¬é¡µæ°æé®æå 33 * pb_no_more_textï¼æ²¡ææ´å¤æç¤ºæå 34 * success_call_backï¼åè°å½æ°å 35 * only_clientï¼æ¯å¦åªè°ç¨app稿件 36 * skip_indexï¼å页æ¶è·³è¿çæ¡æ° 37 * search_key_jsonï¼æ¨¡ç³æ¥è¯¢è¯å¥ 38 */ 39 pp.options = { 40 all_count: -1, 41 current_index: 0, 42 all_page: 0, 43 site_id: 0, 44 channel_id: 0, 45 hasChild: 0, 46 page_no: 0, 47 page_size: 10, 48 state: 30, 49 pager_mode: 1, 50 button_container_id: '', 51 list_container_id: 'PageList', 52 template_container_id: 'PageTemplate', 53 isClear: true, 54 server: 'https://icms3api.changsha.cn', 55 apiUrl: '/default.php?secu=public&mod=interface&a=news_list', 56 apiFun: function () { return getApiData() }, 57 pb_first_text: '|<', 58 pb_pre_text: '<<', 59 pb_next_text: '>>', 60 pb_last_text: '>|', 61 pb_more_text: 'å è½½æ´å¤', 62 pb_confirm_text: '转å°', 63 pb_no_more_text: 'æ²¡ææ´å¤äº', 64 success_call_back: '', 65 only_client: 0, 66 skip_index: 0, 67 search_key_json: '', 68 } 69 70 //跳转页ç 71 pp.goToPage = function (obj, page_no) { 72 if ($(obj).hasClass('disabled_button') || $(obj).hasClass('current_page')) { 73 return false; 74 } 75 pp.options.page_no = page_no; 76 if (pp.options.page_no == 0 || (pp.options.page_no + 1) == pp.options.all_page) { 77 getPageListData(false, true); 78 } else { 79 getPageListData(); 80 } 81 } 82 //跳转ä¸ä¸é¡µç 83 pp.goToPrePage = function (obj) { 84 if ($(obj).hasClass('disabled_button')) { 85 return false; 86 } 87 pp.options.page_no--; 88 getPageListData(); 89 } 90 //跳转ä¸ä¸é¡µç 91 pp.goToNextPage = function (obj) { 92 if ($(obj).hasClass('disabled_button')) { 93 return false; 94 } 95 pp.options.page_no++; 96 getPageListData(); 97 } 98 //跳转æå®é¡µç 99 pp.jumpToPage = function () { 100 var no = $('#' + pp.options.button_container_id + ' .jump_page').val() - 1; 101 if (no < 0 || no > (pp.options.all_page - 1)) { 102 $('#' + pp.options.button_container_id + ' .pb_confirm').attr('href', 'javascript:void(0);'); 103 alert('请è¾å ¥1~' + pp.options.all_page + 'ä¹é´ç页æ°'); 104 return false; 105 } 106 $('#' + pp.options.button_container_id + ' .pb_confirm').attr('href', '#'); 107 pp.options.page_no = no; 108 getPageListData(); 109 } 110 //å è½½æ´å¤ 111 pp.getMore = function () { 112 pp.options.page_no++; 113 getPageListData(); 114 } 115 116 //åå§åæä»¶åæ° 117 pp.options = $.extend(pp.options, opts || {}); 118 119 getPageListData(true, false); 120 121 //çææ¥å£åæ°ï¼ä¸ºäºè®©æä»¶éåºä¸åçæ¥å£ï¼æ¥å£åæ°å¯ä»¥éè¿æ¤æ¹æ³æ¹å 122 function getApiData() { 123 return { 124 'siteid': pp.options.site_id, 125 'channel_id': pp.options.channel_id, 126 'state': pp.options.state, 127 'p': pp.options.page_no, 128 'ps': pp.options.page_size, 129 'is_encrypt': 0, 130 'only_client': pp.options.only_client, 131 'haschild': pp.options.hasChild, 132 'skip_index': pp.options.skip_index, 133 'search_key_json': pp.options.search_key_json 134 } 135 } 136 137 /* 138 * è°ç¨åé¡µæ°æ®æ¥å£ 139 * firstFlag:忬¡å è½½æ å¿ 140 * mMflag:跳转é¦é¡µæå°¾é¡µæ å¿ 141 */ 142 function getPageListData(firstFlag, mMflag) { 143 var apiurl = ""; 144 if (pp.options.apiUrl.indexOf("https://") == 0 || pp.options.apiUrl.indexOf("https://") == 0) { 145 apiurl=pp.options.apiUrl; 146 } else { 147 apiurl = pp.options.server + pp.options.apiUrl; 148 } 149 $.ajax({
150 url: apiurl, 151 data: pp.options.apiFun(), 152 type: "get", 153 dataType: "json", 154 success: function (data) { 155 /* 156 * dataæ°æ®json 157 * result:åé¡µæ°æ® 158 * count:æ»æ¡æ° 159 */ 160 //æ»æ¡æ°ä¸ºundefinedã䏿¯æ°åæ-1æ¶ï¼ä»æ¥å£ä¸åå¼ 161 if (pp.options.all_count == "undefined" || isNaN(pp.options.all_count) || pp.options.all_count == -1) { 162 pp.options.all_count = data.count - pp.options.skip_index; 163 } 164 if (pp.options.pager_mode == 0) {//0-ä¸éè¦é¡µç æé®ï¼ 165 setPageListData(data); 166 } else if (pp.options.pager_mode == 1) {//1-éè¦é¡µç æé®ï¼ç¬¬2页æå¼å§ä»æ¥å£è·åæ°æ®ï¼ 167 pp.options.all_page = Math.ceil(pp.options.all_count / pp.options.page_size); 168 setPageButton(firstFlag, mMflag); 169 if (!firstFlag) { 170 setPageListData(data); 171 } 172 // pp.options.pager_mode = 0;//第ä¸é¡µæ¯éæé¡µé¢ï¼ä¸éè¦ä»æ¥å£è·åæ°æ®ï¼åªå 䏿é®åï¼æ¹ææ å¿ä½ï¼ç¬¬äºé¡µå¼å§ä»æ¥å£è·åæ°æ® 173 } else if (pp.options.pager_mode == 2) {//2-éè¦é¡µç æé®ï¼ç¬¬1页å¼å§ä»æ¥å£è·åæ°æ® 174 setPageListData(data); 175 pp.options.all_page = Math.ceil(pp.options.all_count / pp.options.page_size); 176 setPageButton(firstFlag, mMflag); 177 // pp.options.pager_mode = 0; 178 } else if (pp.options.pager_mode == 3) {//3-ç¹å»å è½½æ´å¤æ¨¡å¼ 179 pp.options.isClear = false; 180 pp.options.all_page = Math.ceil(pp.options.all_count / pp.options.page_size); 181 setPageButton(firstFlag, mMflag); 182 pp.options.pager_mode = 0; 183 } else if (pp.options.pager_mode == 4) {//4-ç¹å»å è½½æ´å¤æ¨¡å¼,第1页仿¥å£è·å 184 pp.options.isClear = false; 185 pp.options.all_page = Math.ceil(pp.options.all_count / pp.options.page_size); 186 setPageListData(data); 187 setPageButton(firstFlag, mMflag); 188 pp.options.pager_mode = 0; 189 } 190 }, 191 error: function () { 192 } 193 }); 194 } 195 196 /* 197 * æå ¥åé¡µæ°æ® 198 * dataï¼åé¡µæ°æ® 199 */ 200 function setPageListData(data) { 201 if (pp.options.isClear) { 202 $('#' + pp.options.list_container_id).empty(); 203 } 204 if (data.result) { 205 $.each(data.result, function (i, documentColumns) { 206 var temp = $('#' + pp.options.template_container_id).html(); 207 var reg = new RegExp("#\/script", "ig"); 208 temp = temp.replace(reg, '</script'); 209 pp.options.current_index++; 210 reg = new RegExp("{f_no}", "g"); 211 temp = temp.replace(reg, pp.options.current_index); 212 $.each(documentColumns, function (key, that) { 213 var reg = new RegExp("{(f_|c_)" + key + "}", "ig");//忽ç¥å¤§å°åãå ¨å±ï¼å ¼å®¹c_å½¢å¼çæ ç¾ 214 if (that == 'undefined' || that == null) { 215 temp = temp.replace(reg, ''); 216 } else { 217 temp = temp.replace(reg, that); 218 } 219 }) 220 $('#' + pp.options.list_container_id).append(temp); 221 }); 222 } 223 setPageButtonAttr(); 224 if (pp.options.success_call_back) { 225 eval(pp.options.success_call_back + '(pp)'); 226 } 227 } 228 229 /* 230 * è®¾ç½®é¡µç æé® 231 * firstFlag:忬¡å è½½æ å¿ 232 * mMflag:跳转é¦é¡µæå°¾é¡µæ å¿ 233 */ 234 function setPageButton(firstFlag, mMflag) { 235 if (pp.options.pager_mode != 3 && pp.options.pager_mode != 4) { 236 /** 237 *é¡µç æé®æ¨¡å¼ä¸(模å¼1ãæ¨¡å¼2)ï¼åªæ¾ç¤º8ä¸ªé¡µç æé®ï¼å½å页æ¯4çåæ°æ¶ï¼éæ°è®¾ç½®é¡µç æé®ï¼ä¸ä¾ç¹ç¬¬8页
238 * é¦é¡µ ä¸ä¸é¡µ 6 7 8 9 10 11 12 13 14 15 ä¸ä¸é¡µ 尾页 239 */ 240 if (firstFlag || mMflag || (pp.options.all_page > pp.options.page_no && (pp.options.page_no + 1) % 4 == 0)) { 241 $('#' + pp.options.button_container_id).empty(); 242 $('#' + pp.options.button_container_id).append("<div class='page_button_area'></div>");//æé®åºå 243 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='pb_first'>" + pp.options.pb_first_text + "</a>");//é¦é¡µé¡µæé® 244 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='pb_pre'>" + pp.options.pb_pre_text + "</a>");//ä¸ä¸é¡µæé® 245 if (pp.options.all_page > 8) { 246 if ((pp.options.page_no + 1) >= 4) { 247 var minPage = (pp.options.page_no - 4) > 0 ? (pp.options.page_no - 4) : 0; 248 for (var i = minPage; i <= pp.options.page_no; i++) { 249 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='page_no_button pb_" + i + "'>" + (i + 1) + "</a>"); 250 } 251 var maxPage = pp.options.all_page > (pp.options.page_no + 5) ? (pp.options.page_no + 5) : pp.options.all_page; 252 for (var i = pp.options.page_no + 1; i < maxPage; i++) { 253 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='page_no_button pb_" + i + "'>" + (i + 1) + "</a>"); 254 } 255 } else { 256 for (var i = pp.options.page_no; i < (pp.options.page_no + 8); i++) { 257 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='page_no_button pb_" + i + "'>" + (i + 1) + "</a>"); 258 } 259 } 260 } else { 261 //æ»é¡µç å°äºéè¦åæ®µçæ°ç®ï¼åå è½½å ¨é¨é¡µç æé® 262 for (var i = 0; i < pp.options.all_page; i++) { 263 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='page_no_button pb_" + i + "'>" + (i + 1) + "</a>"); 264 } 265 } 266 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='pb_next'>" + pp.options.pb_next_text + "</a>");//ä¸ä¸é¡µæé® 267 $('#' + pp.options.button_container_id + ' .page_button_area').append("<a class='pb_last'>" + pp.options.pb_last_text + "</a>");//尾页æé® 268 $('#' + pp.options.button_container_id + ' .page_button_area').append("<span> </span><input class='jump_page' type='number'/><a class='pb_confirm'>" + pp.options.pb_confirm_text + "</a>"); 269 $('#' + pp.options.button_container_id).append("<div class='page_info_area'>å ±" + pp.options.all_page + "页</div>");//ä¿¡æ¯åºå 270 } 271 } else { 272 $('#' + pp.options.button_container_id).empty(); 273 $('#' + pp.options.button_container_id).append("<div class='more_page_button_area'></div>");//æé®åºå 274 $('#' + pp.options.button_container_id + ' .more_page_button_area').append("<a class='pb_more'>" + pp.options.pb_more_text + "</a>");//å è½½æ´å¤ 275 } 276 bindButtonEvent(); 277 setPageButtonAttr(); 278 } 279 280 //ç»å®é¡µç æé®çäºä»¶ 281 //å ä¸ºæ¯æ¬¡è°ç¨æ¥å£é½ä¼ç»å®äºä»¶ï¼å¯¼è´äºä»¶éå¤ç»å®äºï¼æä»¥æ¯æ¬¡ç»å®ä¹åå è§£ç» 282 function bindButtonEvent() { 283 //é¦é¡µ 284 $('#' + pp.options.button_container_id + ' .pb_first').unbind('click').bind('click', function (event) { 285 event.preventDefault(); 286 pp.goToPage(this, 0); 287 }); 288 //ä¸ä¸é¡µ 289 $('#' + pp.options.button_container_id + ' .pb_pre').unbind('click').bind('click', function (event) { 290 event.preventDefault(); 291 pp.goToPrePage(this); 292 }); 293 //æ°å页ç 294 $('#' + pp.options.button_container_id + ' .page_no_button').unbind('click').bind('click', function (event) { 295 event.preventDefault(); 296 var index = parseInt($(this).text()) - 1; 297 pp.goToPage(this, index); 298 }); 299 //ä¸ä¸é¡µ 300 $('#' + pp.options.button_container_id + ' .pb_next').unbind('click').bind('click', function (event) { 301 event.preventDefault(); 302 pp.goToNextPage(this); 303 }); 304 //尾页 305 $('#' + pp.options.button_container_id + ' .pb_last').unbind('click').bind('click', function (event) { 306 event.preventDefault(); 307 pp.goToPage(this, pp.options.all_page - 1); 308 }); 309 //跳转 310 $('#' + pp.options.button_container_id + ' .pb_confirm').unbind('click').bind('click', function (event) { 311 event.preventDefault(); 312 pp.jumpToPage(); 313 }); 314 //å è½½æ´å¤ 315 $('#' + pp.options.button_container_id + ' .pb_more').unbind('click').bind('click', function (event) { 316 event.preventDefault(); 317 pp.getMore(); 318 }); 319 } 320 321 //è®¾ç½®é¡µç æé®å±æ§ 322 function setPageButtonAttr() { 323 $('#' + pp.options.button_container_id + ' .page_button_area a').removeClass('disabled_button');//ç§»é¤ææä¸å¯ç¹å»class 324 //第ä¸é¡µæ¶ï¼é¦é¡µåä¸ä¸é¡µä¸å¯ç¹å» 325 if (pp.options.page_no == 0) { 326 $('#' + pp.options.button_container_id + ' .pb_first').addClass('disabled_button'); 327 $('#' + pp.options.button_container_id + ' .pb_pre').addClass('disabled_button'); 328 } 329 //æåä¸é¡µæ¶ï¼å°¾é¡µãä¸ä¸é¡µåå è½½æ´å¤æé®ä¸å¯ç¹å» 330 if (pp.options.all_page == 0 || pp.options.page_no == (pp.options.all_page - 1)) { 331 $('#' + pp.options.button_container_id + ' .pb_next').addClass('disabled_button'); 332 $('#' + pp.options.button_container_id + ' .pb_last').addClass('disabled_button'); 333 //å è½½æ´å¤æ¨¡å¼ï¼æ´å¤æé®è®¾ç½® 334 $('#' + pp.options.button_container_id + ' .pb_more').addClass('disabled_button'); 335 $('#' + pp.options.button_container_id + ' .pb_more').text(pp.options.pb_no_more_text); 336 } 337 $('#' + pp.options.button_container_id + ' .page_no_button').removeClass('current_page');//å ä¸å½å页class 338 $('#' + pp.options.button_container_id + ' .pb_' + pp.options.page_no).addClass('current_page');//å ä¸å½å页class 339 //ç»é¡µç æé®å ä¸href='#'ï¼ä»¿é¡µé¢è·³è½¬ææ 340 $('#' + pp.options.button_container_id + ' .page_button_area a').attr('href', 'javascript:void(0);'); 341 $('#' + pp.options.button_container_id + ' .page_button_area a').not('.disabled_button,.current_page,.pb_confirm,.pb_more').attr('href', '#'); 342 } 343 344 return pp; 345 }; 346 window.iPager = iPager; 347})(window.jQuery || $); 348 349/* 350 IEä¸ajaxè·¨å请æ±ä¸æ§è¡ï¼éè¦å¨headä¸å ä¸metaï¼æå®æµè§å¨å æ ¸ 351 <meta name="renderer"content="webkit"> 352 <meta http-equiv="X-UA-Compatible" content="IE=10"> 353 */
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.