中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

格式化javascript代碼
來源:易賢網(wǎng) 閱讀:884 次 日期:2014-11-03 08:36:41
溫馨提示:易賢網(wǎng)小編為您整理了“格式化javascript代碼”,方便廣大網(wǎng)友查閱!

查看效果:格式化代碼 從比較緊密地javascript轉(zhuǎn)換成標(biāo)準(zhǔn)地javascript代碼

代碼如下:

<html><head><title>format</title>

<meta content=mshtml 6.00.2800.1528 name=generator>

<meta content= name=author>

<meta content= name=keywords>

<meta content= name=description></head>

<body>

<script language=javascript>

<!--

function class_format(code){

//哈希表類

function hashtable(){

this._hash = new object();

this.add = function(key,value){

if(typeof(key)!=undefined){

if(this.contains(key)==false){

this._hash[key]=typeof(value)==undefined?null:value;

return true;

} else {

return false;

}

} else {

return false;

}

}

this.remove = function(key){delete this._hash[key];}

this.count = function(){var i=0;for(var k in this._hash){i++;} return i;}

this.items = function(key){return this._hash[key];}

this.contains = function(key){return typeof(this._hash[key])!=undefined;}

this.clear = function(){for(var k in this._hash){delete this._hash[k];}}

}

this._casesensitive = true;

//字符串轉(zhuǎn)換為哈希表

this.str2hashtable = function(key,cs){

var _key = key.split(/,/g);

var _hash = new hashtable();

var _cs = true;

if(typeof(cs)==undefined||cs==null){

_cs = this._casesensitive;

} else {

_cs = cs;

}

for(var i in _key){

if(_cs){

_hash.add(_key[i]);

} else {

_hash.add((_key[i]+).tolowercase());

}

}

return _hash;

}

//獲的需要轉(zhuǎn)換地代碼

this._codetxt = code;

if(typeof(syntax)==undefined){

syntax = ;

}

this._deletecomment = false;

//是否大小寫敏感

this._casesensitive = true;

//可以后面加塊語句地關(guān)鍵字

this._blockelement = this.str2hashtable(switch,if,while,try,finally);

//是函數(shù)申明

this._function = this.str2hashtable(function);

//本行括號內(nèi)分號不做換行

this._isfor = for;

this._choiceelement = this.str2hashtable(else,catch);

this._beginblock = {;

this._endblock = };

this._singleeyeelement = this.str2hashtable(var,new,return,else,delete,in,case);

//的到分割字符

this._worddelimiters=   ,.?!;:\\/<>(){}[]\'\r\n\t=+-|*%@#$^&;

//引用字符

this._quotation = this.str2hashtable(\,');

//行注釋字符

this._linecomment = //;

//轉(zhuǎn)義字符

this._escape = \\;

//多行引用開始

this._commenton = /*;

//多行引用結(jié)束

this._commentoff = */;

//行結(jié)束詞

this._rowend = ;;

this._in = in;

this.iscompress = false;

this.style = 0;

this._tabnum = 0;

this.format = function() {

var codearr = new array();

var word_index = 0;

var htmltxt = new array();

if(this.iscompress){

this._deletecomment = true;

}

//的到分割字符數(shù)組(分詞)

for (var i = 0; i < this._codetxt.length; i++) {

if (this._worddelimiters.indexof(this._codetxt.charat(i)) == -1) { //找不到關(guān)鍵字

if (codearr[word_index] == null || typeof(codearr[word_index]) == 'undefined') {

codearr[word_index] = ;

}

codearr[word_index] += this._codetxt.charat(i);

} else {

if (typeof(codearr[word_index]) != 'undefined' && codearr[word_index].length > 0)

word_index++;

codearr[word_index++] = this._codetxt.charat(i);

} }

var quote_opened = false; //引用標(biāo)記

var slash_star_comment_opened = false; //多行注釋標(biāo)記

var slash_slash_comment_opened = false; //單行注釋標(biāo)記

var line_num = 1; //行號

var quote_char = ; //引用標(biāo)記類型

var function_opened = false;

var bracket_open = false;

var for_open = false;

//按分割字,分塊顯示

for (var i=0; i <=word_index; i++){

//處理空行(由于轉(zhuǎn)義帶來)

if(typeof(codearr[i])==undefined||codearr[i].length==0){

continue;

} else if(codearr[i]== ||codearr[i]==\t){

if(slash_slash_comment_opened||slash_star_comment_opened){

if(!this._deletecomment){

htmltxt[htmltxt.length] = codearr[i];

}

}

if(quote_opened){

htmltxt[htmltxt.length] = codearr[i];

}

} else if(codearr[i]==\n){

//處理換行

} else if (codearr[i] == \r){

slash_slash_comment_opened = false;

quote_opened = false;

line_num++;

if(!this.iscompress){

htmltxt[htmltxt.length] = \r\n+ this.getident();

}

//處理function里地參數(shù)標(biāo)記

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&this.isfunction(codearr[i])){

htmltxt[htmltxt.length] = codearr[i] + ;

function_opened = true;

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==this._isfor){

htmltxt[htmltxt.length] = codearr[i];

for_open = true;

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==(){

bracket_open = true;

htmltxt[htmltxt.length] = codearr[i];

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==)){

bracket_open = false;

htmltxt[htmltxt.length] = codearr[i];

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==this._rowend){

if(!this.iscompress){

if(!for_open){

if(i<word_index&&(codearr[i+1]!=\r&&codearr[i+1]!=\n)){

htmltxt[htmltxt.length] = codearr[i] + \n + this.getident();

}else{

htmltxt[htmltxt.length] = codearr[i] + this.getident();

}

}else{

htmltxt[htmltxt.length] = codearr[i];

}

}else{

htmltxt[htmltxt.length] = codearr[i];

}

} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==this._beginblock){

for_open = false;

if(!this.iscompress){

switch(this.style){

case 0:

this._tabnum++;

htmltxt[htmltxt.length] = codearr[i] + \n + this.getident();

break;

case 1:

htmltxt[htmltxt.length] = \n + this.getident();

this._tabnum++;

htmltxt[htmltxt.length] = codearr[i] + \n+ this.getident();

break;

default:

this._tabnum++;

htmltxt[htmltxt.length] = codearr[i];

break;

}

}else{

htmltxt[htmltxt.length] = codearr[i];

}

} else if(!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened &&codearr[i]==this._endblock){

if(!this.iscompress){

this._tabnum--;

if(i<word_index&&codearr[i+1]!=this._rowend){

htmltxt[htmltxt.length] = \n + this.getident() + codearr[i];

}else{

htmltxt[htmltxt.length] = \n + this.getident() + codearr[i];

}

}else{

if(i<word_index&&codearr[i+1]!=this._rowend){

htmltxt[htmltxt.length] = codearr[i] + this._rowend;

}else{

htmltxt[htmltxt.length] = codearr[i];

}

}

//處理關(guān)鍵字

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.isblockelement(codearr[i])){

htmltxt[htmltxt.length] = codearr[i];

//處理內(nèi)置對象(后面加一個空格)

} else if (!slash_slash_comment_opened&&!slash_star_comment_opened && !quote_opened && this.issingleeyeelement(codearr[i])){

if(codearr[i]==this._in){

htmltxt[htmltxt.length] = ;

}

htmltxt[htmltxt.length] = codearr[i] + ;

//處理雙引號(引號前不能為轉(zhuǎn)義字符)

} else if (!slash_star_comment_opened&&!slash_slash_comment_opened&&this._quotation.contains(codearr[i])){

if (quote_opened){

//是相應(yīng)地引號

if(quote_char==codearr[i]){

htmltxt[htmltxt.length] = codearr[i];

quote_opened = false;

quote_char = ;

} else {

htmltxt[htmltxt.length] = codearr[i];

}

} else {

htmltxt[htmltxt.length] = codearr[i];

quote_opened = true;

quote_char = codearr[i];

}

//處理轉(zhuǎn)義字符

} else if(codearr[i] == this._escape){

htmltxt[htmltxt.length] = codearr[i];

if(i<word_index-1){

if(codearr[i+1].charcodeat(0)>=32&&codearr[i+1].charcodeat(0)<=127){

htmltxt[htmltxt.length] = codearr[i+1].substr(0,1);

htmltxt[htmltxt.length] = codearr[i+1].substr(1);

i=i+1;

}

}

//處理多行注釋地開始

} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isstartwith(this._commenton,codearr,i)){

slash_star_comment_opened = true;

if(!this._deletecomment){

htmltxt[htmltxt.length] = this._commenton;

}

i = i + this.getskiplength(this._commenton);

//處理單行注釋

} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isstartwith(this._linecomment,codearr,i)){

slash_slash_comment_opened = true;

if(!this._deletecomment){

htmltxt[htmltxt.length] = this._linecomment;

}

i = i + this.getskiplength(this._linecomment);

//處理忽略詞

} else if (!slash_slash_comment_opened && !slash_star_comment_opened&&!quote_opened&&this.isstartwith(this._ignore,codearr,i)){

slash_slash_comment_opened = true;

htmltxt[htmltxt.length] = this._ignore;

i = i + this.getskiplength(this._ignore);

//處理多行注釋結(jié)束

} else if (!quote_opened&&!slash_slash_comment_opened&&this.isstartwith(this._commentoff,codearr,i)){

if (slash_star_comment_opened) {

slash_star_comment_opened = false;

if(!this._deletecomment){

htmltxt[htmltxt.length] = this._commentoff;

}

i = i + this.getskiplength(this._commentoff);

}

} else {

//不是在字符串中

if(!quote_opened){

//如果不是在注釋重

if(!slash_slash_comment_opened && !slash_star_comment_opened){

htmltxt[htmltxt.length] = codearr[i];

//注釋中

}else{

if(!this._deletecomment){

htmltxt[htmltxt.length] = codearr[i];

}

}

}else{

htmltxt[htmltxt.length] = codearr[i];

}

}

}

return htmltxt.join();

}

this.isstartwith = function(str,code,index){

if(typeof(str)!=undefined&&str.length>0){

var cc = new array();

for(var i=index;i<index+str.length;i++){

cc[cc.length] = code[i];

}

var c = cc.join();

if(this._casesensitive){

if(str.length>=code[index].length&&c.indexof(str)==0){

return true;

}

}else{

if(str.length>=code[index].length&&c.tolowercase().indexof(str.tolowercase())==0){

return true;

}

}

return false;

} else {

return false;

}

}

this.isfunction = function(val){

return this._function.contains(this._casesensitive?val:val.tolowercase());

}

this.isblockelement = function(val) {

return this._blockelement.contains(this._casesensitive?val:val.tolowercase());

}

this.ischoiceelement = function(val) {

return this._choiceelement.contains(this._casesensitive?val:val.tolowercase());

}

this.issingleeyeelement = function(val) {

return this._singleeyeelement.contains(this._casesensitive?val:val.tolowercase());

}

this.isnextelement = function(from,word){

for(var i=from;i<word.length;i++){

if(word[i]!= &&word[i]!=\t&&word[i]!=\r&&word[i]!=\n){

return this.ischoiceelement(word[i]);

}

}

return false;

}

this.getskiplength = function(val){

var count = 0;

for(var i=0;i<val.length;i++){

if(this._worddelimiters.indexof(val.charat(i))>=0){

count++;

}

}

if(count>0){

count=count-1;

}

return count;

}

this.getident=function(){

var n = [];

for(var i=0;i<this._tabnum;i++){

n[n.length] = \t;

}

return n.join();

}

}

function doformat(o){

var htmltxt = ;

if (o == null){

alert(domnode is null!);

return;

}

var _codetxt = ;

if(typeof(o)==object){

switch(o.tagname){

case textarea:

case input:

_codetxt = o.value;

break;

case div:

case span:

_codetxt = o.innertext;

break;

default:

_codetxt = o.innerhtml;

break;

}

}else{

_codetxt = o;

}

var _syn = new class_format(_codetxt);

htmltxt = _syn.format();

return htmltxt;

}

function go()

{

var code = document.getelementbyid(code).value;

var xx = new class_format(code);

var a = new date();

if(document.getelementbyid('cbooperate').selectedindex==1){

xx.iscompress=true;

}else{

xx.style = parseint(document.getelementbyid('cbostyle').value);

}

document.getelementbyid(display).value = xx.format();

}

//-->

</script>

<textarea id=code rows=12 cols=100>

</textarea> <br>

<select id=cbooperate onchange=if(this.selectedindex==1)document.getelementbyid('cbostyle').disabled=true;else document.getelementbyid('cbostyle').disabled=false;>

<option value=0>格式化</option>

<option value=1>壓縮</option>

</select>

<select id=cbostyle>

<option value=0>經(jīng)典</option>

<option value=1>微軟</option>

</select>

<input onclick=go() type=button value=go><br>

<textarea id=display rows=12 cols=100>

</text_area>

</body></html>

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)頁制作
易賢網(wǎng)手機網(wǎng)站地址:格式化javascript代碼
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2026上岸·考公考編培訓(xùn)報班

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)
中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久
亚洲一级在线观看| 久久久久久综合网天天| 亚洲精品永久免费精品| 一本综合久久| 久久全国免费视频| 国产精品乱子乱xxxx| 亚洲国产成人av好男人在线观看| 欧美一区二区三区电影在线观看| 欧美激情aⅴ一区二区三区| 韩日视频一区| 欧美一区国产二区| 国产精品免费一区二区三区观看| 亚洲国产精品一区| 欧美影院一区| 欧美性做爰毛片| 亚洲第一精品在线| 99国产一区| 久久青草欧美一区二区三区| 国产精品视频精品| 亚洲视频综合| 国产精品日韩专区| 亚洲欧美另类在线观看| 国产精品va在线| 亚洲视频第一页| 久久一区国产| 亚洲欧洲另类| 欧美午夜理伦三级在线观看| 亚洲嫩草精品久久| 国产乱码精品一区二区三| 欧美一区1区三区3区公司| 国产在线一区二区三区四区| 欧美亚洲一区二区在线观看| 欧美精品在线观看| 亚洲欧美成人综合| 欧美日韩中文字幕在线| 亚洲第一综合天堂另类专| 久久免费视频这里只有精品| 亚洲国产精品一区二区www在线| 久久精品理论片| 欧美日韩综合视频| 午夜日韩视频| 亚洲第一福利视频| 欧美色欧美亚洲另类二区| 欧美一区二区三区四区高清| 亚洲国产精品久久久久秋霞蜜臀| 久久综合狠狠综合久久激情| 黄色成人av网站| 欧美日韩国产欧| 亚洲欧美在线播放| 狠狠色2019综合网| 欧美午夜精品久久久| 亚洲午夜在线视频| 国产亚洲精品aa| 欧美成人精品在线| 在线观看亚洲精品视频| 免播放器亚洲| 亚洲欧美国内爽妇网| 亚洲第一偷拍| 欧美护士18xxxxhd| 欧美在线视频观看| 亚洲国产精品成人综合| 欧美三级在线| 久久综合精品国产一区二区三区| 亚洲日本精品国产第一区| 狠狠色狠狠色综合人人| 欧美精品福利在线| 久久xxxx精品视频| 亚洲电影免费观看高清完整版在线| 欧美另类变人与禽xxxxx| 欧美一区二区日韩一区二区| 伊人狠狠色j香婷婷综合| 国产精品麻豆成人av电影艾秋| 久久午夜羞羞影院免费观看| 亚洲男人的天堂在线aⅴ视频| 亚洲美女在线看| 在线成人av.com| 国产精品毛片va一区二区三区 | 国产女人18毛片水18精品| 亚洲一区二区三区视频播放| 亚洲国产精品国自产拍av秋霞| 国产精品一区二区你懂的| 欧美黑人在线播放| 媚黑女一区二区| 午夜精品久久久久久久99水蜜桃| 亚洲国产精品99久久久久久久久| 国产亚洲综合精品| 国产手机视频精品| 欧美日韩精品免费看| 欧美国产日韩精品免费观看| 欧美中文在线观看| 亚洲欧美第一页| 亚洲精品在线视频| 樱花yy私人影院亚洲| 免费在线国产精品| 亚洲一区二区三区成人在线视频精品 | 亚洲国产精品一区在线观看不卡| 欧美天堂在线观看| 欧美精品久久久久久| 噜噜噜在线观看免费视频日韩| 亚洲一区二区在线| 欧美专区在线播放| 午夜综合激情| 欧美亚洲专区| 亚洲视频一二三| 亚洲一区视频在线| 久久爱www久久做| 免费久久99精品国产自在现线| 免费在线观看成人av| 蜜桃久久av一区| 欧美日韩精品系列| 国产精品日日做人人爱| 国产日韩欧美一二三区| 国产婷婷色一区二区三区| 国内自拍亚洲| 激情欧美一区二区三区在线观看| 在线观看成人一级片| 中日韩美女免费视频网址在线观看| 亚洲欧洲日韩女同| 亚洲男人第一网站| 你懂的视频欧美| 久久爱www.| 亚洲第一毛片| 国产综合久久久久久| 99国产精品久久久久久久久久| 国产欧美精品在线| 亚洲精品三级| 国产精品乱子乱xxxx| 欧美精品激情blacked18| 最新国产の精品合集bt伙计| 蜜臀久久99精品久久久久久9| 午夜精品理论片| 亚洲黄一区二区| 极品尤物久久久av免费看| 免费人成精品欧美精品| 亚洲美女中文字幕| 亚洲国产成人porn| 欧美成ee人免费视频| 亚洲二区视频在线| 国产精品美女主播| 麻豆视频一区二区| 国产精品日本欧美一区二区三区| 亚洲综合色在线| 1024日韩| 日韩视频一区二区| 亚洲久久在线| 国产精品午夜春色av| 精品1区2区3区4区| 午夜精品免费| 国产视频在线观看一区二区三区| 国产精品一级二级三级| 国产精品主播| 国产丝袜一区二区三区| 国产一区二区欧美日韩| 中文久久乱码一区二区| 久久av免费一区| 欧美系列一区| 国内精品一区二区| 亚洲人精品午夜在线观看| 亚洲综合成人婷婷小说| 久久国产精品久久久| 国产精品一区=区| 亚洲精品午夜精品| 老牛嫩草一区二区三区日本| 国产日韩精品一区二区| 亚洲一区视频| 欧美性大战xxxxx久久久| 亚洲激情视频在线| 久久久久久久久久久久久9999| 你懂的视频欧美| 国产亚洲精品bv在线观看| 亚洲欧美日韩综合一区| 国产精品一区二区久久精品| 亚洲精选国产| 欧美日韩国产限制| 在线看一区二区| 久久不射电影网| 国产精品免费网站| 亚洲综合视频在线| 欧美亚一区二区| 亚洲午夜激情在线| 欧美精品日韩www.p站| 亚洲三级电影全部在线观看高清| 欧美在线黄色| 欧美日韩亚洲国产一区| 亚洲美女在线国产| 欧美视频在线一区二区三区| 亚洲欧美韩国| 一区二区三区亚洲| 欧美电影免费观看大全| 亚洲少妇中出一区| 久久久久久综合| 亚洲人成网在线播放| 欧美成人黑人xx视频免费观看| 欧美黑人国产人伦爽爽爽| 亚洲高清资源| 欧美日本一区| 亚洲男女自偷自拍| 在线看片一区| 欧美日韩免费看| 亚洲永久免费精品|