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

格式化javascript代碼
來(lái)源:易賢網(wǎng) 閱讀:894 次 日期:2014-10-21 15:35:40
溫馨提示:易賢網(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){

//哈希表類(lèi)

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;

//是否大小寫(xiě)敏感

this._casesensitive = true;

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

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

//是函數(shù)申明

this._function = this.str2hashtable(function);

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

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 = \\;

//多行引用開(kāi)始

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; //行號(hào)

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

var function_opened = false;

var bracket_open = false;

var for_open = false;

//按分割字,分塊顯示

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

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

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){

//處理?yè)Q行

} 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)置對(duì)象(后面加一個(gè)空格)

} 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] + ;

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

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

if (quote_opened){

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

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;

}

}

//處理多行注釋地開(kāi)始

} 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>

更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄

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

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

  • 報(bào)班類(lèi)型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢(xún) | 簡(jiǎn)要咨詢(xún)須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專(zhuān)用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢(xún)關(guān)注公眾號(hào):hfpxwx
咨詢(xún)QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專(zhuān)用圖標(biāo)
中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久
久久久精品国产免大香伊| 亚洲欧美日韩一区二区三区在线| 久久久久国产成人精品亚洲午夜| 久久精品欧美日韩精品| 亚洲久久在线| 亚洲欧美日本国产专区一区| 国产欧美精品| 精品电影在线观看| 久久久久国产一区二区三区四区| 亚洲精品一区二区网址| 国产精品自在线| 欧美日韩成人网| 亚洲经典自拍| 久久精品国产综合| 亚洲欧洲在线视频| 亚洲人成在线观看网站高清| 国产精品久久久久久久久久久久 | 免费欧美在线视频| 蜜臀久久99精品久久久久久9| 欧美激情综合五月色丁香小说| 欧美日韩免费看| 欧美日韩亚洲另类| 久久久精品日韩欧美| 国产精品户外野外| 午夜精品久久久久久久蜜桃app| 你懂的视频一区二区| 亚洲激情视频在线| 久久精品成人一区二区三区蜜臀| 免费观看国产成人| 国产精品黄视频| 亚洲一二三四区| 久久久亚洲午夜电影| 亚洲一区亚洲二区| 国产日韩欧美高清免费| 亚洲人在线视频| 国产精品一区久久| 亚洲主播在线观看| 亚洲一区图片| 国产视频一区免费看| 亚洲人成网站999久久久综合| 性欧美办公室18xxxxhd| 国产精品久久久久久久久久妞妞 | 欧美www视频| 亚洲人成欧美中文字幕| 久久久国际精品| 国产日韩欧美在线视频观看| 亚洲美女中文字幕| 一区二区三区欧美在线| 欧美国产日韩a欧美在线观看| 国内一区二区在线视频观看 | 女同性一区二区三区人了人一| 一本色道久久综合亚洲精品高清 | 午夜精品成人在线视频| 日韩午夜三级在线| 欧美三级网址| 亚洲伊人网站| **性色生活片久久毛片| 国产精品一区在线播放| 国产精品久久久久久亚洲调教| 亚洲永久在线观看| 欧美一级在线视频| 欧美亚洲日本国产| 午夜精品久久一牛影视| 欧美亚洲在线| 国产精品成人观看视频免费| 99热精品在线| 一区二区三区在线视频观看| 欧美日韩一区二区三区在线看| 亚洲综合精品自拍| 99精品热视频| 一区二区高清| 最新国产成人在线观看| 91久久国产综合久久蜜月精品| 国产一区二区高清视频| 国产亚洲欧美另类一区二区三区| 欧美精品一线| 欧美激情aⅴ一区二区三区| 欧美 日韩 国产 一区| 欧美电影在线观看| 欧美jizzhd精品欧美巨大免费| 久久精品中文字幕免费mv| 亚洲一区二区三区四区视频| 欧美一级久久| 久久这里有精品15一区二区三区| 午夜精品网站| 久久中文字幕导航| 欧美日韩国产成人高清视频| 欧美日韩无遮挡| 国产亚洲综合在线| 国产精品久久久91| 国语自产精品视频在线看一大j8 | 亚洲一区二区三| 亚洲一区二区三区高清不卡| 亚洲一区二区在| 久久免费视频在线观看| 免费中文日韩| 欧美日韩福利视频| 国产日韩精品一区二区三区 | 国产欧美日韩不卡免费| 国产精品s色| 亚洲欧美成aⅴ人在线观看| 亚洲天堂av高清| 欧美1区免费| 欧美美女视频| 亚洲第一精品夜夜躁人人爽| 欧美亚洲综合网| 欧美美女喷水视频| 在线不卡欧美| 久久国产一区二区| 国产精品嫩草99a| 一级成人国产| 欧美黄色一级视频| 亚洲国产精品黑人久久久 | 狠狠色狠狠色综合人人| 亚洲乱码国产乱码精品精 | 久久久噜噜噜久久| 女人天堂亚洲aⅴ在线观看| 国产在线不卡| 久久精品成人一区二区三区| 欧美日韩一卡| 亚洲一区视频在线观看视频| 欧美日韩亚洲高清一区二区| 亚洲精品1区| 欧美v日韩v国产v| 国产午夜精品麻豆| 久久久久国产精品厨房| 伊人久久大香线蕉综合热线 | 欧美性淫爽ww久久久久无| 亚洲人体影院| 欧美成人自拍| 夜夜夜精品看看| 国产精品一区三区| 欧美一区二区精品| 怡红院精品视频| 日韩一区二区精品| 欧美freesex8一10精品| 悠悠资源网亚洲青| 欧美午夜在线观看| 亚洲一区三区电影在线观看| 国产欧美日韩精品在线| 久久久av毛片精品| 亚洲一区亚洲| 在线播放视频一区| 欧美日本在线一区| 午夜精品久久99蜜桃的功能介绍| 黄色成人在线| 国产午夜精品久久久| 欧美国产日本在线| 久久综合九色| 久久婷婷国产综合尤物精品 | 亚洲在线视频观看| 伊人精品久久久久7777| 国产精品一级久久久| 久久亚洲视频| 久久精品人人爽| 久久久久久伊人| 久久精品国产免费观看| 亚洲综合色丁香婷婷六月图片| 亚洲国产色一区| 99精品99| 亚洲人成网站色ww在线| 亚洲国产成人av好男人在线观看| 欧美视频免费看| 欧美日本久久| 欧美日韩精品免费在线观看视频| 欧美国产高清| 国产精品国产一区二区| 欧美视频免费看| 国产欧美午夜| 亚洲国产成人精品女人久久久 | 国产精品一区在线观看| 欧美日韩国产一级| 欧美大色视频| 欧美日韩精选| 欧美久久电影| 久久精品国产清自在天天线| 亚洲欧美日韩天堂| 久久久久国内| 欧美高清一区二区| 欧美婷婷六月丁香综合色| 国产精品毛片a∨一区二区三区|国 | 一区在线影院| 日韩午夜剧场| 久久久精彩视频| 欧美日韩视频在线第一区| 黄色成人小视频| 在线视频日韩精品| 欧美一级免费视频| 欧美午夜精品久久久| 永久免费视频成人| 久久精品人人做人人爽| 欧美性片在线观看| 亚洲毛片av| 欧美经典一区二区| 狠狠色噜噜狠狠色综合久| 亚洲一区二区在线免费观看| 美女主播一区| 亚洲国产另类久久久精品极度| 暖暖成人免费视频| 国产一区欧美日韩|