﻿// JScript 文件

function RefReplySetHTML(html,userName,leaveSize)
{ 
   
	    replace = filterQuote(html) ;
	    if((leaveSize>0)&&(replace.length>0)&&(replace.length>leaveSize)){
				    replace = replace.substring(0,leaveSize)+"..." ;
				}
			var title = buildRefRep(userName,replace) ;
			SetHTML(title) ;
	
}

function ReplySetHTML(name){
	
	var ddd=buildRep(name);
   SetHTML(ddd) ;
}

function buildRefRep(userName,content){
	
    var str = "[quote]----- 以下引用 <STRONG><EM>"+userName+"</EM></STRONG> 发言 -----<BR/>" ;
    str +=content+"[/quote]<br>" ;
    return str ;
}


function RefReplySetHTMLforum(userName,content,userid,lou)
{ 
   	        replace=content;
			var title = buildRefForum(userName,replace,userid,lou) ;
			SetHTML(title) ;
	
}


//username 用户名 content 文本 userid 用户ID  lou 第几楼 [为-1引用楼主] 
function buildRefForum(userName,content,userid,lou){
if(lou==-1)
	{
	     var str = "<blockquote><div><h2><span style=\"font-weight:normal\">引用: 楼主 <a href=\"/space/index.aspx?id="+userid+"\" target=_blank> <EM> "+userName+" </EM></a>  的帖子 </span></h2> " +content+ "</div></blockquote><br>" ;
	}
	else
	{
    var str = "<blockquote><div><h2><span style=\"font-weight:normal\">引用: " + lou + " 楼<a href=\"/space/index.aspx?id="+userid+"\" target=_blank> <EM> "+userName+" </EM></a>  的帖子 </span></h2> " +content+ "</div></blockquote><br>" ;
    }
    
    SetHTML(str) ;
}


function reForum(userName,content,userid,lou)
{
if(lou==-1)
{
    var str ="";
}
else
{
   var str ="<h2><span style=\"font-weight:normal\">回复: " + lou + " 楼<a href=\"/space/index.aspx?id="+userid+"\"  target=_blank> <EM> "+userName+" </EM></a>  的帖子 </span></h2> </div><br>";
   }
    SetHTML(str) ;
}



function editM(content)
{
    SetHTML(content) ;
}



function buildRep(userName){
	
	//alert(userName);
   var str= "回复----- [ " +userName+ " ] -----<BR><BR>" ;
 return str;
}
function filterScript(value){
	value = value.replace(/script/ig,'ｓｃｒｉｐｔ');
	var first = new Array(2) ;
	var second = new Array(2) ;
	first[0] = /<ｓｃｒｉｐｔ[^<>]*>[^(<\/ｓｃｒｉｐｔ)]*<\/ｓｃｒｉｐｔ>/g;
	first[1] = /&lt;ｓｃｒｉｐｔ[^<>]*&gt;[^(&lt;\/ｓｃｒｉｐｔ)]*&lt;\/ｓｃｒｉｐｔ&gt;/g;
	second[0] = "" ;
	second[1] = "" 
	for(var i =0 ;i<first.length;i++){
	    
	    value = value.replace(first[i],second[i]) ;
	
	}
	return value ;
}


function filterQuote(value){
		var match = /\[quote\]([^［］]*)\[\/quote\]/;
		//var match = /<([^ & ]*)>/ ;
		//alert(match) ;
		var mystr = value;
		
		while(true){
				var matches = mystr.match(match);
		 		if(matches == null){
					break;
				}
				mystr =mystr.replace(match,'') ;
		}
		try{
		   mystr = mystr.replace(/(&lt;).*(&gt;)/g,"");
	        }catch(Ex){}
		//document.getElementById("reply_filter").innerHTML=mystr ;
		
		//mystr = document.getElementById("reply_filter").innerText;  
		var len = mystr.lastIndexOf("]:") ;
		if(len >0)
		    mystr = mystr.substring(len+2) ;
		try{
		    mystr = mystr.replace(/^\s*|\s*$/g,"") ;
		   
	        }catch(e){}
		return mystr;
}

function SetHTML(sz){
	
	     editor_paste(sz);
         //document.frames['EditBox'].setContent("") ;
        // document.frames['EditBox'].editor_paste(sz) ;
  

}


function editor_paste(html){
	
	   oEditor.focus();
	   oEditor.document.selection.createRange().pasteHTML(html);	

}



