PageSourceSearch

https://www.dingcheng.gov.cn/content/_common/base/js/power.core.js…8B-qaqOa0flfLmS1BMQMRXVWMXaQKGwTRIM9e84XxC8

js dingcheng.gov.cn collected 2026-10-02 17:06:37 UTC 10,189 bytes, 296 lines download raw bytes

1/**
2 * 此文件的头部注释
3 */
4
5/*global jQuery: false, window: false */
6
7(function ($) {
8    'use strict';
9
10    var pe,
11        tools;
12
13    pe = window.pe = {};
14
15    tools = {
16        /**
17         * 判断要加的链接符是?还是&
18         * @param {} url 
19         * @returns {} 
20         */
21        connect: function (url) {
22            var connect = "?";
23            if (url.indexOf("?") > -1) {
24                connect = "&";
25            }
26            return connect;
27        },
28        /**
29         * 不同的浏览器分割hash码
30         * @param {} url 
31         * @returns {} 
32         */
33        diffBrowserSplitHash: function (hash) {
34            var hashStr = "";
35            if (hash.indexOf("#/") > -1) {
36                hashStr = hash.split("#/")[1];
37            } else if (hash.indexOf("##") > -1) {
38                hashStr = hash.split("##")[1];
39            }
40            return hashStr;
41        },
42        /**
43         * 特殊处理state参数
44
45         * @param {} url 
46         * @returns {} 
47         */
48        FilterStateSpecialChar: function (stateParam) {
49            if (stateParam.substring(0, 1) === "/") {
50                return stateParam.substring(1);
51            }
52
53            return stateParam;
54        },
55        /**
56         * 合并Url的参数。
57         * @param {string} url 要合并参数的Url
58         * @param {Object<string,object>} param 参数 ,使用键值对对象。
59         * @returns {string} 合并完成后的js
60         */
61        connectUrl: function (url, param) {
62            var querystring = url.split('?')[1] || '';
63            var params = [];
64            if (querystring) {
65                params = querystring.split('&');
66            }
67
68            if (param) {
69                for (var item in param) {
70                    if (param.hasOwnProperty(item)) {
71                        params.push(item + '=' + param[item]);
72                    }
73                }
74            }
75
76            return url.split('?')[0] + '?' + params.join('&');
77        },
78
79        /**
80        * 生成一组随机的Id号码
81        * @param len 长度
82        * @param radix   参数
83        * @returns {string}  id号码
84        */
85        uuid: function (len, radix) {
86            len = len || 8;
87            radix = radix || 2;
88            var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
89                .split(''); // UNDONE [2014-4-17] [] 变量小写命名。这里为什么要把CHARS变量赋值给chars,而不直接用CHARS。
90            var chars = CHARS,
91                uuid = [],
92                i;
93            radix = radix || chars.length;
94            if (len) {
95                for (i = 0; i < len; i++) {
96                    uuid[i] = chars[0 | Math.random() * radix];
97                }
98            } else {
99                var r;
100                uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
101                uuid[14] = '4';
102                for (i = 0; i < 36; i++) {
103                    if (!uuid[i]) {
104                        r = 0 | Math.random() * 16;
105                        uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
106                    }
107                }
108            }
109            return uuid.join('');
110        },
111        errorResultHandler: {
112            'NotAuthenticated': function (result) {
113                window.top.location.href = result.LogOnUrl;
114
115                return '';
116            },
117
118            'NotAuthorized': function (result) {
119                return '您没有权限查看所请求的内容';
120            }
121
122        },
123        RegexHelper: {
124            Url: /(http:\/)?\/[^\/]+/
125
126        },
127        /**
128        * 裁剪字符串
129        * @param str {string} 要剪裁的字符串
130        * @param n {Number} 剪裁的长度
131        * @returns {string}  剪裁好的字符串。
132        */
133        truncateStr: function (str, n) { // UNDONE [2014-4-17] [] 函数命名不要使用简写;变量命名问题;变量统一在代码块开头命名,还是就近命名(变量i)?
134            var r = /[^\x00-\xff]/g;
135            var i;
136            if (str.replace(r, 'mm').length <= n) {
137                return str;
138            }
139            // n = n - 3;    
140            var m = Math.floor(n / 2);
141            for (i = m; i < str.length; i++) {
142                if (str.substr(0, i).replace(r, 'mm').length >= n) {
143                    return str.substr(0, i) + '...';
144                }
145            }
146
147            return str;
148        },
149        HTMLEncode: function (text) {
150            return $('<div/>').text(text).html();
151        },
152        HTMLDecode: function (text) {
153            return $('<div/>').html(text).text();
154        },
155        /*
156         * 给url增加当前的hash值
157         * @param url {string} 要增加hash值的url
158         * @return {string} 增加了hash值得url
159         */
160        AddCurrentHash: function (url) {
161            if (!!url) {
162                var hash = 'state=' + window.location.hash.replace(/^#*/, '');
163                hash = hash.replace("%20", "+");
164                url += (/\?/.test(url) ? '&' : '?') + hash;
165            }
166            return url;
167        },
168
169        /**
170         * 路径操作助手。
171         */
172        PathHelperUtils: {
173            /**
174            * 路径上传目录替换符转换为上传目录, 处理兼容情况。
175            * @param {string} path 原路径。
176            * @param {string} symbol
177            * @param {string} uploadDirectory
178            * @return {string} 返回结果。
179            */
180            ReplacePathSymbolForShow: function (path, symbol, uploadDirectory) {
181                if (!path) {
182                    return "";
183                }
184
185                symbol = symbol || "$/";
186                uploadDirectory = uploadDirectory || "/upload/";
187                path = path.TrimStartReplace("~");
188                uploadDirectory = uploadDirectory.TrimStartReplace("~");
189
190                if (path.indexOf(symbol) == 0) {
191                    path = path.replace(symbol, uploadDirectory);
192                }
193
194                if (path.toLowerCase().indexOf(uploadDirectory.toLowerCase()) == 0) {
195                    //// 上传目录前缀,默认是空字符串。
196                    var uploadPathPrefix = '';
197                    path = uploadPathPrefix + path.toLowerCase();
198                }
199
200                return path;
201            },
202            /**
203            * 路径上传目录替换符转换为上传目录, 处理兼容情况。
204            * @param {string} path 原路径。
205            * @param {string} symbol 上传目录替换符。
206            * @param {string} uploadVirtualPath 上传虚拟路径。
207            * @param {object} regExp 正则表达式RegExp对象,如果传入则使用传入的,否则使用内部正则表达式的。
208            * @return {string} 返回结果。
209            */
210            ReplaceContentSymbolForShow: function (path, symbol, uploadVirtualPath, regExp) {
211                var regexString = "((src|href)\\s*=\\s*(\"|\'))\\$?\\/(\\/|\\w|\\.|\\{|\\})*";
212                if (path && symbol && uploadVirtualPath) {
213                    path = path.TrimStartReplace("~");
214                    uploadVirtualPath = uploadVirtualPath.TrimStartReplace("~");
215
216                    if (!regExp) {
217                        regExp = new RegExp(regexString, 'gi');
218                    }
219
220                    path = path.replace(regExp, function (match, p1) {
221                        var value = match;
222                        if (match && p1 && match.indexOf(p1) == 0) {
223                            var attributeValue = match.substring(p1.length);
224                            attributeValue = attributeValue.ReplacePathSymbolForShow(symbol, uploadVirtualPath);
225                            value = p1.concat(attributeValue);
226                        }
227
228                        return value;
229                    });
230                }
231
232                return path;
233            },
234            TrimStartReplace: function (orignal, target) {
235                if (orignal && target && orignal.length >= target.length) {
236                    while (orignal && orignal.indexOf(target) == 0) {
237                        orignal = orignal.substring(target.length);
238                    }
239                }
240
241                return orignal;
242            }
243        },
244        EncryptBase64ForJs: function (original) { return window.btoa(window.encodeURIComponent(original)); },
245        DecryptBase64ForJs: function (value) { return window.decodeURIComponent(window.atob(value)); }
246    };
247
248    pe.tools = tools;
249
250    //object .create
251    if (typeof Object.create !== 'function') {
252        Object.create = function (o) {
253            var f = function () {};
254            f.prototype = o;
255
256            return new f();
257        };
258    }
259
260    //Function method
261
262    if (typeof Function.method !== 'function') {
263        Function.prototype.method = function (name, func) {
264            this.prototype[name] = func;
265            return this;
266        };
267    }
268
269    /**
270     * 替换路径中的上传占位符。
271     * @param {string} symbol 目录替换符。
272     * @param {any} uploadDirectory 上传虚拟目录路径。
273     * @return {string} 结果。
274     */
275    String.prototype.ReplacePathSymbolForShow = function (symbol, uploadDirectory) {
276        var path = this;
277        return pe.tools.PathHelperUtils.ReplacePathSymbolForShow(path, symbol, uploadDirectory);
278    };
279
280    /**
281     * 替换内容中的上传站位符。
282     * @param {string} symbol 目录替换符。
283     * @param {string} uploadpath 上传虚拟目录路径。
284     * @param {object} regExp 自定义正则。如果传入则使用传入的,如果没有则使用默认的。
285     * @return {string} 结果。
286     */
287    String.prototype.ReplaceContentSymbolForShow = function (symbol, uploadpath, regExp) {
288        var content = this;
289        return pe.tools.PathHelperUtils.ReplaceContentSymbolForShow(content, symbol, uploadpath, regExp);
290    };
291
292    String.prototype.TrimStartReplace = function (target) {
293        var orignal = this;
294        return pe.tools.PathHelperUtils.TrimStartReplace(orignal, target);
295    };
296}(jQuery));

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.