泣红亭 发表于 2004-6-15 04:49:31

【整理:DHTML】超酷文本框

作者:99818 整理日期:2004年6月15日


<html>
<head>
<style type="text/css">
INPUT {
    filter:alpha(opacity=80); border: 1 solid #000000
  }
</style>
<title>超酷文本框!!!
</title></head>

<body background="http://bbs.51js.com/images/standard/51js.gif">
<SCRIPT language=JavaScript>  
var i=0;  
var ie=(document.all)?1:0;  
var ns=(document.layers)?1:0;  
function generate() /* Generation of "Compilation" */  
    {  
        code = document.pad.text.value;  
        if (code)  
            {  
                document.pad.text.value='Compiling...Please wait!';  
                setTimeout("compile()",500);  
            }  
        else alert('First enter something to compile and then press CompileIt')  
    }  
function compile() /* The "Compilation" */  
    {  
        document.pad.text.value='';  
        compilation=escape(code);  
        document.pad.text.value="<script>\n<!--\ndocument.write(unescape(\""+compilation+"\"));\n//-->\n<\/script>";  
        i++;  
        alert("Page compiled "+i+" times!");  
    }  
function selectCode() /* Selecting "Compilation" for Copying */  
    {  
        if(document.pad.text.value.length>0)  
            {  
                document.pad.text.focus();  
                document.pad.text.select();  
            }  
        else alert('Nothing for be selected!')  
    }  
function preview() /* Preview for the "Compilation" */  
    {  
        if(document.pad.text.value.length>0)  
            {  
                pr=window.open("","Preview","scrollbars=1,menubar=1,status=1,left=10,top=10");  
                pr.document.write(document.pad.text.value);  
            }  
        else alert('Nothing for be previewed!')  
    }  
function uncompile() /* Decompiling a "Compilation" */  
    {  
        if (document.pad.text.value.length>0)  
            {  
                source=unescape(document.pad.text.value);  
                document.pad.text.value=""+source+"";  
            }  
        else alert('You need compiled code to uncompile it!')  
    }  
// -->  
</SCRIPT>
<script>
function tp()
{pad.text.focus()
document.execCommand("Paste")}
function savetxt() {
var newwin=window.open('about:blank','','top=10000');
newwin.document.write(document.pad.text.value);
newwin.document.execCommand('saveas','','c_d.htm')
newwin.window.close();}
</script>
            <FORM method=post name=pad align="center">
              <p align="center"><TEXTAREA cols=120 name=text rows=22 style="filter:alpha(opacity=80)">
<html>
<STYLE>.navPoint {
        COLOR: white; CURSOR: hand; FONT-FAMILY: Webdings; FONT-SIZE: 9pt
}
P {
        FONT-SIZE: 9pt
}
</STYLE>
</HEAD>
<BODY scroll=no style="MARGIN: 0px" text="black" vlink="black" link="black" alink="black">
<SCRIPT>

function showitem(id,name)
{
var idname=new Array()
idname="gl1.htm"
idname="gl2.htm"
idname="gl3.htm"
idname="gl4.htm"
idname="gl5.htm"
idname="gl6.htm"
idname="poems/shipwrech.htm"
idname="poems/peasant.htm"
idname="poems/destrman.htm"
idname="poems/Chester_Beatty.htm "
idname="poems/Ptah_Hotep.htm"
idname="poems/lovepoem.htm"
idname="poems/niluohesong.htm"
idname="poems/adunsong.htm"
idname="poems/lasong.htm"
idname="poems/tut.htm"
return ("<span class=smallFont><a target='main1' href="+idname+">"+name+"</a></span><br>")
}
function switchoutlookBar(number)
{        var i = outlookbar.opentitle;
        outlookbar.opentitle=number;
        var id1,id2,id1b,id2b
        if (number!=i && outlooksmoothstat==0){
        if (number!=-1)
                {
                        if (i==-1)
                                {
                                id2="blankdiv";
                                id2b="blankdiv";}
                        else{
                                id2="outlookdiv"+i;
                                id2b="outlookdivin"+i;
                                document.all("outlooktitle"+i).style.border="1px solid navy";
                                document.all("outlooktitle"+i).style.background="#ffb600";
                                document.all("outlooktitle"+i).style.color="white";
                                document.all("outlooktitle"+i).style.textalign="center";
                                }
                        id1="outlookdiv"+number
                        id1b="outlookdivin"+number
                        document.all("outlooktitle"+number).style.border="1px solid white";
                        document.all("outlooktitle"+number).style.background="#FBE499";
                        document.all("outlooktitle"+number).style.color="#ffb600";
                        document.all("outlooktitle"+number).style.textalign="center";
                        smoothout(id1,id2,id1b,id2b,0);
                }
        else
                {
                        document.all("blankdiv").style.display="";
                        document.all("blankdiv").sryle.height="100%";
                        document.all("outlookdiv"+i).style.display="none";
                        document.all("outlookdiv"+i).style.height="0%";
                        document.all("outlooktitle"+i).style.border="1px solid navy";
                        document.all("outlooktitle"+i).style.background="#ffb600";
                        document.all("outlooktitle"+i).style.color="white";
                        document.all("outlooktitle"+i).style.textalign="center";
                }
        }
                        
}

function smoothout(id1,id2,id1b,id2b,stat)
{
        if(stat==0){
                tempinnertext1=document.all(id1b).innerHTML;
                tempinnertext2=document.all(id2b).innerHTML;
                document.all(id1b).innerHTML="";
                document.all(id2b).innerHTML="";
                outlooksmoothstat=1;
                document.all(id1b).style.overflow="hidden";
                document.all(id2b).style.overflow="hidden";
                document.all(id1).style.height="0%";
                document.all(id1).style.display="";
                setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+outlookbar.inc+")",outlookbar.timedalay);
        }
        else
        {
                stat+=outlookbar.inc;
                if (stat>100)
                        stat=100;
                document.all(id1).style.height=stat+"%";
                document.all(id2).style.height=(100-stat)+"%";
                if (stat<100)
                        setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+stat+")",outlookbar.timedalay);
                else
                        {
                        document.all(id1b).innerHTML=tempinnertext1;
                        document.all(id2b).innerHTML=tempinnertext2;
                        outlooksmoothstat=0;
                        document.all(id1b).style.overflow="auto";
                        document.all(id2).style.display="none";
                        }
        }
}

function getOutLine()
{
        outline="<table "+outlookbar.otherclass+">";
        for (i=0;i<(outlookbar.titlelist.length);i++)
                {
                        outline+="<tr><td name=outlooktitle"+i+" id=outlooktitle"+i+" ";               
                        if (i!=outlookbar.opentitle)
                                outline+=" nowrap align=center style='cursor:hand;background-color:#ffb600;color:white;height:5;border:1 solid navy' ";
                        else
                                outline+=" nowrap align=center style='cursor:hand;background-color:#FBE499;color:#ffb600;height:5;border:1 solid white' ";
                        outline+=outlookbar.titlelist.otherclass
                        outline+=" onclick='switchoutlookBar("+i+")'><span class=smallFont><b>";
                        outline+=outlookbar.titlelist.title+"</b></span></td></tr>";
                        outline+="<tr><td name=outlookdiv"+i+" valign=top align=center  id=outlookdiv"+i+" style='width:100%"
                        if (i!=outlookbar.opentitle)
                                outline+=";display:none;height:0%;";
                        else
                                outline+=";display:;height:100%;";
                        outline+="'><div name=outlookdivin"+i+" id=outlookdivin"+i+" style='overflow:auto;width:100%;height:100%'>";
                        for (j=0;j<outlookbar.itemlist.length;j++)
                                outline+=showitem(outlookbar.itemlist.key,outlookbar.itemlist.title);
                        outline+="</div></td></tr>"
                }
        outline+="<tr><td name=blankdiv valign=top align=center  id=blankdiv style='height:100%;width:100%:"
        if (outlookbar.opentitle!=-1)
                                outline+=";display:none;";
                        else
                                outline+=";display:;";
        outline+="'><div style='overflow:auto;width:100%;height:100%'>";
        outline+="</div></td></tr>"
        
        outline+="</table>"
        return outline

}

function show()
{
        var outline;
        outline="<div id=outLookBarDiv name=outLookBarDiv style='width=100%;height:100%'>"
        outline+=outlookbar.getOutLine();
        outline+="</div>"
        document.write(outline);
        //document.all("outLookBarDiv").innerHTML=
}

function theitem(intitle,instate,inkey)
{
        this.state=instate;
        this.otherclass=" nowrap ";
        this.key=inkey;
        this.title=intitle;
}

function addtitle(intitle)
{
        outlookbar.itemlist=new Array();
        outlookbar.titlelist=new theitem(intitle,1,0);
/*        if (outlookbar.titlelist.length != (outlookbar.starttitle+1))
                outlookbar.titlelist.otherclass=" nowrap align=center style='cursor:hand;background-color:#ffb600;color:white;height:5;border:1 solid navy' ";
        else
                outlookbar.titlelist.otherclass=" nowrap align=center style='cursor:hand;background-color:#FBE499;color:#ffb600;height:5;border:1 solid white' ";
*/        return(outlookbar.titlelist.length-1);
}

function additem(intitle,parentid,inkey)
{
        if (parentid>=0 && parentid<=outlookbar.titlelist.length)
        {
                outlookbar.itemlist.length]=new theitem(intitle,2,inkey);
                outlookbar.itemlist.length-1].otherclass=" nowrap align=left style='backgroundColor:blue;height:5' ";
                return(outlookbar.itemlist.length-1);
        }
        else
                additem=-1;
}

function outlook()
{
        this.titlelist=new Array();
        this.itemlist=new Array();
        this.divstyle="style='height:100%;width:100%;overflow:auto' align=center";
        this.otherclass="border=0 cellspacing='0' cellpadding='0' style='height:100%;width:100%'valign=middle align=center ";
        this.addtitle=addtitle;
        this.additem=additem;
        this.starttitle=-1;
        this.show=show;
        this.getOutLine=getOutLine;
        this.opentitle=this.starttitle;
        this.reflesh=outreflesh;
        this.timedelay=50;
        this.inc=10;
        
}

function outreflesh()
{
        document.all("outLookBarDiv").innerHTML=outlookbar.getOutLine();
}

function locatefold(foldname)
{
        for (var i=0;i<outlookbar.titlelist.length;i++)
                if(foldname==outlookbar.titlelist.title)
                        {
                                 outlookbar.starttitle=i;
                                 outlookbar.opentitle=i;
                        }
        
}

var outlookbar=new outlook();
var tempinnertext1,tempinnertext2,outlooksmoothstat
outlooksmoothstat = 0;


</SCRIPT>
<script language="JavaScript">
var t;
t=outlookbar.addtitle('神话传说')

outlookbar.additem('概论',t,1)

t=outlookbar.addtitle('宗教文学')

outlookbar.additem('概论',t,2)

t=outlookbar.addtitle('教谕文学')

outlookbar.additem('概论',t,3)
outlookbar.additem('Ptah_Hotep教谕',t,11)

t=outlookbar.addtitle('传记文学')

outlookbar.additem('概论',t,4)
outlookbar.additem('图特摩斯三世年代记',t,16)

t=outlookbar.addtitle('散文故事')

outlookbar.additem('概论',t,5)
outlookbar.additem('人类的毁灭',t,9)
outlookbar.additem('遇难水手的故事',t,7)
outlookbar.additem('能说善辩的农夫',t,8)

t=outlookbar.addtitle('诗歌')

outlookbar.additem('概论',t,6)
outlookbar.additem('情诗',t,12)
outlookbar.additem('拉的颂歌',t,15)
outlookbar.additem('阿顿颂歌',t,14)
outlookbar.additem('尼罗河颂歌',t,13)
outlookbar.additem('切斯特·贝蒂斯纸草',t,10)

t=outlookbar.addtitle('合拢所有')
</script>
<div align="left"
<TABLE border=3 cellPadding=1 cellSpacing=1 bgcolor="#bbc8c0"
width="100%" height="100%" vspace="0" hspace="0">
  <TBODY>
<TR>
    <TD align=middle id=outLookBarShow vAlign=top
    name="outLookBarShow">
           <TABLE border=3 cellPadding=2 cellSpacing=2 bgcolor="#bbc8c0" style="HEIGHT: 100%; WIDTH: 140px" vspace="0" hspace="0">
  <TBODY>
  <TR>
    <TD align=middle id=outLookBarShow style="HEIGHT: 100%" vAlign=top
    name="outLookBarShow" height="366">
       <SCRIPT>
        outlookbar.show()        
</SCRIPT>

    </TD></TR>
<tr>
<td align="center"><font size="3" color="red">
<b><a href="right.htm" target="main1">注  意</a></b></font>
</td>
</tr>
  </TBODY></TABLE>
</div>

</BODY></HTML></TEXTAREA><BR><p align="center">

<INPUT name=view onclick=preview()  type=button value=预览(ALT+W) accesskey=W>
<INPUT name=select onclick=selectCode()  type=button value=全选(ALT+A) accesskey=A>
<INPUT type="button" onclick=text.focus(),document.execCommand("Cut") value=剪切(ALT+X) accesskey=X>
<INPUT type="button" onclick=text.focus(),document.execCommand("Copy") value=复制(ALT+C) accesskey=C>
<INPUT name=select onclick=tp()  type=button value=粘贴(ALT+V) accesskey=V>
<INPUT type="button" onclick="text.value=text.value.toUpperCase()" value=大写(ALT+D) accesskey=D>
<INPUT type="button" onclick="text.value=text.value.toLowerCase()" value=小写(ALT+B) accesskey=B>
<INPUT type="button" onclick="text.value=escape(text.value)" value=Ascii(ALT+T) accesskey=T>
<INPUT type="button" onclick="text.value=unescape(text.value)" value=UnAscii(ALT+N) accesskey=N>
<INPUT name=compileIt onclick=generate()  type=button value=加密(ALT+J) accesskey=J>  
<INPUT name=retur onclick=uncompile()  type=button value=解密(ALT+L) accesskey=L>     
<INPUT name=retur onclick=savetxt() type=button value=保存(ALT+S) accesskey=S>     
<INPUT name=clear type=reset value=还原(ALT+U) accesskey=U></FORM></body></html>

melop 发表于 2004-6-15 09:21:21

有bug,连续加密两次,并解密两次,得到的结果不正确。

jackiezhu 发表于 2009-6-5 15:46:46

同上!
页: [1]
查看完整版本: 【整理:DHTML】超酷文本框