1let Jie = { 2 state: { 3 xhr: '', 4 isClickEvent: true 5 }, 6 tool: { 7 /** 8 * éç¥ä¿¡æ¯å¼¹çª 9 * @param msg æç¤ºä¿¡æ¯ 10 * @param callback åè°å½æ° 11 * @param config åæ° 12 */ 13 notification: function (msg, callback, config = {}) { 14 if (!config.time || parseInt(config.time) <= 0) { 15 config.time = 1400; 16 } 17 if (typeof layer === "object") { 18 layer.msg(msg, config, callback); 19 } else { 20 alert(msg); 21 let autoInterval = setInterval(function () { 22 callback(); 23 clearInterval(autoInterval); 24 }, time); 25 } 26 }, 27 /** 28 * ajaxæäº¤æ°æ® 29 * @param url æäº¤å°å 30 * @param data æäº¤æ°æ® 31 * @param callback åè°å½æ° 32 * @param isAsync æ¯å¦å¼æ¥ 33 */ 34 ajaxRequest: function (url, data, callback, isAsync = false) { 35 if (Jie.state.xhr && isAsync) { 36 Jie.state.xhr.abort(); 37 } 38 Jie.state.xhr = $.ajax({ 39 type: "POST", 40 dataType: "json", 41 url: url, 42 data: data, 43 async: isAsync, 44 success: function (result) { 45 callback(result); 46 }, 47 error: function (result) { 48 if (typeof result.responseJSON === "object") { 49 Jie.tool.notification(result.responseJSON.msg); 50 } else { 51 Jie.tool.notification(result.statusText); 52 } 53 }, 54 }); 55 }, 56 /** 57 * ajaxæäº¤form表å 58 * @param url æäº¤å°å 59 * @param data æäº¤æ°æ® 60 * @param callback åè°å½æ° 61 * @param isAsync æ¯å¦å¼æ¥ 62 */ 63 ajaxFormRequest: function (url, data, callback, isAsync = false) { 64 if (Jie.state.xhr && isAsync) { 65 Jie.state.xhr.abort(); 66 } 67 Jie.state.xhr = $.ajax({ 68 type: "POST", 69 dataType: "json", 70 url: url, 71 data: data, 72 processData: false, 73 contentType: false, 74 success: function (result) { 75 callback(result); 76 }, 77 async: isAsync, 78 error: function (result) { 79 if (typeof result.responseJSON === "object") { 80 Jie.tool.notification(result.responseJSON.msg); 81 } else { 82 Jie.tool.notification(result.statusText); 83 } 84 } 85 }); 86 } 87 }, 88 events: { 89 /** 90 * æ»å¨å°æå®idä½ç½® 91 * @param id dom ID 92 * @param top é¡¶é¨åç§»è·ç¦» 93 */ 94 scrollPosition: function (id, top = 0) { 95 let offset = $(id).offset(); 96 $('body,html').animate({ 97 scrollTop: offset.top + top 98 }); 99 }, 100 /** 101 * ç¹å»æäº¤æ°æ®äºä»¶ 102 * @param config åæ° 103 */ 104 ajaxSendEvent: function (config = {}) { 105 if (config.elem) { 106 $(config.elem).on('click', config.button ? config.button : 'button', function () { 107 if (Jie.state.isClickEvent) { 108 Jie.state.isClickEvent = false; 109 let dataForm, ajaxFun, _this = this; 110 if (config.data && typeof (config.data) === "function") { 111 dataForm = config.data(); 112 ajaxFun = Jie.tool.ajaxRequest; 113 } else { 114 dataForm = new FormData($(_this).parents('form')[0]); 115 ajaxFun = Jie.tool.ajaxFormRequest; 116 } 117 if (config.verify && typeof (config.verify) === "function" && config.verify(dataForm) === false) { 118 Jie.state.isClickEvent = true; 119 return; 120 } 121 ajaxFun(config.url, dataForm, function (result) { 122 if (result.code === 1) { 123 if (config.success && typeof (config.success) === "function") { 124 Jie.state.isClickEvent = true; 125 config.success(result); 126 } else { 127 Jie.tool.notification(result.msg, function () { 128 window.location.href = result.url ? result.url : ''; 129 }); 130 } 131 } else { 132 if (config.error && typeof (config.error) === "function") { 133 Jie.state.isClickEvent = true; 134 config.error(result); 135 } else { 136 // $("form .form-verify").click(); 137 Jie.tool.notification(result.msg, function () { 138 Jie.state.isClickEvent = true; 139 }); 140 } 141 } 142 }); 143 return false; 144 } 145 }); 146 } 147 }, 148 /** 149 * ç¹å»å è½½æ°æ®äºä»¶ 150 * @param config åæ° 151 */ 152 clickLoadMore: function (config = {}) { 153 let url = config.url ? config.url : '', template = config.template ? config.template : '', 154 page = config.page ? config.page : 1, num = config.num ? config.num : 6, 155 ajaxBox = config.box ? config.box : '#ajaxBox', button = config.button ? config.button : '#loadMore'; 156 $(document).on('click', button, function () { 157 if (Jie.state.isClickEvent) { 158 Jie.state.isClickEvent = false; 159 page++; 160 Jie.tool.ajaxRequest(url, {page: page, template: template}, function (result) { 161 Jie.state.isClickEvent = true; 162 if (result.code === 1 && result.data) { 163 if ($('<div>').html(result.data).children().length < num) { 164 $(button).hide(); 165 } 166 $(ajaxBox).append(result.data); 167 } else { 168 $(button).hide(); 169 } 170 }); 171 } 172 }); 173 }, 174 /** 175 * æ»å¨å è½½æ°æ®äºä»¶ 176 * @param config åæ° 177 */ 178 scrollLoadMore: function (config = {}) { 179 let url = config.url ? config.url : '', template = config.template ? config.template : '', 180 page = config.page ? config.page : 1, num = config.num ? config.num : 6, 181 ajaxBox = config.box ? config.box : '#ajaxBox', isScroll = true; 182 $(window).scroll(function () { 183 let pageHeight = $(window).scrollTop(), 184 thisHeight = $(ajaxBox).offset().top + $(ajaxBox).height() - $(window).height() - 300; //容å¨åºé¨è·ç¦»é¡¶é¨çè·ç¦» 185 if (pageHeight > thisHeight && kai) { 186 if (isScroll) { 187 isScroll = false; 188 page++; 189 Jie.tool.ajaxRequest(url, {page: page, template: template}, function (result) { 190 isScroll = true; 191 if (result.code === 1 && result.data) { 192 if ($('<div>').html(result.data).children().length < num) { 193 isScroll = false; 194 } 195 $(ajaxBox).append(result.data); 196 } else { 197 isScroll = false; 198 } 199 }); 200 } 201 } 202 }); 203 204 } 205 } 206}; 207 208$("form .form-verify").click(function () { 209 var verifyimg = $(this).attr("src"); 210 $(this).attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random()); 211}); 212
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.