网站公告列表

没有公告

加入收藏
设为首页
联系站长
轻松学电脑>>网页制作>>其它教程>>JS代码格式化和语法着色
双击滚屏阅读

JS代码格式化和语法着色
Element("div"); divJSOutput.appendChild(glbRe); glbRe.className="codeRoot"; showWait(); core_analysis(); } function showWait(){ document.body.style.cursor="wait"; with(divWaiting.style){ display="block"; left=(document.body.clientWidth-divWaiting.offsetWidth)/2; top=(document.body.clientHeight-divWaiting.offsetHeight)/2; } spnProcess.innerHTML="0.00% ( 0 / 0 )" return(false); } function stopExec(){ document.body.style.cursor=""; divWaiting.style.display="none"; try{clearTimeout(glbTimer);}catch(e){} return(false); } function core_analysis(){ var str=" ", c="", lastState="", seq, intNextQuote, intTemp, intCount, intWordStart; spnProcess.innerHTML=parseFloat(glbP/glbStr.length*100).toFixed(2)+"% ( "+glbP+" / "+glbStr.length+" )"; for(var i=glbP;i<glbStr.length;i++){ c=glbStr.charAt(i); str+=htmlEncode(c); switch(c){ case "\r": case " ": case "\t": if(lastState=="\r\n"){str=" ";break;} if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){ str=str.substring(0,str.length-htmlEncode(c).length); str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)+htmlEncode(c); } break; case "\n": case ";": if(lastState=="\r\n"){str=" ";break;} outputLn(str); str=" "; lastState="\r\n"; if(i-glbP>200){ glbP=i+1; glbTimer=setTimeout(core_analysis); return; } break; case "\"": intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length){ intNextQuote=glbStr.indexOf("\"",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break; intCount=0; intTemp=intNextQuote; while(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)break; } if(intNextQuote==-1)break; str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\""; i=intNextQuote; lastState=""; break; case "\'": intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length){ intNextQuote=glbStr.indexOf("\'",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break; intCount=0; intTemp=intNextQuote; while(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)break; } if(intNextQuote==-1)break; str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\'"; i=intNextQuote; lastState=""; break; case "\/": if(glbStr.charAt(i+1)=="\/"){ intNextQuote=i; intNextQuote=glbStr.indexOf("\r\n",intNextQuote+1); if(intNextQuote==-1)intNextQuote=glbStr.length; str=str.substring(0,str.length-1); str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>"; i=intNextQuote; }else if(glbStr.charAt(i+1)=="*"){ intNextQuote=i; intNex

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页

 
  • 上一篇文章:

  • 下一篇文章:
  • 广告
    阅读top10
    普通文章[突破]在线编辑器任意…
    普通文章[JS]点出统计器
    普通文章[效果]JS折叠菜单
    普通文章javascript的函数
    普通文章怎么用javascript…
    普通文章百分百弹窗
    普通文章hta应用—代码统计工具
    普通文章小方框中浏览大图
    普通文章js版sliderBar(滑动条…
    普通文章JS代码格式化和语法着…
    普通文章好玩的样式—放大效果
    普通文章用css制作星级评分
    普通文章关于textarea的直观换…
    普通文章仿windows选项卡效果拾…
    查看JS代码格式化和语法着色全部内容
    本站提供:电脑教程 网页制作 Flash教程 PhotoShop教程等免费教程。
    Copyright © 2006-2008轻松学电脑All Rights Reserved