PageSourceSearch

https://shisu.edu.cn/assets/js/utils.js

js shisu.edu.cn collected 2026-09-24 09:04:37 UTC 5,571 bytes, 145 lines download raw bytes

1//手机控制
2String.prototype.contains = function (value) {
3    if (!value)
4        return false;
5    return this.toLowerCase().indexOf(value.toLowerCase()) !== -1;
6};
7var website = (function () {
8    return {
9        isObject: function (value) {
10            ///	<summary>
11            ///	判断是否对象类型
12            ///	</summary>
13            return typeof value === "object";
14        },
15        joinUrl: function (url, param) {
16            ///	<summary>
17            ///	连接url与参数
18            ///	</summary>
19            ///	<param name="url" type="String">
20            ///	 Url
21            ///	</param>
22            ///	<param name="param" type="String">
23            ///	 参数
24            ///	</param>
25            ///	<returns type="String" />
26            if (!param)
27                return url;
28            if (url.contains("?"))
29                return url + "&" + getParams();
30            return url + "?" + getParams();
31
32            //获取参数列表
33            function getParams() {
34                if (website.isObject(param))
35                    return $.param(param);
36                return param;
37            }
38        },
39        getNoCacheUrl: function (url, param) {
40            ///	<summary>
41            ///	获取不缓存的url
42            ///	</summary>
43            ///	<param name="url" type="String">
44            ///	 Url
45            ///	</param>
46            ///	<param name="param" type="String">
47            ///	 参数
48            ///	</param>
49            ///	<returns type="String" />
50            url = website.joinUrl(url, param);
51            return website.joinUrl(url, "randomnumber=" + Math.random());
52        },
53        ajax: function (options) {
54            ///	<summary>
55            ///	提交ajax请求
56            ///	</summary>
57            ///	<param name="options" type="Object">
58            ///	jQuery ajax参数,范例:{url:"/a/b",type:"GET"},常用参数:
59            /// 1. type,请求方式,默认为Post,可选值:"GET","POST";
60            /// 2. dataType,服务器返回的数据类型,默认为json,可选值:"json","text","html","xml","script","jsonp";
61            /// 3. url,服务端地址;
62            /// 4. data: 发送参数,格式可以是参数字符串,比如"a=1&amp;b=2",也可以是js对象,比如{a:1,b:2};
63            /// 5. async: 是否异步,默认为true;
64            /// 6. success: 成功回调函数;
65            ///	</param>
66            options = options || {};
67            var fnSuccess = options.success;
68            var fnError = options.error;
69            options = $.extend({
70                type: 'POST',
71                dataType: "json"
72            }, options, {
73                success: function (result) {
74                    if (fnSuccess)
75                        fnSuccess(result);
76                },
77                error: function (result) {
78                    if (fnError) {
79                        fnError(result);
80                        return;
81                    }
82                    website.ajaxError(result);
83                }
84            });
85            $.ajax(options);
86        },
87        getById: function (id) {
88            ///	<summary>
89            ///	通过Id获取jQuery对象
90            ///	</summary>
91            ///	<param name="id" type="String">
92            ///	元素id,如果传入对象,则直接返回
93            ///	</param>
94            return website.isObject(id) ? id : $("#" + id);
95        },
96        load: function (elementId, url, data, fnLoad) {
97            ///	<summary>
98            ///	从服务端加载html到指定元素
99            ///	</summary>
100            ///	<param name="elementId" type="String">
101            ///	元素Id,也可以是jQuery对象
102            ///	</param>
103            ///	<param name="url" type="String">
104            ///	服务端地址
105            ///	</param>
106            ///	<param name="data" type="String">
107            ///	发送参数,格式可以是参数字符串,比如"a=1&amp;b=2",也可以是js对象,比如{a:1,b:2}
108            ///	</param>
109            ///	<param name="fnLoad" type="Function">
110            ///	成功加载回调函数
111            ///	</param>
112            var element = website.getById(elementId);
113            url = url || element.attr("url");
114            $.ajax({
115                url: website.getNoCacheUrl(url, data),
116                type: 'GET',
117                dataType: "html",
118                success: function (result) {
119                    element.html(result);
120                    website.initControls(element);
121                    if (fnLoad)
122                        fnLoad(result);
123                }
124            });
125        },
126        initControls: function (context) {
127            ///	<summary>
128            ///	初始化组件
129            ///	</summary>
130            ///	<param name="context" type="Object">
131            ///	上下文
132            ///	</param>
133            if ($.initBootstrap)
134                $.initBootstrap(context);
135            if ($.initPagination)
136                $.initPagination(context);
137            if ($.initSelect2)
138                $.initSelect2(context);
139        },  //ajax错误处理
140        ajaxError: function (xmlHttpRequest, ajaxOptions, error) {
141            window.alert("Http状态: " + xmlHttpRequest.status + " " + xmlHttpRequest.statusText + "\n参数: " + ajaxOptions + "\n错误:" + error + "\n" + xmlHttpRequest.responseText);
142        } 
143    }; 
144}());
145 

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.