点击回首页
我的浏览记录 | | 帮助?
当前位置:

源码截图

源码目录树

当前路径:LetSearch/js/dxtHelper.js     // JScript source code
//dxt 2007-03-10

//开始拖动
function Start_Drag()
{
    var ComSet=document.getElementById("all");
    var str="";
    for(var i=0;i<ComSet.children.length;i++)
    {
        str+=",\""+ComSet.children[i].id+"\"";
    }
    str=str.replace(',','');
    var s;
    for(var j=0;j<ComSet.children.length;j++)
    {
        s="Sortable.create(\""+ComSet.children[j].id+"\",{dropOnEmpty:true,handle:'handle',containment:["+str+"],constraint:false,onChange:function(element){},onUpdate:function(element){}});";
        eval(s);  
    }
}

//伸缩每个小窗口
function showHide(node,self)
{	
	if(self.src.indexOf("colapse.gif")!=-1)
	{
		self.src="Images/expand.gif";
	}
	else
	{
		 self.src="Images/colapse.gif";
	}
	Effect.toggle(node,'slide'); 
	return false;
}

    //设置本地cookie
    function setcookie(name,value,t) //t为cookie保存的分钟数,如果没有,那就是默认的5个月
    {
        var cookieexp = 5*30*24*60*60*1000;
        var cookiestr=name+"="+value+";";
        var expires = "";
        var d = new Date();
        var t2=(!t)?cookieexp:t*60*1000;
        d.setTime( d.getTime() + cookieexp);
        expires = "expires=" + d.toGMTString()+";";
        document.cookie = cookiestr+ expires+";";
    }
    
   //取得本地cookie
    function getcookie(name)
    {
        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) return "";
        if ( start == -1 ) return "";
        var end = document.cookie.indexOf( ";", len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }


//生成一个表单
function $se(tag){
	return document.createElement(tag);
}


//生成表单Js
var FormBox=Class.create();
FormBox.prototype={
	initialize:function(className){
		this.container=$se("div");
		if(className)this.container.className=className;
		this.ul=$se("ul");
		this.container.appendChild(this.ul);
		this.items=new Array();
	},
	appendChild:function(e){
		this.container.appendChild(e);
	},
	getBox:function(){
		return this.container;
	},
	show:function(){
		Element.show(this.container);
		this.onShow();
	},
	hide:function(){
		Element.hide(this.container);
		this.onHide();
	},
	getValue:function(name){
		var e=this.items[name];
		if(!e)return false;
		if(!e.tagName)return false;
		var tagName=e.tagName.toLowerCase();
		if(tagName=="input"){
			if(e.type=="radio" || e.type=="checkbox"){
				return e.checked?1:0;
			}else if(e.type=="text" || e.type=="password" || e.type=="hidden"){
				return e.value;
			}else return false;
		}else if(tagName=="select"){
			for(var i=0;i<e.length;i++){
				if(e.options[i].selected)return e.options[i].value;
			}
		}else if(tagName=="textarea"){
			if(e.id.match("fckeditor")){
				var oEditor = FCKeditorAPI.GetInstance(e.id) ;
				return oEditor.GetXHTML();
			}else{
				return e.value;
			}
		}else if(tagName=="span"){
			return e.innerHTML;
		}
		return false;
	},
	setValue:function(name,value){
		var e=this.items[name];
		var tagName=e.tagName.toLowerCase();
		
		if(tagName=="input"){
			if(e.type=="radio" || e.type=="checkbox"){
				e.checked=value=='1';
			}else{
				e.value=value;
			}
		}else if(tagName=="select"){
			if(!value){
				e.selectedIndex=0;
				return;
			}
			for(var i=0;i<e.length;i++){
				var o=e.options[i];
				if(o.value==value){e.selectedIndex=i;return;}
			}
		}else if(tagName=="textarea"){
			if(e.id.match("fckeditor")){
				var oEditor = FCKeditorAPI.GetInstance(e.id) ;
				oEditor.SetHTML(value);
			}else{
				e.value=value;
			}
		}else if(tagName=="span"){
			e.innerHTML=value;
		}
		
	},
	addSelectValue:function(name,text,value){
		var e=this.items[name];
		var opt=new Option(text,value);
		e.options[e.length]=opt;
	},

	setSelectTextByValue:function(name,value,text){
		var e=this.items[name];
		for(var i=0;i<e.length;i++){
			if(e.options[i].value==value)e.childNodes[i].text=text;
		}
	},

	insertItem:function(type,name,_option){
		var e=this.getElement(type);
		var option=_option;
		
		var li;
		if(option.sameLine){
			li=this.ul.lastChild;
		}else{
			li=$se("li");
			this.ul.appendChild(li);
		}
		li.appendChild(e);
		
		if(option.liClassName)li.className=option.liClassName;
		if(option.className)e.className=option.className;
		if(option.foreLabel)this.setLabel(e,option.foreLabel,true);
		if(option.backLabel)this.setLabel(e,option.backLabel,false);
		if(option.value)e.value=option.value;
		if(option.selectArray){
			var arr=option.selectArray;
			var opt;
			for(var i=0;i<arr.length;i++){
				opt=new Option();
				opt.text=arr[i].split(",")[0];
				opt.value=arr[i].split(",")[1];
				e.options[e.length]=opt;
			}
		}
		if(option.tip){
			var span=$se("span");
			span.className="tip";
			span.innerHTML=option.tip;
			li.appendChild(span);
		}
		if(option.attributes){
			for(var p in option.attributes){
				e.setAttribute(p,eval("option.attributes."+p));
				//e[p]=option.attributes[p];
			}
		}
		this.items[name]=e;
	},
	getElement:function(type){
		var e;
		switch(type){
			case "text":
				e=$se("input");
				e.type="text";
				break;
			case "hidden":
				e=$se("input");
				e.type="hidden";
				break;
			case "password":
				e=$se("input");
				e.type="password";
				break;
			case "file":
				e=$se("input");
				e.type="file";
				break;
			case "button":
				e=$se("input");
				e.type="button";
				break;
			case "submit":
				e=$se("input");
				e.type="submit";
				break;
			case "checkbox":
				e=$se("input");
				e.type="checkBox";
				break;
			case "radio":
				e=$se("input");
				e.type="radio";
				break;
			case "textarea":
				e=$se("textarea");
				e.cols=e.rows=3;
				break;
			case "span":
			case "select":
			case "img":
			case "option":
				e=$se(type);
				break;
			case "":
				e=$se("b");
				break;
			default:
				e=$se(type);
				break;
		}
		return e;
	},
	setLabel:function(target,text,before,hideFocus){
		target.id="t"+Math.random().toString().split(".")[1];
		lbl=$se("label");
		lbl.innerHTML=text;
		lbl.htmlFor=target.id;
		if(before){
			target.parentNode.insertBefore(lbl,target);
		}else{
			target.parentNode.insertBefore(lbl,target.nextSibling);
		}
		if(hideFocus)lbl.hideFocus=true;
		else lbl.hideFocus=false;
	},
	reset:function(){
		for(var p in this.items){
			var e=eval("this.items['"+p+"']");
			if(!this.getValue(p))continue;
			this.setValue(p,"");
		}
		this.customReset();
	},
	customReset:function(){},
	onShow:function(){},
	onHide:function(){}

}

关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:4000410510
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
在线客服
分享该页面
关闭侧边栏