1;!function (win, doc) { 2 var PKCms = function () { 3 this.v = '2021'; 4 if (typeof $ === "undefined") { 5 loadingJS('/statics/jquery/jquery-1.8.3.min.js'); 6 } 7 }, 8 loadingJS = function (src) { 9 var sobj = doc.createElement('script'); 10 sobj.type = "text/javascript"; 11 sobj.src = src + '?_' + Date.now(); 12 var headobj = doc.getElementsByTagName('head')[0]; 13 headobj.appendChild(sobj); 14 }, 15 apiAjax = function (action, api_url, api_params, fn) { 16 $.ajax({ 17 type: action, 18 url: api_url, 19 data: api_params, 20 dataType: "JSON", 21 cache: false, 22 success: function (result) { 23 fn(null, result); 24 }, 25 error: function (message) { 26 if (message.status === 500) { 27 fn('æå¡å¨è¿åå¼å¸¸') 28 } else { 29 fn(message); 30 } 31 } 32 }); 33 }, 34 apiResultHandler = function (apiResult, fn) { 35 if (apiResult.hasOwnProperty('isSuccess') 36 && apiResult.hasOwnProperty('msg')) { 37 if (apiResult.isSuccess) { 38 if (apiResult.hasOwnProperty('data')) { 39 fn(null, null, apiResult.data, apiResult.count); 40 } 41 } else { 42 fn(apiResult.msg, apiResult.code); 43 } 44 } 45 }, 46 bin2hex = function (s) { 47 var i, l, o = '', n; 48 s += ''; 49 for (i = 0, l = s.length; i < l; i++) { 50 n = s.charCodeAt(i) 51 .toString(16); 52 o += n.length < 2 ? '0' + n : n; 53 } 54 return o; 55 }; 56 57 PKCms.prototype.apiGet = function (api_url, api_params, fn) { 58 apiAjax("GET", api_url, api_params, fn); 59 }; 60 61 PKCms.prototype.apiPost = function (api_url, api_params, fn) { 62 apiAjax("POST", api_url, api_params, fn); 63 }; 64 65 PKCms.prototype.apiResultHandler = function (apiResult, fn) { 66 if (apiResult != null && typeof apiResult == "string") { 67 try { 68 apiResult = JSON.parse(apiResult); 69 if (typeof apiResult == "object") { 70 apiResultHandler(apiResult, fn); 71 } else { 72 console.log('no json'); 73 fn('è¿åçæ°æ®ä¸æ¯JSONæ ¼å¼', 500); 74 } 75 } catch (e) { 76 console.log('no json'); 77 fn('è¿åçæ°æ®ä¸æ¯JSONæ ¼å¼', 500); 78 } 79 } else if (typeof apiResult == "object") { 80 apiResultHandler(apiResult, fn); 81 } else { 82 console.log('no json'); 83 fn('è¿åçæ°æ®ä¸æ¯JSONæ ¼å¼', 500); 84 } 85 } 86 87 // äº¤æ¢æ°ç»å ç´ 88 PKCms.prototype.arraySort = { 89 swapItems: function(arr, index1, index2) { 90 arr[index1] = arr.splice(index2, 1, arr[index1])[0]; 91 return arr; 92 }, 93 // ä¸ç§» 94 upRecord: function(arr, index) { 95 if(index === 0) { 96 return arr; 97 } 98 return this.swapItems(arr, index, index - 1); 99 }, 100 // ä¸ç§» 101 downRecord: function(arr, index) { 102 if(index === arr.length -1) { 103 return arr; 104 } 105 return this.swapItems(arr, index, index + 1); 106 } 107 } 108 109 PKCms.prototype.getArea = function (regional_code, fn) { 110 apiGet('/index.php/RegionalLinkage/ApiGetAreaListByParent', 111 {parentCode: regional_code}, 112 function (error, apiResult) { 113 if (error) { 114 console.log('å°åºæ°æ®ï¼åºéï¼', error); 115 } else { 116 win.PKCms.apiResultHandler(apiResult, function (error, code, result, count) { 117 if (error) { 118 console.log('å°åºæ°æ®ï¼åºéï¼', error); 119 } else { 120 fn(result, count); 121 } 122 }); 123 } 124 }); 125 } 126 127 PKCms.prototype.localStorage_set = function (params) { 128 if (typeof params == "object") { 129 for (var paramsKey in params) { 130 if (paramsKey !== '') { 131 localStorage.setItem('PKCms_' + paramsKey, params[paramsKey]); 132 } 133 } 134 } 135 }; 136
137 PKCms.prototype.localStorage_get = function (key) { 138 return localStorage.getItem('PKCms_' + key); 139 }; 140 141 PKCms.prototype.localStorage_del = function (key) { 142 localStorage.removeItem('PKCms_' + key); 143 }; 144 145 PKCms.prototype.urlVarsToJSON = function (url) { 146 var hash; 147 var myJson = {}; 148 var hashes = url.slice(url.indexOf('?') + 1).split('&'); 149 for (var i = 0; i < hashes.length; i++) { 150 hash = hashes[i].split('='); 151 myJson[hash[0]] = hash[1]; 152 } 153 return myJson; 154 }; 155 156 PKCms.prototype.JSONToUrl = function (requestParams) { 157 let params = []; 158 Object.entries(requestParams).forEach(([key, value]) => { 159 let param = key + '=' + encodeURI(value); 160 params.push(param); 161 }); 162 return params.join('&'); 163 } 164 165 PKCms.prototype.uuid = function () { 166 var canvas = document.createElement('canvas'); 167 var ctx = canvas.getContext("2d"); 168 var txt = location.hostname; 169 ctx.textBaseline = "top"; 170 ctx.font = "14px 'Arial'"; 171 ctx.textBaseline = "tencent"; 172 ctx.fillStyle = "#f60"; 173 ctx.fillRect(125,1,62,20); 174 ctx.fillStyle = "#069"; 175 ctx.fillText(txt, 2, 15); 176 ctx.fillStyle = "rgba(102, 204, 0, 0.7)"; 177 ctx.fillText(txt, 4, 17); 178 179 var b64 = canvas.toDataURL().replace("data:image/png;base64,",""); 180 var bin = atob(b64); 181 return bin2hex(bin.slice(-16,-12)); 182 } 183 184 PKCms.prototype.isURL = function (str_url, callback) { 185 var strRegex = "^((https|http|ftp|rtsp|mms)?://)" 186 + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" // ftpçuser@ 187 + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IPå½¢å¼çURL- 199.194.52.184 188 + "|" // å 许IPåDOMAINï¼ååï¼ 189 + "([0-9a-z_!~*'()-]+\.)*" // åå- www. 190 + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // äºçº§åå 191 + "[a-z]{2,6})" // first level domain- .com or .museum 192 + "(:[0-9]{1,4})?" // 端å£- :80 193 + "((/?)|" // a slash isn't required if there is no file name 194 + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; 195 var re = new RegExp(strRegex); 196 callback(re.test(str_url)); 197 }; 198 199 PKCms.prototype.arrayDropByItemKey = function (list_arr, drop_key, drop_value, callback) { 200 if (typeof list_arr == "object") { 201 for (var i = 0; i < list_arr.length; i++) { 202 var tmp_item = list_arr[i]; 203 if (tmp_item.hasOwnProperty(drop_key) && (tmp_item[drop_key] == drop_value)) { 204 list_arr.splice(i, 1); 205 } 206 } 207 } 208 // console.log(list_arr); 209 callback(list_arr); 210 }; 211 212 /** 213 * 计ç®ç¾åæ¯ 214 * @param {number} num åå 215 * @param {number} total 忝 216 * @returns {number} è¿åæ°ç¾åæ¯ 217 */ 218 PKCms.prototype.Percentage = function (num, total) { 219 if (num == 0 || total == 0) { 220 return 0; 221 } 222 return (Math.round(num / total * 10000) / 100.00);// å°æ°ç¹å两ä½ç¾åæ¯ 223 }; 224 225 PKCms.prototype.nowDateTime = function () { 226 var myDate = new Date(); 227 return myDate.getFullYear() + '-' + myDate.getMonth() + '-' + myDate.getDate() + ' ' 228 + myDate.getHours() + ':' + myDate.getMinutes(); 229 }; 230 231 PKCms.prototype.formatDateTime = function (value, format) { 232 if (typeof format == "undefined") { 233 format = "yyyy-MM-dd hh:mm:ss"; 234 } 235 return value ? new Date(value * 1000).format(format) : ""; 236 } 237 238 PKCms.prototype.useAppJs = function (app_name, fn) { 239 if (typeof app_name == "string") { 240 if (app_name == 'user') { 241 loadingJS('/statics/layui/layui.js'); 242 } 243 loadingJS('/statics/pkcms/app/' + app_name + '.js'); 244 var cls_name = 'PK' + app_name.slice(0,1).toUpperCase() +app_name.slice(1).toLowerCase(); 245 console.log(cls_name); 246 var l_i = setInterval(function () { 247 console.log(Object.getOwnPropertyNames(cls_name).length); 248 if (Object.getOwnPropertyNames(cls_name).length > 0) { 249 clearInterval(l_i); 250 fn(); 251 } 252 }, 1000); 253 } 254 } 255 256 PKCms.prototype.useBDMapsJs = function (fn, APIKey) { 257 if (APIKey === undefined) { 258 let list_APIKey = ['Ikd2A16tuZY9jviM4wRNkO2Tu3DT5lwK', 'kTVcrmGo2kycDlhxdjtA3Mqe']; 259 APIKey = list_APIKey[Math.ceil(Math.random() * list_APIKey.length)]; 260 } 261 var script = document.createElement("script"); 262 script.src = "http://api.map.baidu.com/api?v=2.0&ak=" + APIKey + "&callback=initializeBaiDuMaps"; 263 document.body.appendChild(script); 264 setTimeout(function () { 265 fn(); 266 }, 500); 267 } 268 269 PKCms.prototype.JSONToUrlQuery = function (json) { 270 return Object.keys(json).map(function (key) { 271 // body... 272 return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]); 273 }).join("&"); 274 } 275 276 /* æ¶é´æ³è½¬åå¼å§ */ 277 Date.prototype.format = function (fmt) { //author: meizz 278 var o = { 279 "M+": this.getMonth() + 1, //æä»½ 280 "d+": this.getDate(), //æ¥ 281 "h+": this.getHours(), //å°æ¶ 282 "m+": this.getMinutes(), //å
283 "s+": this.getSeconds(), //ç§ 284 "q+": Math.floor((this.getMonth() + 3) / 3), //qæ¯å£åº¦ 285 "S": this.getMilliseconds() //æ¯«ç§ 286 }; 287 if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); 288 for (var k in o) 289 if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 290 return fmt; 291 } 292 293 win.PKCms = new PKCms(); 294}(window, document);
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.