仿DW8代码折叠的HTML编辑器

2008-02-23 07:06:19来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

测试版(仅支持ie5.5 ,且一个页面里只能放一个)
收集意见

功能:
1.动态分析,智能折叠,ctrl Enter强制重建
2.tab键输出两个空格(若选区为多行,各行前加入两空格,同时按shift键反之),Ctrl T替换\t为俩空格
3.回车自动缩进
4.Ctrl W预览

限制:
1.取消了右键菜单(复制剪切粘贴可使用键盘)
2.暂不支持文本拖放
3.Ctrl Z将撤销所有操作
4.块起止测试并不严格,且未考虑vbscript
5.运行效率有待改进

<style>
body{
text-align:center;
}
#oTxt,#oBox{
height:440px;
border:none;
border:1px solid #666666;
}
#oTxt{
width:740px;
color:#333333;
background-color:#f0f0f0;
font-family:verdana;
font-size:11px;
line-height:13px;
margin-left:16px;
overflow:auto;
border-left:none;
scrollbar-arrow-color:#666666;
scrollbar-base-color:#666666;
scrollbar-darkshadow-color:#f0f0f0;
scrollbar-face-color:#f0f0f0;
}
#oBox{
position:absolute;
width:15px;
overflow-y:hidden;
background-color:#e0e0e0;
padding-top:1px;
margin-top:1px;
padding-bottom:19px;
border-right:none;
}
</style>
<script>
/*
测试版(仅支持ie5.5 ,且一个页面里只能放一个)
收集意见

功能:
1.动态分析,智能折叠,ctrl Enter强制重建
2.tab键输出两个空格(若选区为多行,各行前加入两空格,同时按shift键反之),Ctrl T替换\t为俩空格
3.回车自动缩进
4.Ctrl W预览

限制:
1.取消了右键菜单(复制剪切粘贴可使用键盘)
2.暂不支持文本拖放
3.Ctrl Z将撤销所有操作
4.块起止测试并不严格,且未考虑vbscript
5.运行效率有待改进
*/
window.onload=function(){
oBox.mLine="http://free.txd.cn/mozart0/img/line.gif";
oBox.mPlus="http://free.txd.cn/mozart0/img/plus.gif";
oBox.mMinus="http://free.txd.cn/mozart0/img/minus.gif";
oBox.mEnd="http://free.txd.cn/mozart0/img/end.gif";
oBox.isPlus=function(o){
return /plus\./.test(o.src);
}
oBox.isMinus=function(o){
return /minus\./.test(o.src);
}
oBox.isLine=function(o){
return /line\./.test(o.src);
}
oBox.isEnd=function(o){
return /end\./.test(o.src);
}
oBox.childrenVisible=function(index){
var t=this.children[index];
while(t.style.display=="none")
t=t.nextSibling;
var x=t.offsetTop/t.height;
while(x<index){
t=t.nextSibling;
if(t.style.display!="none")
x ;
}
return t;
}
oBox.hideBlock=function(index){
var n=1,x=1;
var c=this.children;
c[index].src=this.mPlus;
while( index<c.length&&n){
var t=c[index];
if(t.style.display!="none"){
x ;
t.style.display="none";
}
if(this.isEnd(t))
n--;
else if(!this.isLine(t))
n ;
}
return x;
}
oBox.showBlock=function(index,b){
var index0=index,c=oBox.children;
c[index].src=b?this.mMinus:this.mPlus;
c[index].style.display="block";
index ;
if(b)
while(index<c.length){
var t=c[index];
if(this.isLine(t)){
t.style.display="block";
index ;
}
else if(this.isEnd(t)){
t.style.display="block";
break;
}
else
index =this.showBlock(index,this.isMinus(t))
}
else{
var n=1;
while(index<c.length){
var t=c[index];
t.style.display=="none";
if(this.isEnd(t)){
if(--n==0)
break;
}
else if(!this.isLine(t))
n ;
index ;
}
}
return index-index0 1;
}
oBox.refresh=function(o,str){
o.src=this.judge(str);
o.storeText=str;
}
oBox.judge=function(s){
var l=/\{/.test(s),r=/\}/.test(s);
if(l&&!r)
return this.mMinus;
if(!l&&r)
return this.mEnd;
s=s.replace(/<(\w ).*<\/\1>/g,"<$1/>");
l=/^\s*<\w [^\/] [>\r]/.test(s);
r=/\/>/.test(s);
if(l&&!r)
return this.mMinus;
r=/<\/\w >/.test(s);
if(r)
return this.mEnd;
return this.mLine;
}
oBox.onclick=function(){
var o=event.srcElement;
if(o==this)
return;
var vIndex=(o.offsetTop-1)/oTxt.lineHeight;
var index=vIndex;
var t=this.children[vIndex];
while(t!=o){
t=t.nextSibling;
index ;
}
if(this.isMinus(o))
oTxt.hideLines(vIndex,this.hideBlock(index));
else if(this.isPlus(o))
oTxt.showLines(vIndex,this.showBlock(index,true));
oBox.scrollTop=oTxt.scrollTop;
}
oTxt.lineHeight=13;
oTxt.strSpecial="......";
oTxt.regSpecial=/\.{6}\r?$/;
oTxt.strTab=" ";
oTxt.bFixed=false;
oTxt.originalValue=oTxt.value;

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Dreamweaver经典问题大搜罗(全集)

下一篇:十六则Dreamweaver使用快技法