<script language='javascript'>
//轉意義字符與替換圖象以及字體HtmlEncode(text)
function HtmlEncode(text)
{
return text.replace(//"/g, '"').replace(/</g, '<').replace(/>/g, '>').replace(/#br#/g,'<br>').replace(/IMGSTART/g,'<IMG style=').replace(/IMGMID/g,' src=').replace(/IMGEND/g,'>').replace(/FONTSTART/g,'<font? style=/"').replace(/FONTEND/g,'</font>').replace(/FONTSTYLEEND/g,'/">').replace(/FORUELSTARTMA/g,'<a target=_blank href=').replace(/FORUELENDMA/g,'</a>').replace(/NIFORPIEHAO/g,''');
}
//打印scrolldIV這個div的內碼內容getcontent()
function getcontent()
{
document.write(document.getElementById("scrolldIV").innerText);
}
//保存咨詢記錄函數CmdSave()
function CmdSave()
{
var OW = window.open('','','');
var DD = new Date();
OW.document.open();
OW.document.write(document.getElementById("scrolldIV").innerHTML);
OW.document.execCommand ("SaveAs",true,"咨詢記錄-"+ DD.getYear() + "-" + DD.getMonth() + "-" + DD.getDate() + "-" + DD.getHours() + "-" + DD.getMinutes() +".htm");
OW.close();
}
//把用戶列表加載入到scrolldIV,函數輸入值為用戶列表ChatText(Text)
function ChatText(Text)
{
if(Text!="")
??? {
???? document.getElementById('scrolldIV').innerHTML=document.getElementById('scrolldIV').innerHTML+ HtmlEncode(Text);
???? window.form1.ScrolldNeirong.value=document.getElementById('scrolldIV').innerHTML;
??? document.getElementById('scrolldIV').scrollTop = document.getElementById('scrolldIV').scrollHeight;document.form1.TextBox1.focus();
??? }
??? if(document.getElementById('scrolldIV').scrollTop>=2000)
??? {
??? Cls();
??? }
}
//UserList
//把咨詢記錄加載入到UserList,函數輸入值為咨詢所發送的記錄UserListAdd(Text)
function UserListAdd(text,ctext,soundstat)
{
var listinfo=text.toString().replace(/ListUsersStart/g, "<label οnmοuseοver=this.style.cursor='hand'; οnclick=window.form1.ToUser.value='").replace(/ListUsersMidA/g,"';document.getElementById('ToUserType').innerHTML='").replace(/ListUsersMid/g, "';onMouseOut=this.style.cursor='default'; >").replace(/ListUsersEnd/g, "</label><br>");
var clistinfo=ctext.toString().replace(/ListUsersStart/g, "<label οnmοuseοver=this.style.cursor='hand'; οnclick=window.form1.ToUser.value='").replace(/ListUsersMidA/g,"';document.getElementById('ToUserType').innerHTML='").replace(/ListUsersMid/g, "';onMouseOut=this.style.cursor='default'; >").replace(/ListUsersEnd/g, "</label><br>");
document.getElementById('UserList').innerHTML=listinfo+'---以上為管理員---<br>'+clistinfo;
if(soundstat==1)
{
Sound.play('sound/come.wav');
}
if(soundstat==2)
{
Sound.play('sound/go.wav');
}
}
//清屏Cls()
function Cls()
{
document.getElementById('scrolldIV').innerHTML="";
}
// 隱藏與顯示部分的層1為顯示0為隱藏showOrHide(value)
function showOrHide(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer1"].visibility='hide';
??????? else
?????????? document.all["Layer1"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer1"].visibility='show';
?????? else
????????? document.all["Layer1"].style.visibility='visible';
?? }
}
function showOrHide1(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer2"].visibility='hide';
??????? else
?????????? document.all["Layer2"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer2"].visibility='show';
?????? else
????????? document.all["Layer2"].style.visibility='visible';
?? }
}
function showOrHide2(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer3"].visibility='hide';
??????? else
?????????? document.all["Layer3"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer3"].visibility='show';
?????? else
????????? document.all["Layer3"].style.visibility='visible';
?? }
}
//更改字體大小屬性的函數changeSize(obj)
function changeSize(obj){
document.getElementById("TextBox1").style.fontSize = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;
}
//更改字體屬性的函數changeFont(obj)
function changeFont(obj){
document.getElementById("TextBox1").style.fontFamily = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;
}
//更改字體顏色屬性的函數changeColors(obj)
function changeColors(obj){
document.getElementById("TextBox1").style.color = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;
}
//加載表情圖象,輸入值為圖象的路徑selImg(text)
function selImg(text){
var newElem = document.createElement("IMG");
newElem.src=text;
newElem.style.cssText="WIDTH:19;HEIGHT:19";
//newElem.οnlοad="javascript:AutoAdjustAtchImgSize(this,600);
//for(var i=0;i<5;i++)
window.form1.TextBox1.appendChild(newElem);
}
//把TextArea(TextBox1)的值賦個隱藏控件(TextBox1Hide)激發button1單擊事件
function typechild()
{
if(document.form1.TextBox1.innerHTML.length<1)
?{
???? alert("咨詢內容不能為空!");
???? return false;
?}
?if(document.form1.ToUser.value.length<1)
?{
? alert("咨詢對象未選中!");
???? return false;
?}
window.form1.TextBox1Hide.value= UrlChange(window.form1.TextBox1.innerHTML);
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;
document.getElementById('Button1').click();
//alert(window.form1.TextBox1cssText.value);
}
//輸入方式onkepress時判斷咨詢字符是否超過1000
?function regInput(obj, reg, inputStr)
?{??
?
if(document.form1.TextBox1.innerHTML.length>1000 )
?{??
?alert("咨詢內容不能超過1000字!");
?var docSel?= document.selection.createRange()
??if (docSel.parentElement().tagName != "INPUT")?return false??
??oSel = docSel.duplicate()
??oSel.text = ""
??var srcRange?= obj.createTextRange()
??oSel.setEndPoint("StartToStart", srcRange)
??var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
??return reg.test(str)
??}
?}
?//輸入方式onpaste時判斷咨詢字符是否超過1000
?function regInputpaste(obj, reg, inputStr)
?{??
?
if(window.clipboardData.getData('text').length+document.form1.TextBox1.innerHTML.length>1000)//粘貼板里的字符長度
?{??
?alert("咨詢內容不能超過1000字!");
?var docSel?= document.selection.createRange()
??if (docSel.parentElement().tagName != "INPUT")?return false??
??oSel = docSel.duplicate()
??oSel.text = ""
??var srcRange?= obj.createTextRange()
??oSel.setEndPoint("StartToStart", srcRange)
??var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
??return reg.test(str)
??}
?}
?
//加載字體進入textarea
function fontin()
{
window.form1.TextBox1.style.cssText=window.form1.TextBox1cssText.value;
}
//url轉超級連接
//$2表示url值
//把=和"替換
function UrlChange(r)??
{
?var re = /(^|[^<=""])(http:(|)(([/w/+/-~`@:%])+/.)+([/w/./=/?/+/-~`@/':!%#]|(&)|&)+)/ig;
?var rewww=/(^|[^/w/=])((www|bbs)/.(/w)+/.([/w/./=/?/+/-~`@/'!%#]|(&))+)/ig;?
?r = r.replace(re, "FORUELSTARTMA$2IMGEND$2FORUELENDMA").replace(rewww, "FORUELSTARTMA$2IMGEND$2FORUELENDMA").replace(//"/g, '"').replace(/=/g, '=');??
?return r;
}
//播放聲音
var Sound = new Object();
Sound.play = function Sound_play(src) {
if (!src) return false;
this.stop();
var elm;
if (typeof document.all != "undefined") {
elm = document.createElement("bgsound");
elm.src = src;
}
else {
elm = document.createElement("object");
elm.setAttribute("data",src);
elm.setAttribute("type","audio/x-wav");
elm.setAttribute("controller","true");
}
document.body.appendChild(elm);
this.elm = elm;
return true;
};
Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parentNode.removeChild(this.elm);
this.elm = null;
}
};
</script>?