js函数格式化工具 及源码(转载)
2007-03-19 16:19
435 查看
感觉不错,记录一下了。赫赫~
源代码:
<HTML><HEAD><TITLE>Format</TITLE>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Author>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Keywords>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Description></HEAD>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<BODY>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
<SCRIPT language=JavaScript>
![](http://ttyp.cnblogs.com/Images/dot.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
<!--
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//**//**//**
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** ==================================================================================================
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 类名:CLASS_FORMATER
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 功能:JS格式化
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 示例:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
---------------------------------------------------------------------------------------------------
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var xx = new CLASS_FORMATER(code);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("display").innerHTML = xx.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
---------------------------------------------------------------------------------------------------
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 作者:ttyp
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 邮件:ttyp@21cn.com
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 日期:2006-5-21
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 版本:0.1
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** ==================================================================================================
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
**/
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function CLASS_FORMAT(code)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//哈希表类
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function Hashtable()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._hash = new Object();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.add = function(key,value)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(key)!="undefined")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this.contains(key)==false)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._hash[key]=typeof(value)=="undefined"?null:value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.remove = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{delete this._hash[key];}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.count = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{var i=0;for(var k in this._hash)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{i++;} return i;}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.items = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{return this._hash[key];}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.contains = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{return typeof(this._hash[key])!="undefined";}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.clear = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{for(var k in this._hash)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{delete this._hash[k];}}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._caseSensitive = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//字符串转换为哈希表
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.str2hashtable = function(key,cs)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _key = key.split(/,/g);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _hash = new Hashtable();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _cs = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(cs)=="undefined"||cs==null)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_cs = this._caseSensitive;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_cs = cs;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i in _key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(_cs)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_hash.add(_key[i]);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_hash.add((_key[i]+"").toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return _hash;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//获得需要转换的代码
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._codetxt = code;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(syntax)=="undefined")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
syntax = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._deleteComment = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是否大小写敏感
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._caseSensitive = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//可以后面加块语句的关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._blockElement = this.str2hashtable("switch,if,while,try,finally");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是函数申明
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._function = this.str2hashtable("function");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//本行括号内分号不做换行
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._isFor = "for";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._choiceElement = this.str2hashtable("else,catch");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._beginBlock = "{";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._endBlock = "}";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._singleEyeElement = this.str2hashtable("var,new,return,else,delete,in,case");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//得到分割字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._wordDelimiters= " ,.?!;:///<>(){}[]/"'/r/n/t=+-|*%@#$^&";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//引用字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._quotation = this.str2hashtable("/",'");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行注释字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._lineComment = "//";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//转义字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._escape = "//";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//多行引用开始
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._commentOn = "/*";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//多行引用结束
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._commentOff = "*/";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行结束词
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._rowEnd = ";";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._in = "in";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.isCompress = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.style = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.format = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var codeArr = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var word_index = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var htmlTxt = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._deleteComment = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//得到分割字符数组(分词)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for (var i = 0; i < this._codetxt.length; i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (this._wordDelimiters.indexOf(this._codetxt.charAt(i)) == -1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{ //找不到关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (codeArr[word_index] == null || typeof(codeArr[word_index]) == 'undefined')
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index] = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index] += this._codetxt.charAt(i);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (typeof(codeArr[word_index]) != 'undefined' && codeArr[word_index].length > 0)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
word_index++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index++] = this._codetxt.charAt(i);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var quote_opened = false; //引用标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var slash_star_comment_opened = false; //多行注释标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var slash_slash_comment_opened = false; //单行注释标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var line_num = 1; //行号
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var quote_char = ""; //引用标记类型
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var function_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var bracket_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var for_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//按分割字,分块显示
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for (var i=0; i <=word_index; i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理空行(由于转义带来)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(codeArr[i])=="undefined"||codeArr[i].length==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
continue;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i]==" "||codeArr[i]=="/t")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(slash_slash_comment_opened||slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i]=="/n")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理换行
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (codeArr[i] == "/r")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
line_num++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/r/n"+ this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理function里的参数标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&this.isFunction(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._isFor)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for_open = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]=="(")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
bracket_open = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==")")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
bracket_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!for_open)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&(codeArr[i+1]!="/r"&&codeArr[i+1]!="/n"))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._beginBlock)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
switch(this.style)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case 0:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case 1:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n"+ this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
default:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._endBlock)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum--;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&codeArr[i+1]!=this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent() + codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent() + codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&codeArr[i+1]!=this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + this._rowEnd;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isBlockElement(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理内置对象(后面加一个空格)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isSingleEyeElement(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(codeArr[i]==this._in)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理双引号(引号前不能为转义字符)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_star_comment_opened&&!slash_slash_comment_opened&&this._quotation.contains(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是相应的引号
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(quote_char==codeArr[i])
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_char = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_char = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理转义字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i] == this._escape)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index-1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(codeArr[i+1].charCodeAt(0)>=32&&codeArr[i+1].charCodeAt(0)<=127)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i+1].substr(0,1);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i+1].substr(1);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i=i+1;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理多行注释的开始
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._commentOn,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_star_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._commentOn;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._commentOn);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理单行注释
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._lineComment,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._lineComment;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._lineComment);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理忽略词
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._ignore,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._ignore;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._ignore);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理多行注释结束
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!quote_opened&&!slash_slash_comment_opened&&this.isStartWith(this._commentOff,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_star_comment_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._commentOff;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._commentOff);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//不是在字符串中
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//如果不是在注释重
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!slash_slash_comment_opened && !slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//注释中
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return htmlTxt.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isStartWith = function(str,code,index)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(str)!="undefined"&&str.length>0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cc = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=index;i<index+str.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
cc[cc.length] = code[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var c = cc.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this._caseSensitive)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(str.length>=code[index].length&&c.indexOf(str)==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(str.length>=code[index].length&&c.toLowerCase().indexOf(str.toLowerCase())==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isFunction = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._function.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isBlockElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._blockElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isChoiceElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._choiceElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isSingleEyeElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._singleEyeElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isNextElement = function(from,word)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=from;i<word.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(word[i]!=" "&&word[i]!="/t"&&word[i]!="/r"&&word[i]!="/n")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this.isChoiceElement(word[i]);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.getSkipLength = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var count = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=0;i<val.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this._wordDelimiters.indexOf(val.charAt(i))>=0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
count++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(count>0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
count=count-1;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return count;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.getIdent=function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var n = [];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=0;i<this._tabNum;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
n[n.length] = "/t";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return n.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function doformat(o)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var htmltxt = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (o == null)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
alert("domNode is null!");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _codetxt = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(o)=="object")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
switch(o.tagName)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "TEXTAREA":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "INPUT":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "DIV":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "SPAN":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.innerText;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
default:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.innerHTML;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _syn = new CLASS_FORMAT(_codetxt);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmltxt = _syn.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return htmltxt;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function go()
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var code = document.getElementById("code").value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var xx = new CLASS_FORMAT(code);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var a = new Date();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById('cboOperate').selectedIndex==1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
xx.isCompress=true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
xx.style = parseInt(document.getElementById('cboStyle').value);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("display").value = xx.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
alert("共花:" + (new Date().getTime()-a.getTime()) + "ms");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
//-->
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</SCRIPT>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<TEXTAREA id=code rows=12 cols=100>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
/*
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
这个是一个类
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
*/
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
function xx (num,str){//说明
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
var a = num;this.aa = a;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
this.bb = function(){alert(str);}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
this.cc = function(){for(var i=0;i<10;i++){document.title=i;}}};
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
xx.prototype.dd= function(){alert("d d kd");}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
var a = new xx(100,"hello"),b=new xx(0,"ttyp");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
if(1>2) { alert();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
else {
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
alert(" hell ");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
a.bb();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
b.dd();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
alert(a.aa);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</TEXTAREA> <BR>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<select id="cboOperate" onchange="if(this.selectedIndex==1)document.getElementById('cboStyle').disabled=true;else document.getElementById('cboStyle').disabled=false;">
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="0">格式化</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="1">压缩</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</select>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<select id="cboStyle">
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="0">经典</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="1">微软</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</select>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<INPUT onclick=go() type=button value=go><br>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<textarea id=display rows=12 cols=100>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</textarea>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</BODY></HTML>
源代码:
<HTML><HEAD><TITLE>Format</TITLE>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Author>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Keywords>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<META content="" name=Description></HEAD>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<BODY>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
<SCRIPT language=JavaScript>
![](http://ttyp.cnblogs.com/Images/dot.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
<!--
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
/**//**//**//**
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** ==================================================================================================
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 类名:CLASS_FORMATER
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 功能:JS格式化
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 示例:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
---------------------------------------------------------------------------------------------------
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var xx = new CLASS_FORMATER(code);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("display").innerHTML = xx.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
---------------------------------------------------------------------------------------------------
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 作者:ttyp
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 邮件:ttyp@21cn.com
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 日期:2006-5-21
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** 版本:0.1
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
** ==================================================================================================
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
**/
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function CLASS_FORMAT(code)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//哈希表类
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function Hashtable()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._hash = new Object();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.add = function(key,value)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(key)!="undefined")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this.contains(key)==false)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._hash[key]=typeof(value)=="undefined"?null:value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.remove = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{delete this._hash[key];}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.count = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{var i=0;for(var k in this._hash)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{i++;} return i;}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.items = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{return this._hash[key];}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.contains = function(key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{return typeof(this._hash[key])!="undefined";}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.clear = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{for(var k in this._hash)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{delete this._hash[k];}}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._caseSensitive = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//字符串转换为哈希表
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.str2hashtable = function(key,cs)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _key = key.split(/,/g);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _hash = new Hashtable();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _cs = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(cs)=="undefined"||cs==null)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_cs = this._caseSensitive;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_cs = cs;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i in _key)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(_cs)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_hash.add(_key[i]);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_hash.add((_key[i]+"").toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return _hash;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//获得需要转换的代码
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._codetxt = code;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(syntax)=="undefined")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
syntax = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._deleteComment = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是否大小写敏感
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._caseSensitive = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//可以后面加块语句的关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._blockElement = this.str2hashtable("switch,if,while,try,finally");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是函数申明
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._function = this.str2hashtable("function");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//本行括号内分号不做换行
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._isFor = "for";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._choiceElement = this.str2hashtable("else,catch");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._beginBlock = "{";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._endBlock = "}";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._singleEyeElement = this.str2hashtable("var,new,return,else,delete,in,case");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//得到分割字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._wordDelimiters= " ,.?!;:///<>(){}[]/"'/r/n/t=+-|*%@#$^&";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//引用字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._quotation = this.str2hashtable("/",'");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行注释字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._lineComment = "//";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//转义字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._escape = "//";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//多行引用开始
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._commentOn = "/*";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//多行引用结束
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._commentOff = "*/";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//行结束词
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._rowEnd = ";";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._in = "in";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.isCompress = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this.style = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.format = function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var codeArr = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var word_index = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var htmlTxt = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._deleteComment = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//得到分割字符数组(分词)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for (var i = 0; i < this._codetxt.length; i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (this._wordDelimiters.indexOf(this._codetxt.charAt(i)) == -1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{ //找不到关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (codeArr[word_index] == null || typeof(codeArr[word_index]) == 'undefined')
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index] = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index] += this._codetxt.charAt(i);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
if (typeof(codeArr[word_index]) != 'undefined' && codeArr[word_index].length > 0)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
word_index++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
codeArr[word_index++] = this._codetxt.charAt(i);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var quote_opened = false; //引用标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var slash_star_comment_opened = false; //多行注释标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var slash_slash_comment_opened = false; //单行注释标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var line_num = 1; //行号
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var quote_char = ""; //引用标记类型
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var function_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var bracket_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var for_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//按分割字,分块显示
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for (var i=0; i <=word_index; i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理空行(由于转义带来)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(codeArr[i])=="undefined"||codeArr[i].length==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
continue;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i]==" "||codeArr[i]=="/t")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(slash_slash_comment_opened||slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i]=="/n")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理换行
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (codeArr[i] == "/r")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
line_num++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/r/n"+ this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理function里的参数标记
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&this.isFunction(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._isFor)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for_open = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]=="(")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
bracket_open = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==")")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
bracket_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!for_open)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&(codeArr[i+1]!="/r"&&codeArr[i+1]!="/n"))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._beginBlock)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
for_open = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
switch(this.style)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case 0:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case 1:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + "/n"+ this.getIdent();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
default:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codeArr[i]==this._endBlock)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this.isCompress)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
this._tabNum--;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&codeArr[i+1]!=this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent() + codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = "/n" + this.getIdent() + codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index&&codeArr[i+1]!=this._rowEnd)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + this._rowEnd;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理关键字
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isBlockElement(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理内置对象(后面加一个空格)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isSingleEyeElement(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(codeArr[i]==this._in)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i] + " ";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理双引号(引号前不能为转义字符)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_star_comment_opened&&!slash_slash_comment_opened&&this._quotation.contains(codeArr[i]))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//是相应的引号
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(quote_char==codeArr[i])
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_char = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
quote_char = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理转义字符
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if(codeArr[i] == this._escape)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(i<word_index-1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(codeArr[i+1].charCodeAt(0)>=32&&codeArr[i+1].charCodeAt(0)<=127)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i+1].substr(0,1);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i+1].substr(1);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i=i+1;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理多行注释的开始
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._commentOn,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_star_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._commentOn;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._commentOn);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理单行注释
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._lineComment,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._lineComment;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._lineComment);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理忽略词
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isStartWith(this._ignore,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_slash_comment_opened = true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._ignore;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._ignore);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//处理多行注释结束
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else if (!quote_opened&&!slash_slash_comment_opened&&this.isStartWith(this._commentOff,codeArr,i))
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
slash_star_comment_opened = false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = this._commentOff;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
i = i + this.getSkipLength(this._commentOff);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//不是在字符串中
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!quote_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//如果不是在注释重
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!slash_slash_comment_opened && !slash_star_comment_opened)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
//注释中
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(!this._deleteComment)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmlTxt[htmlTxt.length] = codeArr[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return htmlTxt.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isStartWith = function(str,code,index)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(str)!="undefined"&&str.length>0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var cc = new Array();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=index;i<index+str.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
cc[cc.length] = code[i];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var c = cc.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this._caseSensitive)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(str.length>=code[index].length&&c.indexOf(str)==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(str.length>=code[index].length&&c.toLowerCase().indexOf(str.toLowerCase())==0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
} else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isFunction = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._function.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isBlockElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._blockElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isChoiceElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._choiceElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isSingleEyeElement = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this._singleEyeElement.contains(this._caseSensitive?val:val.toLowerCase());
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.isNextElement = function(from,word)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=from;i<word.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(word[i]!=" "&&word[i]!="/t"&&word[i]!="/r"&&word[i]!="/n")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return this.isChoiceElement(word[i]);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return false;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.getSkipLength = function(val)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var count = 0;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=0;i<val.length;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(this._wordDelimiters.indexOf(val.charAt(i))>=0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
count++;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(count>0)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
count=count-1;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return count;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
this.getIdent=function()
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var n = [];
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
for(var i=0;i<this._tabNum;i++)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
n[n.length] = "/t";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return n.join("");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
function doformat(o)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var htmltxt = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if (o == null)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
alert("domNode is null!");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _codetxt = "";
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(typeof(o)=="object")
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
switch(o.tagName)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "TEXTAREA":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "INPUT":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "DIV":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
case "SPAN":
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.innerText;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
default:
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o.innerHTML;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
break;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
_codetxt = o;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var _syn = new CLASS_FORMAT(_codetxt);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
htmltxt = _syn.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
return htmltxt;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
function go()
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var code = document.getElementById("code").value;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var xx = new CLASS_FORMAT(code);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
var a = new Date();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
if(document.getElementById('cboOperate').selectedIndex==1)
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
xx.isCompress=true;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
}else
![](http://ttyp.cnblogs.com/Images/dot.gif)
{
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
xx.style = parseInt(document.getElementById('cboStyle').value);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
document.getElementById("display").value = xx.format();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
alert("共花:" + (new Date().getTime()-a.getTime()) + "ms");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
//-->
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</SCRIPT>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<TEXTAREA id=code rows=12 cols=100>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
/*
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
这个是一个类
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
*/
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
function xx (num,str){//说明
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
var a = num;this.aa = a;
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
this.bb = function(){alert(str);}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
this.cc = function(){for(var i=0;i<10;i++){document.title=i;}}};
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
xx.prototype.dd= function(){alert("d d kd");}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
var a = new xx(100,"hello"),b=new xx(0,"ttyp");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
if(1>2) { alert();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
else {
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
alert(" hell ");
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
}
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
a.bb();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
b.dd();
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
alert(a.aa);
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</TEXTAREA> <BR>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<select id="cboOperate" onchange="if(this.selectedIndex==1)document.getElementById('cboStyle').disabled=true;else document.getElementById('cboStyle').disabled=false;">
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="0">格式化</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="1">压缩</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</select>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<select id="cboStyle">
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="0">经典</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<option value="1">微软</option>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</select>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<INPUT onclick=go() type=button value=go><br>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
<textarea id=display rows=12 cols=100>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</textarea>
![](http://ttyp.cnblogs.com/Images/OutliningIndicators/None.gif)
</BODY></HTML>
相关文章推荐
- 在EditPlus中配置js和css格式化工具的操作
- JS日期格式化函数性能探底
- js时间格式化工具,时间戳格式化,字符串转时间戳
- 转载JSON格式化工具
- js格式化日期时间的工具方法
- 读 zepto 源码之工具函数
- JS 日期验证正则附asp日期格式化函数
- jQuery源码分析-03构造jQuery对象-工具函数
- js的日期格式化函数
- js 数值项目的格式化函数代码
- underscore.js 源码中一些实用的工具方法
- Zepto源码之$.fn工具函数
- Js-格式化时间戳函数
- 从源码中无法看出函数所在的js脚本的解决方法
- JS时间格式化函数
- JavaScript的js文件压缩和格式化工具
- JS 日期验证正则附asp日期格式化函数
- JS格式化工具
- [乐意黎转载]从零开始学习jQuery (九) jQuery工具函数
- 读 zepto 源码之工具函数