PageSourceSearch

https://www.taiden.com/static/js/common.js

js taiden.com collected 2026-10-09 04:17:45 UTC 15,006 bytes, 524 lines download raw bytes

1var WST = WST || {};
2WST.v = 'a1.6.0';
3WST.checkBrowser = function(){
4	return {
5		mozilla : /firefox/.test(navigator.userAgent.toLowerCase()),
6		webkit : /webkit/.test(navigator.userAgent.toLowerCase()), 
7	    opera : /opera/.test(navigator.userAgent.toLowerCase()), 
8	    msie : /msie/.test(navigator.userAgent.toLowerCase())
9	}
10}
11WST.pageHeight = function(){
12	if(WST.checkBrowser().msie){ 
13		return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight : 
14		document.body.clientHeight; 
15	}else{ 
16		return self.innerHeight; 
17	} 
18};
19//返回当前页面宽度 
20WST.pageWidth = function(){ 
21	if(WST.checkBrowser().msie){ 
22		return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth : 
23		document.body.clientWidth; 
24	}else{ 
25		return self.innerWidth; 
26	} 
27};
28WST.TreeSelector = function(item,data,rootId,defaultValue){ 
29    this._data = data; 
30    this._item = item; 
31    this._rootId = rootId; 
32    if(defaultValue)this.defaultValue = defaultValue;
33} 
34WST.TreeSelector.prototype.createTree = function(){ 
35    var len =this._data.length; 
36    for( var i= 0;i<len;i++){ 
37         if ( this._data[i].pid == this._rootId){ 
38
39              this._item.options.add(new Option(" "+this._data[i].text,this._data[i].id)); 
40              for(var j=0;j<len;j++){ 
41                   this.createSubOption(len,this._data[i],this._data[j]); 
42              } 
43         } 
44    }
45    if(this.defaultValue)this._item.value = this.defaultValue;
46} 
47
48WST.TreeSelector.prototype.createSubOption = function(len,current,next){ 
49    var blank = ".."; 
50    if ( next.pid == current.id){ 
51         intLevel =0; 
52         var intlvl =this.getLevel(this._data,this._rootId,current); 
53         for(a=0;a<intlvl;a++) 
54              blank += ".."; 
55              blank += "├-"; 
56              this._item.options.add(new Option(blank + next.text,next.id)); 
57              for(var j=0;j<len;j++){ 
58                   this.createSubOption(len,next,this._data[j]); 
59              } 
60         } 
61    } 
62    WST.TreeSelector.prototype.getLevel = function(datasources,topId,currentitem){ 
63
64    var pid =currentitem.pid; 
65    if( pid !=topId) 
66    { 
67         for(var i =0 ;i<datasources.length;i++) 
68         { 
69              if( datasources[i].id == pid) 
70              { 
71                   intLevel ++; 
72                   this.getLevel(datasources,topId,datasources[i]); 
73              } 
74         } 
75    } 
76    return intLevel; 
77}
78//多选下拉框移动元素
79WST.multSelect = function(opts){
80    var e1 = document.getElementById(opts.left);
81    var e2 = document.getElementById(opts.right);
82    for(var i=0;i<e1.options.length;i++){
83    	if(e1.options[i].selected){
84    	    var e = e1.options[i];
85    	    e2.options.add(new Option(e.text, e.value));
86    	    e1.remove(i);
87    	    i=i-1
88    	}
89    }
90    document.getElementById(opts.val).value=getValue(document.getElementById(opts.vtarget));
91
92    function getValue(geto){
93        var ids = [];
94    	for(var i=0;i<geto.options.length;i++){
95    		ids.push(geto.options[i].value);
96    	}
97    	return ids.join(',');
98    }
99}
100// 只能輸入數字,且第一數字不能為0
101WST.digitalOnly = function(obj) {
102 	// 先把非数字的都替换掉
103 	obj.value=obj.value.replace(/\D/g, "");
104}
105/**
106 * 获取版本
107 */
108WST.getWSTMARTVersion = function(url){
109	$.post(url,{},function(data,textStatus){
110		var json = {};
111		try{
112	      if(typeof(data )=="object"){
113			json = data;
114	      }else{
115			json = eval("("+data+")");
116	      }
117		}catch(e){}
118	   if(json){
119		   if(json.version && json.version!='same'){
120			   $('.wstmart-version-tips').show();
121			   $('#wstmart_version').html(json.version);
122			   $('#wstmart_down').attr('href',json.downloadUrl);
123		   }
124		   if(json.accredit=='no'){
125			   $('.wstmart-accredit-tips').show();
126		   }
127		   if(json.licenseStatus)$('#licenseStatus').html(json.licenseStatus);
128	   }
129	});
130}
131 /******************** 
132 * 取窗口滚动条高度  
133 ******************/  
134 WST.getScrollTop = function()  
135 {  
136     var scrollTop=0;  
137     if(document.documentElement&&document.documentElement.scrollTop)  
138     {  
139         scrollTop=document.documentElement.scrollTop;  
140     }  
141     else if(document.body)  
142     {  
143         scrollTop=document.body.scrollTop;  
144     }  
145     return scrollTop;  
146 }  
147   
148 /******************** 
149 * 取文档内容实际高度  
150 *******************/  
151 WST.getScrollHeight = function()  
152 {  
153     return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);  
154 }
155
156 //只能輸入數字
157 WST.isNumberKey = function(evt){
158 	var charCode = (evt.which) ? evt.which : event.keyCode;
159 	if (charCode > 31 && (charCode < 48 || charCode > 57)){
160 		return false;
161 	}else{		
162 		return true;
163 	}
164 }  
165
166 //只能輸入數字和小數點
167 WST.isNumberdoteKey = function(evt){
168 	var e = evt || window.event; 
169 	var srcElement = e.srcElement || e.target;
170 	
171 	var charCode = (evt.which) ? evt.which : event.keyCode;			
172 	if (charCode > 31 && ((charCode < 48 || charCode > 57) && charCode!=46)){
173 		return false;
174 	}else{
175 		if(charCode==46){
176 			var s = srcElement.value;			
177 			if(s.length==0 || s.indexOf(".")!=-1){
178 				return false;
179 			}			
180 		}		
181 		return true;
182 	}
183 }
184
185 //只能輸入數字和字母
186 WST.isNumberCharKey = function(evt){
187 	var e = evt || window.event; 
188 	var srcElement = e.srcElement || e.target;	
189 	var charCode = (evt.which) ? evt.which : event.keyCode;
190
191 	if((charCode>=48 && charCode<=57) || (charCode>=65 && charCode<=90) || (charCode>=97 && charCode<=122) || charCode==8){
192 		return true;
193 	}else{		
194 		return false;
195 	}
196 }
197
198WST.isChinese = function(obj,isReplace){
199 	var pattern = /[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/i
200 	if(pattern.test(obj.value)){
201 		if(isReplace)obj.value=obj.value.replace(/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/ig,"");
202 		return true;
203 	}
204 	return false;
205 }   
206 
207Number.prototype.toFixed = function(exponent){ 
208    return parseInt(this * Math.pow(10, exponent)+0.5 )/Math.pow(10,exponent);
209}
210 
211//用户名判断 (可输入"_",".","@", 数字,字母)
212 WST.isUserName = function(evt){
213 	var evt = evt || window.event; 
214 	var charCode = (evt.which) ? evt.which : evt.keyCode;
215 	if((charCode==95 || charCode==46 || charCode==64) || (charCode>=48 && charCode<=57) || (charCode>
215=65 && charCode<=90) || (charCode>=97 && charCode<=122) || charCode==8){
216 		return true;
217 	}else{		
218 		return false;
219 	}
220 }
221 
222WST.isEmail =function(v){
223		var tel = new RegExp("^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$");
224		return(tel.test(v));
225}   
226//判断是否电话
227WST.isTel = function(v){
228	 var tel = new RegExp("^[[0-9]{3}-|\[0-9]{4}-]?(\[0-9]{8}|[0-9]{7})?$");
229	 return(tel.test(v));
230}
231WST.isPhone = function(v){
232	 var tel = new RegExp("^[1][0-9]{10}$");
233	 return(tel.test(v));
234}
235//判断url
236WST.isUrl = function(str){
237    if(str==null||str=="") return false;
238    var result=str.match(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\’:+!]*([^<>\"])*$/);
239    if(result==null)return false;
240    return true;
241}
242//比较时间差
243WST.getTimeDiff = function(startTime,endTime,diffType){
244    //将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式
245    startTime = startTime.replace(/-/g, "/");
246    endTime = endTime.replace(/-/g, "/");
247    //将计算间隔类性字符转换为小写
248    diffType = diffType.toLowerCase();
249    var sTime = new Date(startTime); //开始时间
250    var eTime = new Date(endTime); //结束时间
251    //作为除数的数字
252    var divNum = 1;
253    switch (diffType) {
254        case "second":
255             divNum = 1000;
256             break;
257        case "minute":
258             divNum = 1000 * 60;
259             break;
260        case "hour":
261             divNum = 1000 * 3600;
262             break;
263        case "day":
264             divNum = 1000 * 3600 * 24;
265             break;
266        default:
267             break;
268     }
269     return parseInt((eTime.getTime() - sTime.getTime()) / parseInt(divNum));
270}
271/**
272 * 截取字符串
273 */
274WST.cutStr = function (str,len)
275{
276	if(!str || str=='')return '';
277	var strlen = 0;
278	var s = "";
279	for(var i = 0;i < str.length;i++)
280	{
281		if(strlen >= len){
282			return s + "...";
283		}
284		if(str.charCodeAt(i) > 128)
285			strlen += 2;
286		else
287			strlen++;
288		s += str.charAt(i);
289	}
290	return s;
291}
292WST.checkChks = function(obj,cobj){
293	$(cobj).each(function(){
294		$(this)[0].checked = obj.checked;
295	})
296}
297WST.getChks = function(obj){
298	var ids = [];
299	$(obj).each(function(){
300		if($(this)[0].checked)ids.push($(this).val());
301	});
302	return ids;
303}
304WST.showHide = function(t,str){
305	var s = str.split(',');
306	if(t){
307		for(var i=0;i<s.length;i++){
308		   $(s[i]).show();
309		}
310	}else{
311		for(var i=0;i<s.length;i++){
312		   $(s[i]).hide();
313		}
314	}
315	s = null;
316}
317WST.blank = function(str,defaultVal){
318	if(str=='0000-00-00')str = '';
319	if(str=='0000-00-00 00:00:00')str = '';
320	if(!str)str = '';
321	if(typeof(str)=='null')str = '';
322	if(typeof(str)=='undefined')str = '';
323	if(str=='' && defaultVal)str = defaultVal;
324	return str;
325}
326WST.limitDecimal = function(obj,len){
327	var s = obj.value;
328 	if(s.indexOf(".")>-1){
329	 	if((s.length - s.indexOf(".")-1)>len){
330	 		obj.value = s.substring(0,s.indexOf(".")+len+1);
331	 	}
332	}
333 	s = null;
334}
335WST.getParams = function(obj){
336	var params = {};
337	var chk = {},s;
338	$(obj).each(function(){
339		if($(this)[0].type=='hidden' || $(this)[0].type=='number' || $(this)[0].type=='tel' || $(this)[0].type=='password' || $(this)[0].type=='select-one' || $(this)[0].type=='textarea' || $(this)[0].type=='text'){
340			params[$(this).attr('id')] = $.trim($(this).val());
341		}else if($(this)[0].type=='radio'){
342			if($(this).attr('name')){
343				params[$(this).attr('name')] = $('input[name='+$(this).attr('name')+']:checked').val();
344			}
345		}else if($(this)[0].type=='checkbox'){
346			if($(this).attr('name') && !chk[$(this).attr('name')]){
347				s = [];
348				chk[$(this).attr('name')] = 1;
349				$('input[name='+$(this).attr('name')+']:checked').each(function(){
350					s.push($(this).val());
351				});
352				params[$(this).attr('name')] = s.join(',');
353			}
354		}
355	});
356	chk=null,s=null;
357	return params;
358}
359WST.setValue = function(name, value){
360	var first = name.substr(0,1), input, i = 0, val;
361	if("#" === first || "." === first){
362		input = $(name);
363	} else {
364		input = $("[name='" + name + "']");
365	}
366
367	if(input.eq(0).is(":radio")) { //单选按钮
368		input.filter("[value='" + value + "']").each(function(){this.checked = true});
369	} else if(input.eq(0).is(":checkbox")) { //复选框
370		if(!$.isArray(value)){
371			val = new Array();
372			val[0] = value;
373		} else {
374			val = value;
375		}
376		for(i = 0, len = val.length; i < len; i++){
377			input.filter("[value='" + val[i] + "']").each(function(){this.checked = true});
378		}
379	} else {  //其他表单选项直接设置值
380		input.val(value);
381	}
382}
383WST.setValues = function(obj){
384	var input,value,val;
385    for(var key in obj){
386    	if($('#'+key)[0]){
387    		WST.setValue('#'+key,obj[key]);
388    	}else if($("[name='" + key + "']")[0]){
389    		WST.setValue(key,obj[key]);
390    	}
391    }
392}
393
394$(function(){
395	/**
396	 * 获取WSTMart基础配置
397	 * @type {object}
398	 */
399	WST.conf = window.conf;
400	/* 基础对象检测 */
401	WST.conf || $.error("WSTMart基础配置没有正确加载!");
402	if(WST.conf.ROUTES)WST.conf.ROUTES = eval("("+WST.conf.ROUTES+")");
403	/**
404	 * 解析URL
405	 * @param  {string} url 被解析的URL
406	 * @return {object}     解析后的数据
407	 */
408	WST.parse_url = function(url){
409		var parse = url.match(/^(?:([a-z]+):\/\/)?([\w-]+(?:\.[\w-]+)+)?(?::(\d+))?([\w-\/]+)?(?:\?((?:\w+=[^#&=\/]*)?(?:&\w+=[^#&=\/]*)*))?(?:#([\w-]+))?$/i);
410		parse || $.error("url格式不正确!");
411		return {
412			"scheme"   : parse[1],
413			"host"     : parse[2],
414			"port"     : parse[3],
415			"path"     : parse[4],
416			"query"    : parse[5],
417			"fragment" : parse[6]
418		};
419	}
420
421	WST.parse_str = function(str){
422		var value = str.split("&"), vars = {}, param;
423		for(var i=0;i<value.length;i++){
424			param = value[i].split("=");
425			vars[param[0]] = param[1];
426		}
427		return vars;
428	}
429	WST.initU = function(url,vars){
430		if(typeof vars === "string"){
431			vars = this.parse_str(vars);
432		}
433		var newUrl = WST.conf.ROUTES[url];
434	    var urlparams = newUrl.match(/<(\w+(\??))>/g);
435	    var tmpv = null;
436		for(var v in vars){
437			tmpv = '<'+v+'>';
438			if($.inArray(tmpv,urlparams)>-1){
439				newUrl = newUrl.replace(tmpv,vars[v]);
440				delete vars[v];
441			}
442		}
443		tmpv = urlparams = null;
444		if(false !== WST.conf.SUFFIX){
445			newUrl += "." + WST.conf.SUFFIX;
446		}
447		if($.isPlainObject(vars)){
448			var tmp = $.param(vars);
449			if(tmp!='')newUrl += "?"+tmp;
450			tmp = null;
451		}
452		//url = url.replace(new RegExp("%2F","gm"),"+");
453		newUrl = WST.conf.APP + "/"+newUrl;
454		return newUrl;
455	}
456	
457	WST.U0 = function(url, vars){
458		if(!url || url=='')return '';
459		var info = this.parse_url(url), path = [], reg;
460		/* 验证info */
461		info.path || $.error("url格式错误!");
462		url = info.path;
463		/* 解析URL */
464		path = url.split("/");
465		path = [path.pop(), path.pop(), path.pop()].reverse();
466		path[1] || $.error("WST.U(" + url + ")没有指定控制器");
467
468		/* 解析参数 */
469		if(typeof vars === "string"){
470			vars = this.parse_str(vars);
471		}
472		/* 解析URL自带的参数 */
473		info.query && $.extend(vars, this.parse_str(info.query));
474		if(false !== WST.conf.SUFFIX){
475			url += "." + WST.conf.SUFFIX;
476		}
477		if($.isPlainObject(vars)){
478			var tmp = $.param(vars);
479			if(tmp!='')url += "?"+tmp;
480			tmp = null;
481		}
482		//url = url.replace(new RegExp("%2F","gm"),"+");
483		url = WST.conf.APP + "/"+url;
484		return url;
485	}
486	WST.U = function(url,vars){
487		if(WST.conf.ROUTES && WST.conf.ROUTES[url]){
488		    return WST.initU(url,vars);
489		}else{
490			return WST.U0(url, vars);
491		}
492	}
493
494	WST.AU = function(url, vars){
495        if(!url || url=='')return '';
496        var info = this.parse_url(url);
497        url = info.path;
498        path = url.split("/");
499        url = "addon/";
500        path = [path.pop(), path.pop()].reverse();
501        path[0] || $.error("WST.AU(" + url + ")没有指定控制器");
502        path[1] || $.error("WST.AU(" + url + ")没有指定接口");
503        url  = url + info.scheme + "-" + path.join('-');
504        /* 解析参数 */
505		if(typeof vars === "string"){
506			vars = this.parse_str(vars);
507		}
508		info.query && $.extend(vars, this.parse_str(info.query));
509		if(false !== WST.conf.SUFFIX){
510			url += "." + WST.conf.SUFFIX;
511		}
512		if($.isPlainObject(vars)){
513			var tmp = $.param(vars);
514			if(tmp!='')url += "?"+tmp;
515			tmp = null;
516		}
517		return WST.conf.APP + "/"+url;
518	}
519});
520
521WST.replaceImg = function(v,str){
522	 var vs = v.split('.');
523     return v.replace("."+vs[1],str+"."+vs[1]);
524}

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.