初入江湖 七級 |
var xmlDoc; /*-------------------------------------------------------------------------- ● 字符串相关函数 --------------------------------------------------------------------------*/ function Trim(s){ return s.replace(/(^\s*)|(\s*$)/g,""); } function True(s){ var reg=/^[\w\u4e00-\u9fa5ⅠⅡⅢⅣⅤⅥⅦⅧ【の】·ⅨⅩⅪⅫ\+\-]+$/; return reg.test(s); } function Length(s){ var d=0; var a=s.split(""); for (var i=0;i<a.length;i++){ if (a[i].charCodeAt(0)<299){ d++; }else{ d+=2; } } return d; } function is_number(n){ //判断是否为有理数(不是循环小数) var reg=/^[\-\+]?[1-9]*\d(\.\d+)?$/; return reg.test(n); } function is_link(str){ var reg=/^http(s)?:\/\/([\w\-]+\.)+[\w\-]+(\/[\w\-\.\/\?%#&\=]*)?$/; return reg.test(str); } function pxcode(ob){ var much=/[A-Za-z]+$/; var be=parseInt(ob.replace(much,'')); return be; } /*-------------------------------------------------------------------------- ● 验证码 --------------------------------------------------------------------------*/ var captcha_id=0; function captcha_update(name,kongjianname){ if (name=="") name='captcha_image'; if (kongjianname=="") kongjianname='captcha_val'; captcha_id++; var url=currentaddress+'Include/Captcha.php?k='+captcha_id; $_DOM(name).src=url; $_DOM(kongjianname).value=''; $_DOM(kongjianname).focus(); return false; } function captcha_true(kongjianname,baocuospan){ if (kongjianname=="") kongjianname='captcha_val'; if (baocuospan=="") baocuospan='captcha_error_span'; $_DOM(kongjianname).value=Trim($_DOM(kongjianname).value); if ($_DOM(kongjianname).value==""){ $_DOM(baocuospan).innerHTML='请输入验证码'; return false; }else{ $_DOM(baocuospan).innerHTML=''; return true; } } /*-------------------------------------------------------------------------- ● 表单相关函数 --------------------------------------------------------------------------*/ function value_radio(id){ // 获得单选框的值 var val=$_DOM(id); for (var i=0;i<val.length;i++){ if (val[i].checked) return val[i].value; } } function value_checkbox(id,explode){ // 获得复选框的值 var val=$_DOM(id); var ret=""; for (var i=0;i<val.length;i++){ if (val[i].checked){ if (ret==""){ ret=val[i].value; }else{ ret=ret+explode+val[i].value; } } } return ret; } function formarea_loaded(){ //处理IFRAME方式提交的帖子数据 try{ var msg=window.frames['form_area'].document.getElementById('msg').innerHTML; if (msg=="default") return false; else if (msg=="created") F5(true); else if (msg=="OK") window.frames['form_area'].document.location='Include/default2.php'; else topic_alert(msg,(msg=="验证码输入错误" || msg=="验证码超时,请重新输入")?'topic_alerted_yzm':'topic_alerted_else'); }catch(e){ alert('无法连接到服务器,请检查您的网络连接'); document.form1.button3.disabled=false; return false; } } function ctrlenter_submit(event,form_name,onsubmit){ if (!event) event=window.event; if (event.ctrlKey && event.keyCode==13){ if (onsubmit===true){ $(form_name).onsubmit(); }else{ $(form_name).submit(); } } } /*-------------------------------------------------------------------------- ● 搜索框 --------------------------------------------------------------------------*/ function search_submit(){ var span=document.search_form.text; span.value=Trim(span.value); if (span.value==""){ span.focus(); return false; }else{ return true; } } function set_searchtext(str){ document.search_form.text.value=str; return true; } function search_start(){ document.search_form.text.focus(); return true; } /*-------------------------------------------------------------------------- ● 模态窗口函数 --------------------------------------------------------------------------*/ function diag_close(){ try{ top.window_close(); }catch(e){ return false; } } function window_open(tit,url,wid,hei,userdefined){ top.jswindow.open(tit,url,wid,hei); } function window_close(){ top.jswindow.close(); } function Alert(title,msg,w,h,fun){ if (fun==undefined) fun=''; var ru='../Include/Alert.php?t='+title+'&m='+msg+'&fun='+fun; window_open(title,ru,w,h,true); } function Confirm(title,msg,w,h,func,bujiakuohao){ if (bujiakuohao===true) msg+="&action=nk"; window_open(title,'../Include/Confirm.php?t='+title+'&m='+msg+'&u='+func,w,h); } function window_info(){ var ret=new Array(); var scrollX=0,scrollY=0,width=0,height=0,contentWidth=0,contentHeight=0; if (typeof(window.pageXOffset)=="number"){ scrollX=window.pageXOffset; scrollY=window.pageYOffset; }else if (document.body&&(document.body.scrollLeft||document.body.scrollTop)){ scrollX=document.body.scrollLeft; scrollY=document.body.scrollTop; }else if (document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){ scrollX=document.documentElement.scrollLeft; scrollY=document.documentElement.scrollTop; } if (typeof(window.innerWidth)=="number"){ width=window.innerWidth; height=window.innerHeight; }else if (document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){ width=document.documentElement.clientWidth; height=document.documentElement.clientHeight; }else if (document.body&&(document.body.clientWidth||document.body.clientHeight)){ width=document.body.clientWidth; height=document.body.clientHeight; } if (document.documentElement&&(document.documentElement.scrollHeight||document.documentElement.offsetHeight)){ if (document.documentElement.scrollHeight>document.documentElement.offsetHeight){ contentWidth=document.documentElement.scrollWidth; contentHeight=document.documentElement.scrollHeight; }else{ contentWidth=document.documentElement.offsetWidth; contentHeight=document.documentElement.offsetHeight; } }else if (document.body&&(document.body.scrollHeight||document.body.offsetHeight)){ if (document.body.scrollHeight>document.body.offsetHeight){ contentWidth=document.body.scrollWidth; contentHeight=document.body.scrollHeight; }else{ contentWidth=document.body.offsetWidth; contentHeight=document.body.offsetHeight; } }else{ contentWidth=width; contentHeight=height; } if (height>contentHeight) height=contentHeight; if (width>contentWidth) width=contentWidth; ret['ScrollX']=scrollX; ret['ScrollY']=scrollY; ret['Width']=width; ret['Height']=height; ret['ContentWidth']=contentWidth; ret['ContentHeight']=contentHeight; return ret; } /*-------------------------------------------------------------------------- ● 文档对象操作函数 --------------------------------------------------------------------------*/ function $_DOM(id){ return document.getElementById(id); } function $_DAM(obj){ return top.document.getElementById(obj); } function dom_delete($ob){ document.body.removeChild($_DOM($ob)); return true; } function createNode(ikk,lable_name,weizhi,classname){ var nod=top.document.createElement(lable_name); if (ikk!==null) nod.id=ikk; weizhi.appendChild(nod); if (classname!==undefined && classname!==null) nod.className=classname; return nod; //返回创建的节点 } function createAttribute(name,value,weizhi){ var nod=top.document.createAttribute(name); nod.value=value; weizhi.setAttributeNode(nod); return nod; } function window_setTitle(s){ $_DOM('window_title').innerHTML=s; } function dropNode(id){ id=id.split(','); for (i=0;i<id.length;i++) dom_delete(id[i]); } function drapNode(id){ id=id.split(','); for (i=0;i<id.length;i++) top.document.body.removeChild($_DAM(id[i])); } function divPosition(e){ var x=e.offsetLeft; var y=e.offsetTop; while(e=e.offsetParent){ x+=e.offsetLeft; y+=e.offsetTop; } var t=new Array(); t['x']=x; t['y']=y; return t; } function sed(obj,con){ try{ obj.innerHTML=con; return true; }catch(e){ return false; } } function $_URL(id){ //获取url变量的值 var qs=document.location.search.replace(/\?/gi,'').split('&'); var ds=new Array(); for (var i=0;i<qs.length;i++){ qs[i]=qs[i].split('='); ds[qs[i][0]]=qs[i][1]; } if (ds[id]==undefined) ds[id]=''; return ds[id]; } /*-------------------------------------------------------------------------- ● Cookie函数 --------------------------------------------------------------------------*/ function getCookieValue(name){ var str=""; var cookies=document.cookie.split("; "); var cookiesValue=new Array(); for (var i=0;i<cookies.length;i++){ tempArr=cookies[i].split("="); if (tempArr[0]==name){ return tempArr[1]; } } return ""; } /*-------------------------------------------------------------------------- ● XML --------------------------------------------------------------------------*/ function loadXML(xmlFile){ var _xmlDoc=null; if (window.ActiveXObject) _xmlDoc=new ActiveXObject('Microsoft.XMLDOM'); else{ try{ _xmlDoc=document.implementation.createDocument('','',null); }catch(ex){ alert(ex.message); _xmlDoc=null; } } if (_xmlDoc!=null){ _xmlDoc.async=false; try{ _xmlDoc.load(xmlFile); }catch(ex){ alert(ex.message); _xmlDoc=null; } return _xmlDoc; } } function xmlvalue(obj){ try{ var r=obj.firstChild.nodeValue; return r; }catch(e){ return ''; } } /*-------------------------------------------------------------------------- ● Ajax --------------------------------------------------------------------------*/ function ajaxcode(str){ var regs=[[],['*0','*1','*2','*3','*4','*5','*6']]; regs[0][0]=/\*/gi; regs[0][1]=/\+/gi; regs[0][2]=/\//gi; regs[0][3]=/\?/gi; regs[0][4]=/&/gi; regs[0][5]=/#/gi; regs[0][6]=/%/gi; for (var i=0;i<regs[0].length;i++) str=str.replace(regs[0][i],regs[1][i]); return str; } /*-------------------------------------------------------------------------- ● 其他函数 --------------------------------------------------------------------------*/ function classpast(obj,cla){ if (classhave(obj,cla)) return obj; //若字符串中已有相同的类 if (Trim(obj)==""){ obj=cla; }else{ obj+=" "+cla; } return obj; } function classhave(obj,cla){ var abj=obj.split(" "); for (var i=0;i<abj.length;i++){ if (abj[i]==cla){ return true; } } return false; } function arraypast(vrb,val){ for (var i=0;i<vrb.length;i++) if (vrb[i]==val) return vrb; vrb[vrb.length]=val; return vrb; } function arraygetid(vrb,val){ for (var i=0;i<vrb.length;i++) if (vrb[i]==val) return i; return -1; } function arraydelete(vrb,val){ var id=arraygetid(vrb,val); if (id>-1) delete vrb[id]; return vrb; } function datelike(a,b){ a=a.split(" ")[0].split("-"); //字符串转为日期数组 b=b.split(" ")[0].split("-"); for (var i=0;i<a.length;i++) a[i]=parseInt(a[i]); //05=>5 for (i=0;i<b.length;i++) b[i]=parseInt(b[i]); return (a[0]==b[0] && a[1]==b[1] && a[2]==b[2]); } function copy($str){ window.clipboardData.setData("Text",$str); return true; } function wait(z){ var j=0; z*=100000; for (var i=0;i<z;i++) j++; alert(z); return true; } function blank(){ return true; } function Escape(str){ return escape(str); } function F5(GLM){ var b=window.location.href; if (GLM===true) b=b.replace('#','&linked='); //过滤#部分 document.location=b; return true; } function browser_ie(){ return window.attachEvent&&(!window.opera); } function spali(){ var msg=top.window.frames['newiframe'].document.getElementById('msg').innerHTML; if (msg=="default") return false; var stt="OK(name="; var str=msg.substring(0,stt.length); if (msg=="") msg="未知错误"; else if (str==stt){ var file_name=msg.split('='); file_name=file_name[1].split(')'); file_name=file_name[0]; var cot='<img class="BDE_Image" src="'+file_name+'" border="0" onload="if (this.height>428) this.height=428;if (this.width>570) this.width=570" />'; editor_insert(cot); top.window_close(); }else Alert('上传失败',msg,400,110,'spalierrored()'); } function $_DAMW(obj){ if (obj=="window_close_img") obj="window_closeimg"; //旧版本兼容代码 return $_DAM("js"+obj+String(top.jswindow_id)); } function $_WIN(fx){ if (fx==undefined) fx=0; var ob=window.frames['jswindow_iframe'+String(top.jswindow_id-fx)]; return ob; } function redir(url){ document.location=url; } function isundefined(v){ return (v=="undefined"); } function past_class(vari,name){ if (Trim(vari)==""){ return vari; }else{ return vari+' '+name; } } /*-------------------------------------------------------------------------- ● 通用函数 --------------------------------------------------------------------------*/ function spalierrored(){ with($_WIN(1)){ document.getElementById('button').disabled=false; document.getElementById('fileField').focus(); } diag_close(); } function show_membertequans(){ window_open('会员特权','Include/membertequan.php',542,205); return false; } function bdkjdgyj_play(fstr){ jswindow.open('百度空间动感影集',fstr,480,394); } function head_login(type){ try{ var xm=loadXML("../Ajax/window_login.xml").documentElement.childNodes; switch (type){ case "register": var d=1; break; default: var d=0; } var title=xm[d].firstChild.firstChild.nodeValue; var url=xm[d].childNodes[1].firstChild.nodeValue; var size=xm[d].childNodes[2].childNodes; var width=parseInt(size[0].firstChild.nodeValue); var height=parseInt(size[1].firstChild.nodeValue); jswindow.open(title,url,width,height); return false; }catch(e){ //若出错则用新窗口打开 return true; } } function code_password(str){ return (/^\w+$/i.test(str)); } /*-------------------------------------------------------------------------- ● 获取数据 --------------------------------------------------------------------------*/ xa=loadXML("../fictitious/Ajax/website.xml"); //读取虚拟目录中的xml数据文件 xn=xa.documentElement; //website根节点 var website_address=xn.getAttribute('address'); //网站根地址 var website_name=xn.getAttribute('name'); //网站名称 io=xn.childNodes[1].childNodes; //产品目录 ion=io.length; //产品数量 var website_products=new Array(); var system_board_name='侃吧'; var been,system_logo_icon; for (i=0;i<ion;i++){ //循环遍历各产品 been=io[i].getAttribute('comment'); website_products[been]=io[i].getAttribute('address'); if (been=='侃吧') system_logo_icon=io[i].childNodes[2].firstChild.nodeValue; } var tieba_address=website_products[system_board_name]; //系统首页地址 websiteaddress=tieba_address; var currentaddress='http://'+document.location.hostname+"/";
|