PageSourceSearch

https://www.chinaventure.com.cn/js/utils.js

js chinaventure.com.cn collected 2026-10-02 04:19:17 UTC 7,443 bytes, 195 lines download raw bytes

1//创建常量
2var ROOTPATH = window.location.href;
3var CVWEBDOMAIN = ''; 
4var OSENV = '';
5var HREFENV = '';
6var CODEENV = '';
7var BASEURL = {};
8
9//定义常量
10(function(){
11    //当前网站启用域名
12    if (ROOTPATH.indexOf('chinaventure.com.cn') !== -1) {
13        CVWEBDOMAIN = 'chinaventure'
14    } else if (ROOTPATH.indexOf('cvmedia.com.cn') !== -1) {
15        CVWEBDOMAIN = 'cvmedia'
16    }
17    //代码环境,域名不同请求地址不同
18    if (((window.location.href.indexOf('cvmedia.com.cn') !== -1) || (window.location.href.indexOf('chinaventure.com.cn') !== -1)) && (window.location.href.indexOf('new.chinaventure.com.cn') == -1)) {
19        CODEENV = 'product'
20        BASEURL = {
21            ES:{
22				//搜索
23				ESREQBASEURL1:'https://esdata.chinaventure.com.cn',
24				//敏感词
25				ESREQBASEURL2:'https://esdata.chinaventure.com.cn',
26			},
27			SSO:{
28				SSOBASEURL1: 'https://sso.chinaventure.com.cn'
29			},
30			REDIS:{
31				REDISBASEURL1: 'https://rsdata.chinaventure.com.cn'
32			}
33		}
34    } else {
35        CODEENV = 'test'
36        BASEURL = {
37            ES:{
38                //搜索
39                ESREQBASEURL1:'http://8.147.135.180:8081',
40                //敏感词
41                ESREQBASEURL2:'http://8.147.135.180:8081',
42            },
43            SSO:{
44                SSOBASEURL1: 'http://8.147.135.139:8180'
45            },
46            REDIS:{
47                REDISBASEURL1: 'http://8.147.135.180:8280'
48            }
49        }
50    }
51    //设备环境
52    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
53        OSENV = 'mobile'
54    } else {
55        OSENV = 'pc'
56    }
57    //地址属于
58    if ((ROOTPATH.indexOf('m.chinaventure') !== -1) || (ROOTPATH.indexOf('m.cvmedia') !== -1)) {
59        HREFENV = 'mobile'
60    } else {
61        HREFENV = 'pc'
62    } 
63})()
64
65console.log('<=========当前设备配置信息=========>','\n','当前地址:ROOTPATH =',ROOTPATH,'\n','启用域名:CVWEBDOMAIN =',CVWEBDOMAIN,'\n','设备环境:OSENV =',OSENV,'\n','地址环境:HREFENV =',HREFENV,'\n','开发环境:CODEENV =',CODEENV)
66
67//获取链接中字段
68function getQueryString(name) {
69    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
70    var r = window.location.search.substr(1).match(reg);
71    if(r != null) {
72          return decodeURIComponent(r[2]);
73    }
74    return '';
75}
76
77// 设置cookie
78var setCookie = function (name, value, days) {
79    let exp = new Date()
80    exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000) 
81    //document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString() + ";path=/;domain=b.com";
82    document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString() + ";path=/";
83}
84
85//读取cookie
86var getCookie = function (name) { 
87    var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
88    return v ? unescape(v[2]) : null
89} 
90
91//删除cookie
92var deletCookie = function (name) { 
93    let exp = new Date()
94    exp.setTime(exp.getTime() - 1) 
95    let cval = getCookie(name)
96    if (cval !== null) {
97        document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString() + ";path=/";
98    }     
99}
100
101//正则表达式
102var REGPhone = /^((13[0-9])|(14[5,7,9])|(15([0-9]))|(166)|(17[0-9])|(18[0-9])|(19[8|9]))\d{8}$/;
103var REGEmail = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
104var REGTestCode = /^\d{6}$/;
105var REGPassword = /^[0-9a-zA-Z]+$/;
106
107// 对Date的扩展,将 Date 转化为指定格式的String   
108// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,   
109// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)   
110// 例子:   
111// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423   
112// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18   
113Date.prototype.Format = function(fmt) {  
114    var o = {   
115        "M+" : this.getMonth()+1,                 //月份   
116        "d+" : this.getDate(),                    //日   
117        "h+" : this.getHours(),                   //小时   
118        "m+" : this.getMinutes(),                 //分   
119        "s+" : this.getSeconds(),                 //秒   
120        "q+" : Math.floor((this.getMonth()+3)/3), //季度   
121        "S"  : this.getMilliseconds()             //毫秒   
122    };   
123    if(/(y+)/.test(fmt))
124        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
125    for(var k in o)   
126        if(new RegExp("("+ k +")").test(fmt))   
127            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
128    return fmt;  
129}
130
131//转换新闻列表中的时间戳为自定义字段--依赖Date.Format()自定义方法
132//originData:需要转换的原始数组    keyword:时间戳的对应的字段名
133var turnTimestampInList = function (originData,keyword) {
134    var nowMSecond = new Date().getTime()
135    var turnedData = originData
136    for (let i = 0; i < turnedData.length; i++) {
137        var itemObj = new Date(turnedData[i][keyword]);
138        var chaMs = nowMSecond - itemObj.getTime()
139        if (chaMs >= 172800000) { //两天前
140            turnedData[i][keyword] = itemObj.Format("yyyy-MM-dd hh:mm:ss")
141        } else if (chaMs >= 86400000 && chaMs < 172800000) { //一天前
142            turnedData[i][keyword] = '一天前'
143        } else if (chaMs >= 3600000 && chaMs < 86400000) { //1~24小时
144            turnedData[i][keyword] = Math.floor(chaMs/3600000)+'小时前'
145        } else if (chaMs >= 600000 && chaMs < 3600000) {//10~60分钟
146            turnedData[i][keyword] = Math.floor(chaMs/60000)+'分钟前'
147        } else { //10分钟以内
148            turnedData[i][keyword] = '刚刚'
149        }
150    }
151    console.log('转换后的数据:',turnedData)
152    return turnedData
153}
154
155//获取设备信息
156function GetOSInfo () { 
157    var _pf = navigator.platform; 
158    var appVer = navigator.userAgent; 
159    if(_pf=="Win32" || _pf == "Windows") { 
160        if(appVer.indexOf("WOW64")>-1) { 
161            _bit = "64位"; 
162        } else { 
163            _bit = "32位"; 
164        } 
165        if(appVer.indexOf("Windows NT 6.0") > -1 || appVer.indexOf("Windows Vista") > -1) { 
166            if(_bit=='64位' || appVer.indexOf("Windows Vista") > -1){ 
167                return 'Windows_vista '+_bit; 
168            } else{ 
169                return "Unknow"; 
170            } 
171        } else if (appVer.indexOf("Windows NT 6.1") > -1 || appVer.indexOf("Windows 7") > -1) { 
172            if(_bit=='32位' || appVer.indexOf("Windows 7") > -1) { 
173                return 'Windows_7 '+_bit; 
174            } else { 
175                return "Unknow"; 
176            } 
177        } else { 
178            try { 
179                var _winName = Array('2000','XP','2003'); 
180                var _ntNum = appVer.match(/Windows NT 5.\d/i).toString(); 
181                return 'Windows_' + _winName[_ntNum.replace(/Windows NT 5.(\d)/i,"$1")]+" "+_bit; 
182            } catch(e) {
183                return 'Windows';
184            } 
185        } 
186    } else if (_pf == "Mac68K" || _pf == "MacPPC" || _pf == "Macintosh") { 
187        return "Mac"; 
188    } else if (_pf == "X11") { 
189        return "Unix"; 
190    } else if (String(_pf).indexOf("Linux") > -1) { 
191        return "Linux"; 
192    } else { 
193        return "Unknow"; 
194    } 
195}

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.