PageSourceSearch

https://www.nordineoubaali.com/statics/pkcms/app/common.js

js nordineoubaali.com collected 2026-10-03 18:32:30 UTC 10,664 bytes, 294 lines download raw bytes

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.