www.gusucode.com > SiteEngine(建站引擎) 7.0 个人免费版源码程序 > admin/images/admincp.js

    window.onerror = function(){return true;}
function strsub(str, len, hasDot)
{
    var newLength = 0;
    var newStr = "";
    var chineseRegex = /[^\x00-\xff]/g;
    var singleChar = "";
    var strLength = str.replace(chineseRegex,"**").length;
    for(var i = 0;i < strLength;i++)
    {
        singleChar = str.charAt(i).toString();
        if(singleChar.match(chineseRegex) != null)
        {
            newLength += 2;
        }
        else
        {
            newLength++;
        }
        if(newLength > len)
        {
            break;
        }
        newStr += singleChar;
    }
    if(hasDot && strLength > len)
    {
        newStr += "...";
    }
    return newStr;
}


function modelesswin(url,mwidth,mheight)
{
	if (document.all&&window.print)
	eval('window.showModelessDialog(url,"","help:0;resizable:0;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
	else
	eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
}

function actionmouseover(obj)
{
	//$('#'+obj).show();
	document.getElementById(obj).style.display = "";
}
function actionmouseout(obj)
{
	document.getElementById(obj).style.display = "none";
}

function showadv(obj)
{
	for (i=1; i< myArray.length+100; i++)
	{
		if (obj==i)
		{
			if (document.getElementById("siteengine"+i))
			{
		 		document.getElementById("siteengine"+i).style.display = "";
		 	}
		}
		else
		{
			if (document.getElementById("siteengine"+i))
			{
		 		document.getElementById("siteengine"+i).style.display = "none";
		 	}
		}
	}
}

// 取得地址栏中的styleid值
function  getstyleid()
{
	//构造参数对象并初始化
	var  name,value,i;
	var  str=parent.location.href;// 获得浏览器地址栏URL串
	var  num=str.indexOf("?")
	str=str.substr(num+1);// 截取“?”后面的参数串
	var  arrtmp=str.split("&");// 将各参数分离形成参数数组
	for(i=0;i  <  arrtmp.length;i++)
	{
		num=arrtmp[i].indexOf("=");
		if(num>0)
		{
			name=arrtmp[i].substring(0,num);// 取得参数名称
			if(name=='styleid')
			{
				value=arrtmp[i].substr(num+1);// 取得参数值
				return value;
			}
			// this[name]=value;// 定义对象属性并初始化
		}
	}
}

function refreshurl(URL)
{
	parent.location.href =URL;
}

function deleteall(str)
{
	if (confirm('Are you sure?'))
	{
		 var  e  =  document.boka;
		 e.action = str+'.php?action=delete'+str;
		 e.submit();
	}
}

/* 取得COOKIE的值 */
function get_cookie(Name)
{
	var search = Name + "=";
	var returnvalue = "";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)
			end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end));
		}
	}
	return returnvalue;
}
/* 记录COOKIE */
function setCookie(Name,Svalue)
{
	//var argv = setCookie.arguments;
	//var argc = setCookie.arguments.length;
	var UTime=new Date();
	UTime.setTime(UTime.getTime() + 1000*3600*24*365);
	document.cookie=Name+"="+Svalue+";expires="+UTime.toGMTString();
}
function setpopupcookie(str)
{
	if (get_cookie(str)==1)
	{
		setCookie(str,0);
	}
	else
	{
		setCookie(str,1);
	}
}


function show_opr_more(str)
{
	if($('#'+str).css('display')=="none")
	{
		$('#'+str).show();
		var ofst=$('#op_menu_more').offset();
		$('#'+str).css('left',ofst.left);
		$('#'+str).css('top',ofst.top+30);
		//$('#'+str).css('margin-left',-mywidth-24);
	}
	else
	{
		$('#'+str).hide();
	}

}

function showdiv(str,isparent)
{
	if (isparent==1)
	{
		if(parent.document.getElementById(str).style.display)
		{
			parent.document.getElementById(str).style.display="";
			if (str=='newfunctions' || str=='wizard')
			{
				loadiframeurl();
				parent.document.getElementById("full").style.visibility="visible";
			}
		}
		else
		{
			parent.document.getElementById(str).style.display="none";
			if (str=='newfunctions' || str=='wizard')
			{
				loadiframeurl();
				parent.document.getElementById("full").style.visibility="hidden";
			}
		}
	}
	else
	{
		if(document.getElementById(str).style.display)
		{
			document.getElementById(str).style.display="";
			centerThis(str);
			if (str=='newfunctions' || str=='wizard')
			{
				loadiframeurl();
				document.getElementById("full").style.visibility="visible";
			}
		}
		else
		{
			document.getElementById(str).style.display="none";
			centerThis(str);
			if (str=='newfunctions' || str=='wizard')
			{
				loadiframeurl();
				document.getElementById("full").style.visibility="hidden";
			}
		}
	}
}

function twoiframe(String1,String2,iframe1,iframe2,flag)
{
	if (flag==1)
	{
		parent.document.getElementById(iframe1).src=String1;
		parent.document.getElementById(iframe2).src=String2;
	}
	else
	{
		document.getElementById(iframe1).src=String1;
		document.getElementById(iframe2).src=String2;
	}
}

// change style
function setActiveStyleSheet(title)
{
	var i, a;
	if (title)
	{
		for(i=0; (a = document.getElementsByTagName('link')[i]); i++)
		{
			if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title'))
			{
				a.disabled = true;
				if(a.getAttribute('title') == title) a.disabled = false;
			}
		}
	}
 }
 function getActiveStyleSheet()
 {
	var i, a;
	for(i=0; (a = document.getElementsByTagName('link')[i]); i++)
	{
		if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled) return a.getAttribute('title');
	}
	return null;
}

function isvisible(str)
{
	if(document.getElementById(str).style.visibility=="hidden")
	{
		document.getElementById(str).style.visibility="visible";
		if (str=='editfull')
		{
			document.getElementById('editpop').style.display="";
		}
	}
	else
	{
		document.getElementById(str).style.visibility="hidden";
		if (str=='editfull')
		{
			document.getElementById('editpop').style.display="none";
		}
	}
}

// 取得字符串的字节长度
function ByteLen(Str)
{
	var Len=0;
	Str=Str + "";
	for(var i=1;i<=Str.length;i++)
	{
		if(Str.charCodeAt(i-1)>255)
		Len++;
		else Len+=1;
	}
	return(Len);
}
function ByteLeft(Str,Length)
{
	var Len=0;
	for(var i=1;i<=Str.length;i++)
	{
		if(Str.charCodeAt(i-1)>255)
		Len++;
		else Len+=1;
		if(Len==Length)
			return(Str.substring(0,i));
		else if(Len>Length)
			return(Str.substring(0,i-1));
	}
}
function Test(obj,Num)
{
	var str=obj.value;
	event.keyCode=0;
	var len=ByteLen(obj.value);
	if (obj.name=='seotitle')
	{
		document.all("seotitlestatus").innerText="" + len;
	}
	else if (obj.name=='seodescription')
	{
		document.all("seodescriptionstatus").innerText="" + len;
	}
	else if (obj.name=='seokeywords')
	{
		document.all("seokeywordsstatus").innerText="" + len;
	}
	if(ByteLen(str)>Num) obj.value=ByteLeft(str,Num);
}
// 取得字符串的字节长度

function showmenu()
{
	if (document.getElementById("_IframeLeft").style.display=='')
	{
		document.getElementById("_IframeLeft").style.display='none';
		document.getElementById("closemenu").src="images/menu/menu_open.gif";
		str = $(window).width()-20;
		document.getElementById("_IframeBody").style.width=str+'px';
		document.frames.style.width = str+'px';
	}
	else
	{
		document.getElementById("_IframeLeft").style.display='';
		document.getElementById("_IframeLeft").style.width='200px';
		document.getElementById("menu").style.width='200px';
		document.getElementById("closemenu").src="images/menu/menu_close.gif";
		str = $("#RightPane").width();
		document.getElementById("_IframeBody").style.width=str+'px';;
		//document.getElementById("editiframe").style.width=str+'px';;
	}
}
function show()
{
	if (document.getElementById("shortcut").style.display=='')
	{
		document.getElementById("shortcut").style.display = 'none';
		document.getElementById("shortcutimage").src="images/menu/close.gif";
	}
	else
	{
		document.getElementById("shortcut").style.display = '';
		document.getElementById("shortcutimage").src="images/open.gif";
	}
}

function alertobject(obj){
	var str='';
	var j=0;
	if(typeof(obj)=='string')
	{
		alert(obj);
		return;
	}
	for (var i in obj) {// i为索引名称
		if(obj[i])
		{
			str += i + ": " + obj[i];
			str+="\r\n";
		}
		j++
	}
	// document.write(str);
	alert(str);
}

function getFrameId(str)
{
	if (str==1)
	{
		var allFrame=document.getElementsByTagName("iframe");
	}
	else
	{
		var allFrame=parent.document.getElementsByTagName("iframe");
	}
	for(var i=0;i<allFrame.length;i++)
	{
    		if(allFrame[i].contentWindow==window){
    			return (allFrame[i].id);
    		}
	}
}

function newtab(title,str,formname)
{
	iframeid = createtabinif(title,str);
	formname.target=iframeid.id;
	// str = str.replace(keyword, escape(keyword));
	document.getElementById(iframeid.id).src = str;
	return false;
}


function getcontent(str,cid,type) // 取得页面返回内容
{
	if(type==1)
	{
		$("#"+cid).load(str);
	}
	else
	{
		$.post(str+"&inajax=1",
		{ inajax:"1"},
			function(data)
			{
				$("#"+cid).html(data);
			},"html"
		);
	}
}