PageSourceSearch

https://www.icbcindia.com/Portal_Resources/js/util/utils.js

js icbcindia.com collected 2026-10-07 18:47:43 UTC 4,274 bytes, 103 lines download raw bytes

1(function (name, def) {
2    if (typeof define === "function") {
3        define(function () { return def; });
4    } else if (typeof module !== "undefined" && module.exports) {
5        module.exports = def;
6    } else {
7        this[name] = def;
8    }
9})("utils", (function (window) {
10    var document = window.document,
11        jsHash = {},
12        cssHash = {},
13        head = document.head || document.getElementsByTagName("head")[0];
14    return {
15        execFn: function (fn, data) {
16            return typeof fn === "function" ? fn.call(window, data) : window[fn].call(window, data);
17        },
18        loadJs: function (src, fn, data, hashKey) {
19            var execFn = this.execFn;
20            hashKey = hashKey || src;
21            if (jsHash[hashKey]) {
22                window.components.push(execFn(fn, data));
23                return;
24            }
25            var script = document.createElement("script");
26            script.type = "text/javascript";
27            script.src = src;
28            document.body.appendChild(script);
29            if (script.readyState) {
30                script.onreadystatechange = function () {
31                    if(this.readyState == "complete" || this.readyState == "loaded") {
32                        this.onreadystatechange = null;
33                        jsHash[hashKey] = true;
34                        window.components.push(execFn(fn, data));
35                    }
36                }
37            } else {
38                script.onload = function () {
39                    this.onload = null;
40                    jsHash[hashKey] = true;
41                    window.components.push(execFn(fn, data));
42                }
43            }
44        },
45        loadCss: function (src, hashKey) {
46            hashKey = hashKey || src;
47            if (cssHash[hashKey]) return;
48            var link = document.createElement("link");
49            link.setAttribute("rel", "stylesheet");
50            link.setAttribute("type", "text/css");
51            link.setAttribute("href", src);
52            head.appendChild(link);
53            cssHash[hashKey] = true;
54        },
55        parseTemplate: function (str, data) {
56            var fn = new Function('obj',
57                'var p=[],print=function(){p.push.apply(p,arguments);};' +
58                'with(obj){p.push(\'' + str
59                    .replace(/[\r\t\n]/g, " ")
60                    .split("<%").join("\t")
61                    .replace(/((^|%>)[^\t]*)'/g, "$1\r")
62                    .replace(/\t=(.*?)%>/g, "',$1,'")
63                    .split("\t").join("');")
64                    .split("%>").join("p.push('")
65                    .split("\r").join("\\'") +
66                "');}return p.join('');");
67            return data ? fn(data) : fn;
68        },
69        getCookie: function (name) {
70            var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"),
71                arr = document.cookie.match(reg);
72            if (arr) return unescape(arr[2]);
73            else return null;
74        },
75        removeCookie: function (name, path) {
76            var expires = new Date(),
77                cookieValue = this.getCookie(name);
78            expires.setTime(expires.getTime() - 1);
79            path = path ? "path=" + path : "";
80            if (cookieValue) document.cookie = name + "=" + cookieValue + ";" + path + ";expires=" + expires.toGMTString();
81        },
82        setCookie: function (name, value, time, path) {
83            var expires = new Date(),
84                second =  time * 1000;
85            expires.setTime(expires.getTime() + second);
86            path = path ? "path=" + path : "";
87            var strCookie = name + "=" + escape (value) + ";" + path + ";expires=" + expires.toGMTString();
88            if(decodeURI(parent.window.location.href).search(/海外分行\/(工银泰国|西班牙网站)/)===-1) {
89                document.cookie = strCookie;
90            }
91        },
92        getCookieByCis: function (cookies, name) {
93            var value = "";
94            for(var i = 0; i < cookies.length; i++){
95              var cookie = cookies[i].trim(); 
96              if(cookie.indexOf(name)===0){
97                  value = cookie.substring(name.length+1,cookie.length);
98              }    
99            }
100            return value;   
101        }
102    };
103})(window));

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.