JS代碼格式化和語(yǔ)法著色V2
更新時(shí)間:2006年10月14日 00:00:00 作者:
升級(jí)到第二版,開一貼以示慶賀,哈哈哈
自 Ver1.1 升級(jí)內(nèi)容
1. 增加函數(shù)列表
2. 增加函數(shù) Export 功能
3. 增加函數(shù)依存關(guān)系分析 (這個(gè)功能個(gè)人未見其他軟件實(shí)現(xiàn)過(guò),自己創(chuàng)意,問題多多,目前分析能力還是比較有限的,只能分析全局函數(shù)依存關(guān)系,可能在復(fù)雜代碼的情況下出現(xiàn) bug)
4. 修正 for 語(yǔ)句分析 bug
5. 修正 語(yǔ)法折疊的 bug
6. 改進(jìn) Collapse All ※ Expand All 函數(shù)工作方式,避免行數(shù)太大時(shí)的死機(jī)
7. 改進(jìn)行號(hào)分析機(jī)制,避免行數(shù)太大時(shí)的死機(jī)
<html>
<head>
<title>JSer Ver 2.0</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<style>
/* Global CSS */
* { padding:0px; margin:0px; font-size:13px; font-family: arial 宋體; }
body { overflow:auto; border:0px none black; background-color:buttonface; }
li { margin:0px 0px 0px 40px; padding:2px 4px; }
div { font-size:13px; line-height:14px; }
p { font-size:13px; line-height:14px; }
/* Class CSS */
.codeRoot { line-height:14px; }
.quote { color:#999; }
.comments { color: #009090; }
.indent { margin-left:25px; }
.regexp { color:#F000F0; }
.keyWord { color:blue; }
.object { color:red; }
.method_property { color:#FF8000; }
.operator { color:#004000; }
.colsp { font-size:12px; width:14px; height:14px; overflow:hidden; border:1px outset buttonface; text-align:center;
cursor:pointer; padding-left:2px; }
.colsp2 { font-size:12px; width:14px; height:14px; overflow:hidden; border:1px inset buttonface; text-align:center;
cursor:pointer; padding-left:2px; color:red!important; background-color:#E0FFF8!important; }
/* Identified CSS */
#divTools { height:20px; border-bottom:1px solid #555; padding-left:15px; }
#divTools a { color:navy; text-decoration:none; height:20px; line-height:20px; padding:0px 25px; }
#divTools a:hover { color:white; background-color:navy; text-decoration:none; height:20px; line-height:20px; }
#divJSInput { display:none; width:600px; height:450px; border:2px outset buttonface; position:absolute; background-
color:buttonface; z-Index:2; }
#divJSInputTitle { color:white; background-color:navy; height:20px; line-height:20px; padding:0px 10px; cursor:default; }
#txtJSInput { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white;}
#divJSInputBar { height:24px; padding:0px 4px; }
#divJSInputBar input { width:110px; height:22px; border:1px solid #555; line-height:20px; }
#divMain { width:100%; height:500; overflow:hidden; position:relative; }
#divJSOutputLineNo { width:32px; height:100%; overflow:hidden; background-color:#DDD; position:absolute; left:0px; top:0px;
text-align:right; }
#divJSOutputLineNo p { font-size:12px; line-height:14px; }
#divJSOutputPlus { width:14px; height:100%; overflow:hidden; background-color:#EEE; position:absolute; left:32px; top:0px; z
-Index:2; }
#divJSOutputPlus p { font-size:12px; line-height:14px; }
#divJSOutput { background-color:white; border:1px inset buttonface; height:100%; position:absolute; left:45px; top:0px;
overflow:scroll; }
#divWaiting { display:none; width:400px; height:60px; border:1px solid buttonface; position:absolute; background-
color:#E0F0F0; z-Index:3; text-align:center; padding-top:10px; }
#divWaiting input { width:140px; height:22px; border:1px solid #555; line-height:20px; cursor:default; margin-top:4px; }
#divJSExport { display:none; width:600px; height:450px; border:2px outset buttonface; position:absolute; background-
color:buttonface; z-Index:2; }
#divJSExportTitle { color:white; background-color:navy; height:20px; line-height:20px; padding:0px 10px; cursor:default; }
#selJSExport { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white; }
#divJSExportContent { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white; display:none; }
#divJSExportBar { height:24px; padding:0px 4px; }
#divJSExportBar input { width:170px; height:22px; border:1px solid #555; line-height:20px; }
</style>
<script type="text/javascript">
/**********************
Author: Hutia
*********************/
window.onload=init;
//------------------
// Static Variable
//------------------
var KEYWORDS="abstract break byte case catch char class const continue default delete do double else extends false final
finally float for function goto if implements import in instanceof int interface long native null package private protected
public reset return short static super switch synchronized this throw transient true try var void while with";
var OBJECTS="Anchor Applet Area Arguments Array Boolean Button Checkbox Collection Crypto Date Dictionary Document Drive
Drives Element Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders Form Frame Function Global Hidden
History HTMLElement Image Infinity Input JavaArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType
Navigator Number Object Option Packages Password Plugin PrivilegeManager Random RegExp Screen Select String Submit Text
Textarea URL VBArray Window WScript";
var METHODS_PROPERTIES="above abs acos action activeElement alert alinkColor all altKey anchor anchors appCodeName applets
apply appName appVersion arguments arity asin assign atan atan2 atob availHeight availLeft availTop availWidth ActiveXObject
back background below bgColor big blink blur bold border borderWidths bottom btoa button call callee caller cancelBubble
captureEvents ceil charAt charCodeAt charset checked children classes className clear clearInterval clearTimeout click
clientInformation clientX clientY close closed colorDepth compile complete concat confirm constructir contains contextual
cookie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected defaultStatus defaultValue description
disableExternalCapture disablePrivilege document domain E Echo element elements embeds enabledPlugin enableExternalCapture
enablePrivilege encoding escape eval event exec exp expando FromPoint fgColor fileName find fixed floor focus fontColor
fontSize form forms forward frames fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear getHours
getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot getTime getTimezoneOffset getUTCDate getUTCDay
getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent
Height hash hidden history home host hostName href hspace id ids ignoreCase images index indexOf inner innerHTML innerText
innerWidth insertAdjacentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode Links LN10 LN2 LOG10E
LOG2E lang language lastIndex lastIndexOf lastMatch lastModified lastParen layers layerX layerY left leftContext length link
linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins match max menubar method mimeTypes min modifiers
moveAbove moveBelow moveBy moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator netscape next
number offscreenBuffering offset offsetHeight offsetLeft offsetParent offsetTop offsetWidth offsetX offsetY onabort onblur
onchange onclick ondblclick ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmousedown onmousemove
onmouseout onmouseover onmouseup onmove onreset onresize onsubmit onunload open opener options outerHeight outerHTML
outerText outerWidth POSITIVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentElement parentLayer
parentWindow parse parseFloat parseInt pathname personalbar pixelDepth platform plugins pop port pow preference previous
print prompt protocol prototype push random readyState reason referrer refresh releaseEvents reload removeAttribute
removeMember replace resizeBy resizeTo returnValue reverse right rightcontext round SQRT1_2 SQRT2 screenX screenY scroll
scrollbars scrollBy scrollIntoView scrollTo search select selected selectedIndex self setAttribute setDay setFullYear
setHotkeys setHours setInterval setMember setMilliseconds setMinutes setMonth setResizable setSeconds setSlot setTime
setTimeout setUTCDate setUTCFullYear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear
setZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort source sourceIndex splice split sqrt src
srcElement srcFilter status statusbar stop strike style sub submit substr substring suffixes sun sup systemLanguage TYPE
tagName tags taint taintEnabled tan target test text title toElement toGMTString toLocaleString toLowerCase toolbar top
toString toUpperCase toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent userLanguage value valueOf
visibility vlinkColor vspace watch which width window write writeln x y zIndex";
var OPS="! $ % & * + - // / : < = > ? [ ] ^ | ~ is new sizeof typeof unchecked";
var regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)","g");
var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|(\\W")+"$)","g");
var regMP=new RegExp("(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)","g");
//var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")+"$)","g");
//------------------
// Global Variables
//------------------
var divJSInput, txtJSInput, divMain, divJSOutputLineNo, divJSOutputPlus, divJSOutput, divWaiting;
var spnProcess, cmdStop, divJSExport, selJSExport, divJSExportContent;
var glbStr, glbP, glbRe, curRe, glbTimer, glbBusy, glbFuntionNames;
function init(){
// init global variables
divJSInput=document.getElementById("divJSInput");
txtJSInput=document.getElementById("txtJSInput");
divMain=document.getElementById("divMain");
divJSOutputLineNo=document.getElementById("divJSOutputLineNo");
divJSOutputPlus=document.getElementById("divJSOutputPlus");
divJSOutput=document.getElementById("divJSOutput");
divWaiting=document.getElementById("divWaiting");
spnProcess=document.getElementById("spnProcess");
cmdStop=document.getElementById("cmdStop");
divJSExport=document.getElementById("divJSExport");
selJSExport=document.getElementById("selJSExport");
divJSExportContent=document.getElementById("divJSExportContent");
// init window state
maximizeWindow();
divMain.style.width=document.body.clientWidth-4;
divMain.style.height=document.body.clientHeight-26;
divJSOutput.style.width=document.body.clientWidth-72;
// init global events
divJSOutputLineNo.onselectstart=divJSOutputLineNo.onselect=divJSOutputPlus.onselectstart=divJSOutputPlus.onselect=cancelEvent
divJSOutput.onscroll=divJSOutput_onscroll;
divJSInput.onkeydown=divJSInput_keydown;
divJSExport.onkeydown=divJSExport_keydown;
}
//------------------
// event scripts
//------------------
function cancelEvents(e){
var e=window.event?window.event:e;
e.returnValue=false;
return(false);
}
function divJSInput_keydown(e){
var e=window.event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var sel;
if(e.keyCode==27)hideJSInput();
if(e.keyCode==13&&e.ctrlKey)execJSInput();
if(e.keyCode==9&&srcEle==txtJSInput){
document.selection.createRange().text="\t";return(false); // not support FF
}
}
function divJSExport_keydown(e){
var e=window.event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var sel;
if(e.keyCode==27)hideJSExport();
if(e.keyCode==13&&e.ctrlKey)hideJSExport();
}
function divJSOutput_onscroll(){
divJSOutputLineNo.scrollTop=divJSOutputPlus.scrollTop=divJSOutput.scrollTop;
}
//------------------
// functional scripts
//------------------
function showJSInput(){
if(glbBusy)return;
hideJSExport();
with(divJSInput.style){
display="block";
left=(document.body.clientWidth-divJSInput.offsetWidth)/2;
top=(document.body.clientHeight-divJSInput.offsetHeight)/2;
}
txtJSInput.focus();
return(false);
}
function showJSExport(){
if(glbBusy)return;
hideJSInput();
with(divJSExport.style){
display="block";
left=(document.body.clientWidth-divJSExport.offsetWidth)/2;
top=(document.body.clientHeight-divJSExport.offsetHeight)/2;
}
divJSExportContent.style.display="none";
selJSExport.style.display="block";
selJSExport.focus();
return(false);
}
function hideJSInput(){
divJSInput.style.display="none";
}
function hideJSExport(){
divJSExport.style.display="none";
}
function execJSInput(){
hideJSInput();
divJSOutput.innerHTML="";
divJSOutputLineNo.innerHTML="";
divJSOutputPlus.innerHTML="";
glbStr=txtJSInput.innerText; // not support FF
glbP=0;
glbFuntionNames=new Array();
curRe=glbRe=document.createElement("div");
divJSOutput.appendChild(glbRe);
glbRe.className="codeRoot";
while(selJSExport.options.length>0)selJSExport.options[0]=null;
showWait(startRecalcLine);
core_analysis();
}
function execJSExport(){
var fns=new Array(), fcs=new Array(), str;
for(var i=0; i<selJSExport.options.length; i++){
if(selJSExport.options[i].selected){
fns.push(selJSExport.options[i].value);
str=selJSExport.options[i].obj.outerHTML;
try{
str+=selJSExport.options[i].obj.nextSibling.outerHTML;
str+=selJSExport.options[i].obj.nextSibling.nextSibling.outerHTML;
}catch(e){}
fcs.push(str);
}
}
if(fns.length==0)return;
divJSExportContent.style.display="block";
selJSExport.style.display="none";
divJSExportContent.innerHTML=fcs.join("\r\n<br>\r\n");
}
function execJSExport_Dep(){
var fns=new Array(), fcs=new Array(), str, regFNs=new Array(), needDepthTest;
for(var i=0; i<selJSExport.options.length; i++){
if(selJSExport.options[i].selected){
fns.push(selJSExport.options[i].value);
try{
str=selJSExport.options[i].obj.nextSibling.outerHTML;
}catch(e){}
fcs.push(str);
}
}
if(fns.length==0)return;
divJSExportContent.style.display="none";
selJSExport.style.display="block";
needDepthTest=false;
for(var i=0;i<glbFuntionNames.length;i+=1){
if(!selJSExport.options[i].selected){
for(j=0;j<fcs.length;j++){
if(html2txt(fcs[j]).match(glbFuntionNames[i].replace(/\./g,"\\."))){
selJSExport.options[i].selected=true;
needDepthTest=true;
break;
}
}
}
}
if(needDepthTest)execJSExport_Dep();
}
function showWait(onstop){
glbBusy=true;
document.body.style.cursor="wait";
with(divWaiting.style){
display="block";
left=(document.body.clientWidth-divWaiting.offsetWidth)/2;
top=(document.body.clientHeight-divWaiting.offsetHeight)/2;
}
spnProcess.innerHTML="0.00% ( 0 / 0 )";
divWaiting.onstop=onstop;
cmdStop.focus();
return(false);
}
function hideWait(){
glbBusy=false;
document.body.style.cursor="";
divWaiting.style.display="none";
try{clearTimeout(glbTimer);}catch(e){}
try{divWaiting.onstop();}catch(e){}
return(false);
}
function stopExec(){ hideWait(); }
function startRecalcLine(){
var re="", re2="";
if(glbBusy)return;
glbBusy=true;
for(var i=0;i<parseInt(divJSOutput.scrollHeight/14+200);i++){
re+="<p>"+(i+1)+"</p>";
re2+="<p> </p>";
}
divJSOutputLineNo.innerHTML=re;
divJSOutputPlus.innerHTML=re2;
divJSOutputPlus.buttons=new Array();
glbP=0;
showWait();
recalcLine();
return(false);
}
function recalcLine(){
var objs, j;
objs=document.getElementsByTagName("div");
for(var i=glbP;i<objs.length&&(i-glbP<30);i++){
if(objs[i].className=="indent"){
j=parseInt(objs[i].offsetTop/14)-1;
divJSOutputPlus.childNodes[j].className="colsp";
divJSOutputPlus.childNodes[j].innerHTML="-";
divJSOutputPlus.childNodes[j].linkedDIV=objs[i];
divJSOutputPlus.childNodes[j].startIndex=j+1;
divJSOutputPlus.childNodes[j].endIndex=j+Math.round(objs[i].offsetHeight/14);
if(objs[i].innerHTML!="")divJSOutputPlus.childNodes[j].endIndex++;
divJSOutputPlus.childNodes[j].switchDIV=divJSOutputPlus.childNodes[j].onclick=switchDIV;
divJSOutputPlus.buttons.push(divJSOutputPlus.childNodes[j]);
}
}
spnProcess.innerHTML=parseFloat(glbP/objs.length*100).toFixed(2)+"% ( "+glbP+" / "+objs.length+" )";
if(i<objs.length){glbP=i; glbTimer=setTimeout(recalcLine); return;}
stopExec();
divJSOutput_onscroll();
}
function switchDIV(disp){
var y, obj;
if((this.className=="colsp"||disp=="hide")&&disp!="show"){
this.className="colsp2";
this.innerHTML="+";
for(var i=this.startIndex;i<this.endIndex;i++){
divJSOutputLineNo.childNodes[i].style.display="none";
divJSOutputPlus.childNodes[i].style.display="none";
}
this.linkedDIV.style.display="none";
}else{
this.className="colsp";
this.innerHTML="-";
this.linkedDIV.style.display="block";
for(var i=this.startIndex;i<this.endIndex;i++){
divJSOutputLineNo.childNodes[i].style.display="block";
divJSOutputPlus.childNodes[i].style.display="block";
if(divJSOutputPlus.childNodes[i].className=="colsp2"){
i=divJSOutputPlus.childNodes[i].endIndex-1;
}
}
}
divJSOutput_onscroll();
}
function collapseAll(index){
index=isNaN(parseInt(index))?0:parseInt(index);
if(!divJSOutputPlus.buttons)return;
if(index<0)index=0;
if(index>divJSOutputPlus.buttons.length)return;
for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("hide");
setTimeout("collapseAll("+i+")");
}
function expandAll(index){
index=isNaN(parseInt(index))?0:parseInt(index);
if(!divJSOutputPlus.buttons)return;
if(index<0)index=0;
if(index>divJSOutputPlus.buttons.length)return;
for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("show");
setTimeout("expandAll("+i+")");
}
function core_analysis(){
var str=" ", c="", lastState="", seq, intNextQuote, intTemp, intCount, intWordStart;
spnProcess.innerHTML=parseFloat(glbP/glbStr.length*100).toFixed(2)+"% ( "+glbP+" / "+glbStr.length+" )";
for(var i=glbP;i<glbStr.length;i++){
c=glbStr.charAt(i);
str+=htmlEncode(c);
switch(c){
case "\r": case " ": case "\t":
if(lastState=="\r\n"){str=" ";break;}
str=str.substring(0,str.length-htmlEncode(c).length);
if(lastState=="blank")break;
if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){
str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP);
}
str+=htmlEncode(c);
lastState="blank";
break;
case ";":
if(str.match(/\Wfor.*?\(/i))break;
// attention there's no break here
case "\n":
if(lastState=="\r\n"){str=" ";break;}
outputLn(str);
str=" ";
lastState="\r\n";
if(i-glbP>200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "\"":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\"",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\"";
i=intNextQuote;
lastState="";
break;
case "\'":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\'",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\'";
i=intNextQuote;
lastState="";
break;
case "\/":
if(glbStr.charAt(i+1)=="\/"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("\r\n",intNextQuote+1);
if(intNextQuote==-1)intNextQuote=glbStr.length;
str=str.substring(0,str.length-1);
str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"<\/span>";
i=intNextQuote;
}else if(glbStr.charAt(i+1)=="*"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("*\/",intNextQuote+1);
if(intNextQuote==-1)return;
str=str.substring(0,str.length-1);
str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"*\/<\/span>";
i=intNextQuote+1;
}else if(str.match(/[=(][ \t]*\//)){
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\/",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"regexp\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"<\/span>\/";
i=intNextQuote;
lastState="";
}
lastState="";
break;
case "{":
outputLn(str);
str=" ";
seq=document.createElement("div");
seq.className="indent";
curRe.appendChild(seq);
curRe=seq;
lastState="\r\n";
if(i-glbP>200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "}":
outputLn(str.substring(0,str.length-1));
str="} ";
lastState="";
curRe=curRe.parentNode;
break;
default:
if(c.match(/\w/)&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;}
if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){
str=str.substring(0,str.length-htmlEncode(c).length);
str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)+htmlEncode(c);
}
lastState="";
break;
}
}
if(i==glbStr.length){
if(str!=""){ outputLn(str); str=" "; }
stopExec();
}
}
function outputLn(theStr){
var seq, txt, fn;
if(html2txt(theStr).match(/^[ \t\r\n]*$/))return;
seq=document.createElement("p");
seq.innerHTML=theStr;
curRe.appendChild(seq);
txt=html2txt(theStr);
if(!txt)return;
fn=txt.match(/function[ \t\r\n]+([\.\w]+?)[ \t\r\n]*\(.*?\)[ \t\r\n]*\{/);
if(fn){
glbFuntionNames.push(fn[1]);
selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]);
selJSExport.options[selJSExport.options.length-1].obj=seq;
}
fn=txt.match(/([\.\w]+?)[ \t\r\n]*=[ \t\r\n]*function\W*\(.*?\)[ \t\r\n]*\{/);
if(fn){
glbFuntionNames.push(fn[1]);
selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]);
selJSExport.options[selJSExport.options.length-1].obj=seq;
}
}
function clKW(str){ return(str.charAt(0)+"<span class=\"keyWord\">"+str.substring(1)+"</span>"); }
function clObj(str){ return(str.charAt(0)+"<span class=\"object\">"+str.substring(1)+"</span>"); }
function clMP(str){ return(str.charAt(0)+"<span class=\"method_property\">"+str.substring(1)+"</span>"); }
function clOP(str){ return(str.charAt(0)+"<span class=\"operator\">"+str.substring(1)+"</span>"); }
//------------------
// global scripts
//------------------
function maximizeWindow(){
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
}
function htmlEncode(strS){
return(strS.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/
\r\n/g,"<br\/>"));
}
function html2txt(strS){
return(strS.replace(/<.+?>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/<br\/?
>/g,"\r\n").replace(/&/g,"&"));
}
</script>
</head>
<body>
<!-- Author: Hutia -->
<div id="divTools">
<a href="#" onclick="showJSInput();return(false);">Input JS</a>
<a href="#" onclick="collapseAll();return(false);">Collapse All</a>
<a href="#" onclick="expandAll();return(false);">Expand All</a>
<a href="#" onclick="showJSExport();return(false);">Export JS</a>
</div>
<div id="divJSInput">
<div id="divJSInputTitle">Please Input the JS:</div>
<textarea id="txtJSInput">
/********************** Author: Hutia *********************/
window.onload=init; //------------------ // Static Variable //-----
-------------
var KEYWORDS="abstract break byte case catch char class cons
t continue default delete do double else extends false final finally f
loat for function goto if implements import in instanceof int interface&nbs
p;long native null package private protected public reset return short stat
ic super switch synchronized this throw transient true try var void wh
ile with"; var OBJECTS="Anchor Applet Area Arguments Array Boolean 
;Button Checkbox Collection Crypto Date Dictionary Document Drive Drives Element
Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders For
m Frame Function Global Hidden History HTMLElement Image Infinity Input Jav
aArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType Naviga
tor Number Object Option Packages Password Plugin PrivilegeManager Random RegExp
Screen Select String Submit Text Textarea URL VBArray Window WScript"
; var METHODS_PROPERTIES="above abs acos action activeElement alert alinkCol
or all altKey anchor anchors appCodeName applets apply appName appVersion a
rguments arity asin assign atan atan2 atob availHeight availLeft availTop&
nbsp;availWidth ActiveXObject back background below bgColor big blink blur bold&
nbsp;border borderWidths bottom btoa button call callee caller cancelBubble capt
ureEvents ceil charAt charCodeAt charset checked children classes className clea
r clearInterval clearTimeout click clientInformation clientX clientY close clos
ed colorDepth compile complete concat confirm constructir contains contextual co
okie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected&nb
sp;defaultStatus defaultValue description disableExternalCapture disablePrivilege document doma
in E Echo element elements embeds enabledPlugin enableExternalCapture enablePri
vilege encoding escape eval event exec exp expando FromPoint fgColor fileNa
me find fixed floor focus fontColor fontSize form forms forward frames 
;fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear
getHours getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot&nbs
p;getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMillise
conds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent
Height hash hidden history home host hostName href hspace id id
s ignoreCase images index indexOf inner innerHTML innerText innerWidth insertAdj
acentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode&nbs
p;Links LN10 LN2 LOG10E LOG2E lang language lastIndex lastIndexOf lastMatc
h lastModified lastParen layers layerX layerY left leftContext length link
linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins 
;match max menubar method mimeTypes min modifiers moveAbove moveBelow moveBy&nbs
p;moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator 
;netscape next number offscreenBuffering offset offsetHeight offsetLeft offsetParent
offsetTop offsetWidth offsetX offsetY onabort onblur onchange onclick ondblclick 
;ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmoused
own onmousemove onmouseout onmouseover onmouseup onmove onreset onresize onsubmit&nbs
p;onunload open opener options outerHeight outerHTML outerText outerWidth POSIT
IVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentEleme
nt parentLayer parentWindow parse parseFloat parseInt pathname personalbar pixelDepth
platform plugins pop port pow preference previous print prompt proto
col prototype push random readyState reason referrer refresh releaseEvents reloa
d removeAttribute removeMember replace resizeBy resizeTo returnValue reverse right&nb
sp;rightcontext round SQRT1_2 SQRT2 screenX screenY scroll scrollbars scrollBy&
nbsp;scrollIntoView scrollTo search select selected selectedIndex self setAttribute s
etDay setFullYear setHotkeys setHours setInterval setMember setMilliseconds setMinut
es setMonth setResizable setSeconds setSlot setTime setTimeout setUTCDate setUTCFullY
ear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear se
tZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort
source sourceIndex splice split sqrt src srcElement srcFilter status statu
sbar stop strike style sub submit substr substring suffixes sun sup sy
stemLanguage TYPE tagName tags taint taintEnabled tan target test text&nbs
p;title toElement toGMTString toLocaleString toLowerCase toolbar top toString toUpper
Case toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent 
;userLanguage value valueOf visibility vlinkColor vspace watch which width 
;window write writeln x y zIndex"; var OPS="! $ %
& * + - // / : < = > ? [ ]
^ | ~ is new sizeof typeof unchecked"; var
regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)
","g"); var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|
(\\W")+"$)","g"); var regMP=new RegExp("
(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)
","g"); //var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")
+"$)","g"); //------------------ // Global Variables //--
----------------
var divJSInput, txtJSInput, divMain, divJSOutputLineNo, divJSOutputPlus, divJSOutput,
divWaiting; var spnProcess, cmdStop, divJSExport, selJSExport, divJSExportContent;
3; var glbStr, glbP, glbRe, curRe, glbTimer, glbBusy, glbFuntionNames; &
#10; function init()
{ // init global variables divJSInput=document.getElementById
("divJSInput"); txtJSInput=document.getElementById
("txtJSInput"); divMain=document.getElementById
("divMain"); divJSOutputLineNo=document.getElementById
("divJSOutputLineNo"); divJSOutputPlus=document.getElementById
("divJSOutputPlus"); divJSOutput=document.getElementById
("divJSOutput"); divWaiting=document.getElementById
("divWaiting"); spnProcess=document.getElementById
("spnProcess"); cmdStop=document.getElementById
("cmdStop"); divJSExport=document.getElementById
("divJSExport"); selJSExport=document.getElementById
("selJSExport"); divJSExportContent=document.getElementById
("divJSExportContent"); // init window state maximizeW
indow(); divMain.style.width=document.body.clientWidth-
4; divMain.style.height=document.body.clientHeight-
26; divJSOutput.style.width=document.body.clientWidth-
52; // init global events divJSOutputLineNo.onse
lectstart=divJSOutputLineNo.onselect=divJSOutputPlus.onselectstart=divJSOutputPlus.onselect=cancelEvents; divJ
SOutput.onscroll=divJSOutput_onscroll; divJSInput.onkeydown=divJSInput_keydown;  
;divJSExport.onkeydown=divJSExport_keydown; } //------------------
// event scripts //------------------ function cancelEvents(e)
{ var e=window.event?window.event:e; e.returnValue=false; return
(false); } function divJSInput_keydown(e){ var e=window.event?
window.event:e; var srcEle=e.srcElement?
e.srcElement:e.target; var sel; if(e.keyCode==27)hideJSInput(); if
(e.keyCode==13&&e.ctrlKey)execJSInput(); if(e.keyCode==9&&srcEle==txtJSInput)
{ document.selection.createRange().text="\t";return
(false); // not support FF } }
function divJSExport_keydown(e){ var e=window.event?
window.event:e; var srcEle=e.srcElement?
e.srcElement:e.target; var sel; if(e.keyCode==27)hideJSExport(); if
(e.keyCode==13&&e.ctrlKey)hideJSExport(); } function divJSOutput_onscroll()
{ divJSOutputLineNo.scrollTop=divJSOutputPlus.scrollTop=divJSOutput.scrollTop; }
//------------------ // functional scripts //-----------
------- function showJSInput(){ if(glbBusy)return; hideJSExport
(); with(divJSInput.style){ display="block"; left=
(document.body.clientWidth-divJSInput.offsetWidth)/2; top=(document.body.clientHeight-
divJSInput.offsetHeight)/2; } txtJSInput.focus
(); return(false); } function showJSExport()
{ if(glbBusy)return; hideJSInput(); with(divJSExport.style)
{ display="block"; left=(document.body.clientWidth-
divJSExport.offsetWidth)/2; top=(document.body.clientHeight-
divJSExport.offsetHeight)/2; }
divJSExportContent.style.display="none"; selJSExport.style.display="block"
; selJSExport.focus(); return(false); }
function hideJSInput(){ divJSInput.style.display="none"; }
function hideJSExport(){ divJSExport.style.display="none"; }
function execJSInput(){ hideJSInput
(); divJSOutput.innerHTML=""; divJSOutputLineNo.innerHTML=""
;; divJSOutputPlus.innerHTML=""; glbStr=txtJSInput.value; &n
bsp;glbP=0; glbFuntionNames=new Array(); curRe=glbRe=document.createElement
("div"); divJSOutput.appendChild
(glbRe); glbRe.className="codeRoot"; while
(selJSExport.options.length>0)selJSExport.options[0]=null; showWait
(startRecalcLine); core_analysis(); } function execJSExport()
{ var fns=new Array(), fcs=new Array(), str; for
(var i=0; i<selJSExport.options.length; i++){ if(selJSExport.options[i].selected)
{ fns.push(selJSExport.options[i].value); str=selJSExport.options
[i].obj.outerHTML; try{ str+=selJSExport.options
[i].obj.nextSibling.outerHTML; str+=selJSExport.options
[i].obj.nextSibling.nextSibling.outerHTML; }catch(e){} fcs.push
(str); } } if(fns.length==0)
return; divJSExportContent.style.display="block"; selJSExport.style.d
isplay="none"; divJSExportContent.innerHTML=fcs.join
("\r\n<br>\r\n"); } function execJSExport_Dep()
{ var fns=new Array(), fcs=new Array(), str, regFNs=new Array
(), needDepthTest; for(var i=0; i<selJSExport.options.length; i++)
{ if(selJSExport.options[i].selected){ fns.push(selJSExport.options
[i].value); try{ str=selJSExport.options
[i].obj.nextSibling.outerHTML; }catch(e){} fcs.push
(str); } } if(fns.length==0)
return; divJSExportContent.style.display="none"; selJSExport.style.di
splay="block"; needDepthTest=false; for
(var i=0;i<glbFuntionNames.length;i+=1){ if(!selJSExport.options[i].selected)
{ for(j=0;j<fcs.length;j++){ if(html2txt(fcs[j]).match
(glbFuntionNames[i].replace(/\./g,"\\."))){ selJSExport.options
[i].selected=true; needDepthTest=true; break;&#
13; } } } } if
(needDepthTest)execJSExport_Dep(); } function showWait(onstop)
{ glbBusy=true; document.body.style.cursor="wait"; wit
h(divWaiting.style){ display="block"; left=(document.body.clientWidth-
divWaiting.offsetWidth)/2; top=(document.body.clientHeight-divWaiting.offsetHeight)/2; }
spnProcess.innerHTML="0.00% ( 0 / 0 )
"; divWaiting.onstop=onstop; cmdStop.focus(); return(false); }
function hideWait()
{ glbBusy=false; document.body.style.cursor=""; divWaiting.style.displ
ay="none"; try{clearTimeout(glbTimer);}catch(e){} try{divWaiting.onstop();}catch(e)
{} return(false); } function stopExec(){ hideWait(); }
function startRecalcLine()
{ var re="", re2=""; if(glbBusy)
return; glbBusy=true; for(var i=0;i<parseInt
(divJSOutput.scrollHeight/14+200);i++){ re+="<p>"+(i+1)
+"</p>"; re2+="<p>&nbsp;</p>"; }
divJSOutputLineNo.innerHTML=re; divJSOutputPlus.innerHTML=re2;
divJSOutputPlus.buttons=new Array(); glbP=0; showWait
(); recalcLine(); return(false); }
function recalcLine()
{ var objs, j; objs=document.getElementsByTagName
("div"); for(var i=glbP;i<objs.length&&(i-glbP<30);i++){ if
(objs[i].className=="indent"){ j=parseInt(objs[i].offsetTop/14)-
1; divJSOutputPlus.childNodes
[j].className="colsp"; divJSOutputPlus.childNodes[j].innerHTML="-
"; divJSOutputPlus.childNodes[j].linkedDIV=objs
[i]; divJSOutputPlus.childNodes
[j].startIndex=j+1; divJSOutputPlus.childNodes[j].endIndex=j+Math.round(objs[i].offsetHeight/14)
+1; divJSOutputPlus.childNodes[j].switchDIV=divJSOutputPlus.childNodes
[j].onclick=switchDIV; divJSOutputPlus.buttons.push(divJSOutputPlus.childNodes
[j]); } } spnProcess.innerHTML=parseFloat(glbP/objs.length*100).toFixed
(2)+"% ( "+glbP+" / "+objs.length+" )"; if
(i<objs.length){glbP=i; glbTimer=setTimeout(recalcLine); return;} stopExec
(); divJSOutput_onscroll(); } function switchDIV(disp)
{ var y, obj; if((this.className=="colsp"||disp=="hide")
&&disp!="show")
{ this.className="colsp2"; this.innerHTML="+"; &
nbsp;for(var i=this.startIndex;i<this.endIndex;i++){ divJSOutputLineNo.childNodes
[i].style.display="none"; divJSOutputPlus.childNodes
[i].style.display="none"; }
this.linkedDIV.style.display="none"; }else
{ this.className="colsp"; this.innerHTML="-
"; this.linkedDIV.style.display="block"; for
(var i=this.startIndex;i<this.endIndex;i++){ divJSOutputLineNo.childNodes
[i].style.display="block"; divJSOutputPlus.childNodes
[i].style.display="block"; if(divJSOutputPlus.childNodes
[i].className=="colsp2"){ i=divJSOutputPlus.childNodes[i].endIndex-
1; } } } divJSOutput_onscroll(); }
function collapseAll(index){ index=isNaN(parseInt(index))?0:parseInt
(index); if(!divJSOutputPlus.buttons)return; if(index<0)index=0; if
(index>divJSOutputPlus.buttons.length)return; for
(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV
("hide"); setTimeout("collapseAll("+i+")"); }
function expandAll(index){ index=isNaN(parseInt(index))?0:parseInt
(index); if(!divJSOutputPlus.buttons)return; if(index<0)index=0; if
(index>divJSOutputPlus.buttons.length)return; for
(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV
("show"); setTimeout("expandAll("+i+")"); }
function core_analysis()
{ var str=" ", c="", lastState="", seq, intNextQuo
te, intTemp, intCount, intWordStart; spnProcess.innerHTML=parseFloat
(glbP/glbStr.length*100).toFixed(2)+"%
( "+glbP+" / "+glbStr.length+" )"; for
(var i=glbP;i<glbStr.length;i++){ c=glbStr.charAt(i); str+=htmlEncode
(c); switch(c)
{ case "\r": case " ": case "\t":
if(lastState=="\r\n"){str=" ";break;}
str=str.substring(0,str.length-htmlEncode(c).length); if
(lastState=="blank")break; if(c.match(/\W/)&&glbStr.charAt(i-1).match(/
\w/)){ str=str.replace(regKW,clKW).replace(regObj,clObj).replace
(regMP,clMP); } str+=htmlEncode
(c); lastState="blank"; break; &nb
sp;case ";": if(str.match(/\Wfor.*?\(/i))
break; // attention there's no break here &nbs
p;case "\n": if(lastState=="\r\n"){str=" ";break;}
outputLn
(str); str=" "; lastState="\r\n";&
#13; if(i-glbP>200)
{ glbP=i+1; glbTimer=setTimeout
(core_analysis); return; }
break; case "\"":  
;intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length)
{ intNextQuote=glbStr.indexOf
("\"",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote
-1)!="\\")
break; intCount=0; intTemp=intNextQuote; w
hile(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)
break; } if(intNextQuote==-1)
break; str+="<span class=\"quote\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\""; i=intNextQuote; lastSta
te=""; break; case "\'":
intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length)
{ intNextQuote=glbStr.indexOf
("\'",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!
="\\")
break; intCount=0; intTemp=intNextQuote; w
hile(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)
break; } if(intNextQuote==-1)
break; str+="<span class=\"quote\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\'"; i=intNextQuote; lastState=&q
uot;"; break; case "\/":  
; if(glbStr.charAt(i+1)=="\/")
{ intNextQuote=i; intNextQuote=glbStr.indexOf
("\r\n",intNextQuote+1); if(intNextQuote==-1)
intNextQuote=glbStr.length; str=str.substring(0,str.length-
1); str+="<span class=\"comments\">\/"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>"; i=intNextQuote; }
else if(glbStr.charAt(i+1)=="*")
{ intNextQuote=i; intNextQuote=glbStr.indexOf
("*\/",intNextQuote+1); if(intNextQuote==-1)
return; str=str.substring(0,str.length-
1); str+="<span class=\"comments\">\/"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"*\/<\/span>"; i=intNextQuote+1; }
else if(str.match(/[=(][ \t]*\//))
{ intNextQuote=i; while(intNextQuote!=-
1&&intNextQuote<glbStr.length){ intNextQuote=glbStr.indexOf
("\/",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt
(intNextQuote-1)!="\\")
break; intCount=0; intTemp=intNextQuote; &
nbsp; while(glbStr.charAt(--intTemp)=="\\")intCount++; if
(intCount%2==0)break; } if(intNextQuote==-1)
break; str+="<span class=\"regexp\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\/"; i=intNextQuote;
lastState=""; }
lastState=""; break; case&n
bsp;"{": outputLn
(str); str=" "; seq=document.createElement
("div"); seq.className="indent"; curRe.
appendChild
(seq); curRe=seq; lastState="\r\n"; &nbs
p; if(i-glbP>200)
{ glbP=i+1; glbTimer=setTimeout
(core_analysis); return; }
break; case "}
": outputLn(str.substring(0,str.length-
1)); str="}
"; lastState=""; curRe=curRe.parentNod
e; break; default: if(c.match(/\w/)
&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;} if(c.match(/\W/)
&&glbStr.charAt(i-1).match(/\w/)){ str=str.substring(0,str.length-htmlEncode
(c).length); str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)
+htmlEncode(c); }
lastState=""; break; }
} if(i==glbStr.length){ if(str!="")
{ outputLn(str); str=" "; } stopExec(); }
} function outputLn(theStr)
{ var seq, txt, fn; if(html2txt(theStr).match(/^[ \t\r\n]*$/))
return; seq=document.createElement
("p"); seq.innerHTML=theStr; curRe.appendChild
(seq); txt=html2txt(theStr); if(!txt)return; fn=txt.match
(/function[ \t\r\n]+([\.\w]+?)[ \t\r\n]*\(.*?\)[ \t\r\n]*\{/); if(fn)
{ glbFuntionNames.push(fn[1]); selJSExport.options[selJSExport.options.length]
=new Option(fn[0]+"}",fn[1]); selJSExport.options[selJSExport.options.length-
1].obj=seq; } fn=txt.match(/([\.\w]+?)[ \t\r\n]*=[ \t\r\n]*function\W*\(.*?\)
[ \t\r\n]*\{/); if(fn){ glbFuntionNames.push(fn
[1]); selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn
[1]); selJSExport.options[selJSExport.options.length-1].obj=seq; } }
function clKW(str){ return(str.charAt(0)
+"<span class=\"keyWord\">"+str.substring(1)+"</span>"); }
function clObj(str){ return(str.charAt(0)
+"<span class=\"object\">"+str.substring(1)+"</span>"); }
function clMP(str){ return(str.charAt(0)
+"<span class=\"method_property\">"+str.substring(1)+"</span>"); }
function clOP(str){ return(str.charAt(0)
+"<span class=\"operator\">"+str.substring(1)+"</span>"); }
//------------------ // global scripts //------------------
function maximizeWindow(){ window.moveTo(0,0); window.resizeTo
(screen.availWidth,screen.availHeight); } function htmlEncode(strS){ return
(strS.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace
(/>/g,"&gt;").replace(/ /g,"&nbsp;").replace(/
\r\n/g,"<br\/>")); } function html2txt(strS){ return
(strS.replace(/<.+?>/g,"").replace(/&lt;/g,"<").replace
(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/<br\/?>/g,"\r\n").replace
(/&amp;/g,"&")); }
</textarea>
<div id="divJSInputBar">
<input type="button" value="OK" onclick="execJSInput();" />
<input type="button" value="Cancel" onclick="hideJSInput();" />
</div>
</div>
<div id="divJSExport">
<div id="divJSExportTitle">Function List:</div>
<select id="selJSExport" multiple size="2" ></select>
<div id="divJSExportContent"></div>
<div id="divJSExportBar">
<input type="button" value="Calculate Dependentce" onclick="execJSExport_Dep();"/>
<input type="button" value="Export Selected Functions" onclick="execJSExport();"/>
<input type="button" value="Cancel" onclick="hideJSExport();" />
</div>
</div>
<div id="divMain">
<div id="divJSOutputLineNo"></div>
<div id="divJSOutputPlus"></div>
<div id="divJSOutput"></div>
</div>
<div id="divWaiting">
Processing...<span id="spnProcess"></span><br>
<input type="button" value="Stop" onclick="stopExec();" id="cmdStop"/>
</div>
</body>
</html>
自 Ver1.1 升級(jí)內(nèi)容
1. 增加函數(shù)列表
2. 增加函數(shù) Export 功能
3. 增加函數(shù)依存關(guān)系分析 (這個(gè)功能個(gè)人未見其他軟件實(shí)現(xiàn)過(guò),自己創(chuàng)意,問題多多,目前分析能力還是比較有限的,只能分析全局函數(shù)依存關(guān)系,可能在復(fù)雜代碼的情況下出現(xiàn) bug)
4. 修正 for 語(yǔ)句分析 bug
5. 修正 語(yǔ)法折疊的 bug
6. 改進(jìn) Collapse All ※ Expand All 函數(shù)工作方式,避免行數(shù)太大時(shí)的死機(jī)
7. 改進(jìn)行號(hào)分析機(jī)制,避免行數(shù)太大時(shí)的死機(jī)
復(fù)制代碼 代碼如下:
<html>
<head>
<title>JSer Ver 2.0</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<style>
/* Global CSS */
* { padding:0px; margin:0px; font-size:13px; font-family: arial 宋體; }
body { overflow:auto; border:0px none black; background-color:buttonface; }
li { margin:0px 0px 0px 40px; padding:2px 4px; }
div { font-size:13px; line-height:14px; }
p { font-size:13px; line-height:14px; }
/* Class CSS */
.codeRoot { line-height:14px; }
.quote { color:#999; }
.comments { color: #009090; }
.indent { margin-left:25px; }
.regexp { color:#F000F0; }
.keyWord { color:blue; }
.object { color:red; }
.method_property { color:#FF8000; }
.operator { color:#004000; }
.colsp { font-size:12px; width:14px; height:14px; overflow:hidden; border:1px outset buttonface; text-align:center;
cursor:pointer; padding-left:2px; }
.colsp2 { font-size:12px; width:14px; height:14px; overflow:hidden; border:1px inset buttonface; text-align:center;
cursor:pointer; padding-left:2px; color:red!important; background-color:#E0FFF8!important; }
/* Identified CSS */
#divTools { height:20px; border-bottom:1px solid #555; padding-left:15px; }
#divTools a { color:navy; text-decoration:none; height:20px; line-height:20px; padding:0px 25px; }
#divTools a:hover { color:white; background-color:navy; text-decoration:none; height:20px; line-height:20px; }
#divJSInput { display:none; width:600px; height:450px; border:2px outset buttonface; position:absolute; background-
color:buttonface; z-Index:2; }
#divJSInputTitle { color:white; background-color:navy; height:20px; line-height:20px; padding:0px 10px; cursor:default; }
#txtJSInput { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white;}
#divJSInputBar { height:24px; padding:0px 4px; }
#divJSInputBar input { width:110px; height:22px; border:1px solid #555; line-height:20px; }
#divMain { width:100%; height:500; overflow:hidden; position:relative; }
#divJSOutputLineNo { width:32px; height:100%; overflow:hidden; background-color:#DDD; position:absolute; left:0px; top:0px;
text-align:right; }
#divJSOutputLineNo p { font-size:12px; line-height:14px; }
#divJSOutputPlus { width:14px; height:100%; overflow:hidden; background-color:#EEE; position:absolute; left:32px; top:0px; z
-Index:2; }
#divJSOutputPlus p { font-size:12px; line-height:14px; }
#divJSOutput { background-color:white; border:1px inset buttonface; height:100%; position:absolute; left:45px; top:0px;
overflow:scroll; }
#divWaiting { display:none; width:400px; height:60px; border:1px solid buttonface; position:absolute; background-
color:#E0F0F0; z-Index:3; text-align:center; padding-top:10px; }
#divWaiting input { width:140px; height:22px; border:1px solid #555; line-height:20px; cursor:default; margin-top:4px; }
#divJSExport { display:none; width:600px; height:450px; border:2px outset buttonface; position:absolute; background-
color:buttonface; z-Index:2; }
#divJSExportTitle { color:white; background-color:navy; height:20px; line-height:20px; padding:0px 10px; cursor:default; }
#selJSExport { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white; }
#divJSExportContent { width:598px; height:406px; overflow:auto; padding:4px 8px; background-color:white; display:none; }
#divJSExportBar { height:24px; padding:0px 4px; }
#divJSExportBar input { width:170px; height:22px; border:1px solid #555; line-height:20px; }
</style>
<script type="text/javascript">
/**********************
Author: Hutia
*********************/
window.onload=init;
//------------------
// Static Variable
//------------------
var KEYWORDS="abstract break byte case catch char class const continue default delete do double else extends false final
finally float for function goto if implements import in instanceof int interface long native null package private protected
public reset return short static super switch synchronized this throw transient true try var void while with";
var OBJECTS="Anchor Applet Area Arguments Array Boolean Button Checkbox Collection Crypto Date Dictionary Document Drive
Drives Element Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders Form Frame Function Global Hidden
History HTMLElement Image Infinity Input JavaArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType
Navigator Number Object Option Packages Password Plugin PrivilegeManager Random RegExp Screen Select String Submit Text
Textarea URL VBArray Window WScript";
var METHODS_PROPERTIES="above abs acos action activeElement alert alinkColor all altKey anchor anchors appCodeName applets
apply appName appVersion arguments arity asin assign atan atan2 atob availHeight availLeft availTop availWidth ActiveXObject
back background below bgColor big blink blur bold border borderWidths bottom btoa button call callee caller cancelBubble
captureEvents ceil charAt charCodeAt charset checked children classes className clear clearInterval clearTimeout click
clientInformation clientX clientY close closed colorDepth compile complete concat confirm constructir contains contextual
cookie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected defaultStatus defaultValue description
disableExternalCapture disablePrivilege document domain E Echo element elements embeds enabledPlugin enableExternalCapture
enablePrivilege encoding escape eval event exec exp expando FromPoint fgColor fileName find fixed floor focus fontColor
fontSize form forms forward frames fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear getHours
getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot getTime getTimezoneOffset getUTCDate getUTCDay
getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent
Height hash hidden history home host hostName href hspace id ids ignoreCase images index indexOf inner innerHTML innerText
innerWidth insertAdjacentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode Links LN10 LN2 LOG10E
LOG2E lang language lastIndex lastIndexOf lastMatch lastModified lastParen layers layerX layerY left leftContext length link
linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins match max menubar method mimeTypes min modifiers
moveAbove moveBelow moveBy moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator netscape next
number offscreenBuffering offset offsetHeight offsetLeft offsetParent offsetTop offsetWidth offsetX offsetY onabort onblur
onchange onclick ondblclick ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmousedown onmousemove
onmouseout onmouseover onmouseup onmove onreset onresize onsubmit onunload open opener options outerHeight outerHTML
outerText outerWidth POSITIVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentElement parentLayer
parentWindow parse parseFloat parseInt pathname personalbar pixelDepth platform plugins pop port pow preference previous
print prompt protocol prototype push random readyState reason referrer refresh releaseEvents reload removeAttribute
removeMember replace resizeBy resizeTo returnValue reverse right rightcontext round SQRT1_2 SQRT2 screenX screenY scroll
scrollbars scrollBy scrollIntoView scrollTo search select selected selectedIndex self setAttribute setDay setFullYear
setHotkeys setHours setInterval setMember setMilliseconds setMinutes setMonth setResizable setSeconds setSlot setTime
setTimeout setUTCDate setUTCFullYear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear
setZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort source sourceIndex splice split sqrt src
srcElement srcFilter status statusbar stop strike style sub submit substr substring suffixes sun sup systemLanguage TYPE
tagName tags taint taintEnabled tan target test text title toElement toGMTString toLocaleString toLowerCase toolbar top
toString toUpperCase toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent userLanguage value valueOf
visibility vlinkColor vspace watch which width window write writeln x y zIndex";
var OPS="! $ % & * + - // / : < = > ? [ ] ^ | ~ is new sizeof typeof unchecked";
var regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)","g");
var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|(\\W")+"$)","g");
var regMP=new RegExp("(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)","g");
//var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")+"$)","g");
//------------------
// Global Variables
//------------------
var divJSInput, txtJSInput, divMain, divJSOutputLineNo, divJSOutputPlus, divJSOutput, divWaiting;
var spnProcess, cmdStop, divJSExport, selJSExport, divJSExportContent;
var glbStr, glbP, glbRe, curRe, glbTimer, glbBusy, glbFuntionNames;
function init(){
// init global variables
divJSInput=document.getElementById("divJSInput");
txtJSInput=document.getElementById("txtJSInput");
divMain=document.getElementById("divMain");
divJSOutputLineNo=document.getElementById("divJSOutputLineNo");
divJSOutputPlus=document.getElementById("divJSOutputPlus");
divJSOutput=document.getElementById("divJSOutput");
divWaiting=document.getElementById("divWaiting");
spnProcess=document.getElementById("spnProcess");
cmdStop=document.getElementById("cmdStop");
divJSExport=document.getElementById("divJSExport");
selJSExport=document.getElementById("selJSExport");
divJSExportContent=document.getElementById("divJSExportContent");
// init window state
maximizeWindow();
divMain.style.width=document.body.clientWidth-4;
divMain.style.height=document.body.clientHeight-26;
divJSOutput.style.width=document.body.clientWidth-72;
// init global events
divJSOutputLineNo.onselectstart=divJSOutputLineNo.onselect=divJSOutputPlus.onselectstart=divJSOutputPlus.onselect=cancelEvent
divJSOutput.onscroll=divJSOutput_onscroll;
divJSInput.onkeydown=divJSInput_keydown;
divJSExport.onkeydown=divJSExport_keydown;
}
//------------------
// event scripts
//------------------
function cancelEvents(e){
var e=window.event?window.event:e;
e.returnValue=false;
return(false);
}
function divJSInput_keydown(e){
var e=window.event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var sel;
if(e.keyCode==27)hideJSInput();
if(e.keyCode==13&&e.ctrlKey)execJSInput();
if(e.keyCode==9&&srcEle==txtJSInput){
document.selection.createRange().text="\t";return(false); // not support FF
}
}
function divJSExport_keydown(e){
var e=window.event?window.event:e;
var srcEle=e.srcElement?e.srcElement:e.target;
var sel;
if(e.keyCode==27)hideJSExport();
if(e.keyCode==13&&e.ctrlKey)hideJSExport();
}
function divJSOutput_onscroll(){
divJSOutputLineNo.scrollTop=divJSOutputPlus.scrollTop=divJSOutput.scrollTop;
}
//------------------
// functional scripts
//------------------
function showJSInput(){
if(glbBusy)return;
hideJSExport();
with(divJSInput.style){
display="block";
left=(document.body.clientWidth-divJSInput.offsetWidth)/2;
top=(document.body.clientHeight-divJSInput.offsetHeight)/2;
}
txtJSInput.focus();
return(false);
}
function showJSExport(){
if(glbBusy)return;
hideJSInput();
with(divJSExport.style){
display="block";
left=(document.body.clientWidth-divJSExport.offsetWidth)/2;
top=(document.body.clientHeight-divJSExport.offsetHeight)/2;
}
divJSExportContent.style.display="none";
selJSExport.style.display="block";
selJSExport.focus();
return(false);
}
function hideJSInput(){
divJSInput.style.display="none";
}
function hideJSExport(){
divJSExport.style.display="none";
}
function execJSInput(){
hideJSInput();
divJSOutput.innerHTML="";
divJSOutputLineNo.innerHTML="";
divJSOutputPlus.innerHTML="";
glbStr=txtJSInput.innerText; // not support FF
glbP=0;
glbFuntionNames=new Array();
curRe=glbRe=document.createElement("div");
divJSOutput.appendChild(glbRe);
glbRe.className="codeRoot";
while(selJSExport.options.length>0)selJSExport.options[0]=null;
showWait(startRecalcLine);
core_analysis();
}
function execJSExport(){
var fns=new Array(), fcs=new Array(), str;
for(var i=0; i<selJSExport.options.length; i++){
if(selJSExport.options[i].selected){
fns.push(selJSExport.options[i].value);
str=selJSExport.options[i].obj.outerHTML;
try{
str+=selJSExport.options[i].obj.nextSibling.outerHTML;
str+=selJSExport.options[i].obj.nextSibling.nextSibling.outerHTML;
}catch(e){}
fcs.push(str);
}
}
if(fns.length==0)return;
divJSExportContent.style.display="block";
selJSExport.style.display="none";
divJSExportContent.innerHTML=fcs.join("\r\n<br>\r\n");
}
function execJSExport_Dep(){
var fns=new Array(), fcs=new Array(), str, regFNs=new Array(), needDepthTest;
for(var i=0; i<selJSExport.options.length; i++){
if(selJSExport.options[i].selected){
fns.push(selJSExport.options[i].value);
try{
str=selJSExport.options[i].obj.nextSibling.outerHTML;
}catch(e){}
fcs.push(str);
}
}
if(fns.length==0)return;
divJSExportContent.style.display="none";
selJSExport.style.display="block";
needDepthTest=false;
for(var i=0;i<glbFuntionNames.length;i+=1){
if(!selJSExport.options[i].selected){
for(j=0;j<fcs.length;j++){
if(html2txt(fcs[j]).match(glbFuntionNames[i].replace(/\./g,"\\."))){
selJSExport.options[i].selected=true;
needDepthTest=true;
break;
}
}
}
}
if(needDepthTest)execJSExport_Dep();
}
function showWait(onstop){
glbBusy=true;
document.body.style.cursor="wait";
with(divWaiting.style){
display="block";
left=(document.body.clientWidth-divWaiting.offsetWidth)/2;
top=(document.body.clientHeight-divWaiting.offsetHeight)/2;
}
spnProcess.innerHTML="0.00% ( 0 / 0 )";
divWaiting.onstop=onstop;
cmdStop.focus();
return(false);
}
function hideWait(){
glbBusy=false;
document.body.style.cursor="";
divWaiting.style.display="none";
try{clearTimeout(glbTimer);}catch(e){}
try{divWaiting.onstop();}catch(e){}
return(false);
}
function stopExec(){ hideWait(); }
function startRecalcLine(){
var re="", re2="";
if(glbBusy)return;
glbBusy=true;
for(var i=0;i<parseInt(divJSOutput.scrollHeight/14+200);i++){
re+="<p>"+(i+1)+"</p>";
re2+="<p> </p>";
}
divJSOutputLineNo.innerHTML=re;
divJSOutputPlus.innerHTML=re2;
divJSOutputPlus.buttons=new Array();
glbP=0;
showWait();
recalcLine();
return(false);
}
function recalcLine(){
var objs, j;
objs=document.getElementsByTagName("div");
for(var i=glbP;i<objs.length&&(i-glbP<30);i++){
if(objs[i].className=="indent"){
j=parseInt(objs[i].offsetTop/14)-1;
divJSOutputPlus.childNodes[j].className="colsp";
divJSOutputPlus.childNodes[j].innerHTML="-";
divJSOutputPlus.childNodes[j].linkedDIV=objs[i];
divJSOutputPlus.childNodes[j].startIndex=j+1;
divJSOutputPlus.childNodes[j].endIndex=j+Math.round(objs[i].offsetHeight/14);
if(objs[i].innerHTML!="")divJSOutputPlus.childNodes[j].endIndex++;
divJSOutputPlus.childNodes[j].switchDIV=divJSOutputPlus.childNodes[j].onclick=switchDIV;
divJSOutputPlus.buttons.push(divJSOutputPlus.childNodes[j]);
}
}
spnProcess.innerHTML=parseFloat(glbP/objs.length*100).toFixed(2)+"% ( "+glbP+" / "+objs.length+" )";
if(i<objs.length){glbP=i; glbTimer=setTimeout(recalcLine); return;}
stopExec();
divJSOutput_onscroll();
}
function switchDIV(disp){
var y, obj;
if((this.className=="colsp"||disp=="hide")&&disp!="show"){
this.className="colsp2";
this.innerHTML="+";
for(var i=this.startIndex;i<this.endIndex;i++){
divJSOutputLineNo.childNodes[i].style.display="none";
divJSOutputPlus.childNodes[i].style.display="none";
}
this.linkedDIV.style.display="none";
}else{
this.className="colsp";
this.innerHTML="-";
this.linkedDIV.style.display="block";
for(var i=this.startIndex;i<this.endIndex;i++){
divJSOutputLineNo.childNodes[i].style.display="block";
divJSOutputPlus.childNodes[i].style.display="block";
if(divJSOutputPlus.childNodes[i].className=="colsp2"){
i=divJSOutputPlus.childNodes[i].endIndex-1;
}
}
}
divJSOutput_onscroll();
}
function collapseAll(index){
index=isNaN(parseInt(index))?0:parseInt(index);
if(!divJSOutputPlus.buttons)return;
if(index<0)index=0;
if(index>divJSOutputPlus.buttons.length)return;
for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("hide");
setTimeout("collapseAll("+i+")");
}
function expandAll(index){
index=isNaN(parseInt(index))?0:parseInt(index);
if(!divJSOutputPlus.buttons)return;
if(index<0)index=0;
if(index>divJSOutputPlus.buttons.length)return;
for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("show");
setTimeout("expandAll("+i+")");
}
function core_analysis(){
var str=" ", c="", lastState="", seq, intNextQuote, intTemp, intCount, intWordStart;
spnProcess.innerHTML=parseFloat(glbP/glbStr.length*100).toFixed(2)+"% ( "+glbP+" / "+glbStr.length+" )";
for(var i=glbP;i<glbStr.length;i++){
c=glbStr.charAt(i);
str+=htmlEncode(c);
switch(c){
case "\r": case " ": case "\t":
if(lastState=="\r\n"){str=" ";break;}
str=str.substring(0,str.length-htmlEncode(c).length);
if(lastState=="blank")break;
if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){
str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP);
}
str+=htmlEncode(c);
lastState="blank";
break;
case ";":
if(str.match(/\Wfor.*?\(/i))break;
// attention there's no break here
case "\n":
if(lastState=="\r\n"){str=" ";break;}
outputLn(str);
str=" ";
lastState="\r\n";
if(i-glbP>200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "\"":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\"",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\"";
i=intNextQuote;
lastState="";
break;
case "\'":
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\'",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\'";
i=intNextQuote;
lastState="";
break;
case "\/":
if(glbStr.charAt(i+1)=="\/"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("\r\n",intNextQuote+1);
if(intNextQuote==-1)intNextQuote=glbStr.length;
str=str.substring(0,str.length-1);
str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"<\/span>";
i=intNextQuote;
}else if(glbStr.charAt(i+1)=="*"){
intNextQuote=i;
intNextQuote=glbStr.indexOf("*\/",intNextQuote+1);
if(intNextQuote==-1)return;
str=str.substring(0,str.length-1);
str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"*\/<\/span>";
i=intNextQuote+1;
}else if(str.match(/[=(][ \t]*\//)){
intNextQuote=i;
while(intNextQuote!=-1&&intNextQuote<glbStr.length){
intNextQuote=glbStr.indexOf("\/",intNextQuote+1);
if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break;
intCount=0; intTemp=intNextQuote;
while(glbStr.charAt(--intTemp)=="\\")intCount++;
if(intCount%2==0)break;
}
if(intNextQuote==-1)break;
str+="<span class=\"regexp\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))
+"<\/span>\/";
i=intNextQuote;
lastState="";
}
lastState="";
break;
case "{":
outputLn(str);
str=" ";
seq=document.createElement("div");
seq.className="indent";
curRe.appendChild(seq);
curRe=seq;
lastState="\r\n";
if(i-glbP>200){
glbP=i+1;
glbTimer=setTimeout(core_analysis);
return;
}
break;
case "}":
outputLn(str.substring(0,str.length-1));
str="} ";
lastState="";
curRe=curRe.parentNode;
break;
default:
if(c.match(/\w/)&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;}
if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){
str=str.substring(0,str.length-htmlEncode(c).length);
str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)+htmlEncode(c);
}
lastState="";
break;
}
}
if(i==glbStr.length){
if(str!=""){ outputLn(str); str=" "; }
stopExec();
}
}
function outputLn(theStr){
var seq, txt, fn;
if(html2txt(theStr).match(/^[ \t\r\n]*$/))return;
seq=document.createElement("p");
seq.innerHTML=theStr;
curRe.appendChild(seq);
txt=html2txt(theStr);
if(!txt)return;
fn=txt.match(/function[ \t\r\n]+([\.\w]+?)[ \t\r\n]*\(.*?\)[ \t\r\n]*\{/);
if(fn){
glbFuntionNames.push(fn[1]);
selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]);
selJSExport.options[selJSExport.options.length-1].obj=seq;
}
fn=txt.match(/([\.\w]+?)[ \t\r\n]*=[ \t\r\n]*function\W*\(.*?\)[ \t\r\n]*\{/);
if(fn){
glbFuntionNames.push(fn[1]);
selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]);
selJSExport.options[selJSExport.options.length-1].obj=seq;
}
}
function clKW(str){ return(str.charAt(0)+"<span class=\"keyWord\">"+str.substring(1)+"</span>"); }
function clObj(str){ return(str.charAt(0)+"<span class=\"object\">"+str.substring(1)+"</span>"); }
function clMP(str){ return(str.charAt(0)+"<span class=\"method_property\">"+str.substring(1)+"</span>"); }
function clOP(str){ return(str.charAt(0)+"<span class=\"operator\">"+str.substring(1)+"</span>"); }
//------------------
// global scripts
//------------------
function maximizeWindow(){
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
}
function htmlEncode(strS){
return(strS.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/
\r\n/g,"<br\/>"));
}
function html2txt(strS){
return(strS.replace(/<.+?>/g,"").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/<br\/?
>/g,"\r\n").replace(/&/g,"&"));
}
</script>
</head>
<body>
<!-- Author: Hutia -->
<div id="divTools">
<a href="#" onclick="showJSInput();return(false);">Input JS</a>
<a href="#" onclick="collapseAll();return(false);">Collapse All</a>
<a href="#" onclick="expandAll();return(false);">Expand All</a>
<a href="#" onclick="showJSExport();return(false);">Export JS</a>
</div>
<div id="divJSInput">
<div id="divJSInputTitle">Please Input the JS:</div>
<textarea id="txtJSInput">
/********************** Author: Hutia *********************/
window.onload=init; //------------------ // Static Variable //-----
-------------
var KEYWORDS="abstract break byte case catch char class cons
t continue default delete do double else extends false final finally f
loat for function goto if implements import in instanceof int interface&nbs
p;long native null package private protected public reset return short stat
ic super switch synchronized this throw transient true try var void wh
ile with"; var OBJECTS="Anchor Applet Area Arguments Array Boolean 
;Button Checkbox Collection Crypto Date Dictionary Document Drive Drives Element
Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders For
m Frame Function Global Hidden History HTMLElement Image Infinity Input Jav
aArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType Naviga
tor Number Object Option Packages Password Plugin PrivilegeManager Random RegExp
Screen Select String Submit Text Textarea URL VBArray Window WScript"
; var METHODS_PROPERTIES="above abs acos action activeElement alert alinkCol
or all altKey anchor anchors appCodeName applets apply appName appVersion a
rguments arity asin assign atan atan2 atob availHeight availLeft availTop&
nbsp;availWidth ActiveXObject back background below bgColor big blink blur bold&
nbsp;border borderWidths bottom btoa button call callee caller cancelBubble capt
ureEvents ceil charAt charCodeAt charset checked children classes className clea
r clearInterval clearTimeout click clientInformation clientX clientY close clos
ed colorDepth compile complete concat confirm constructir contains contextual co
okie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected&nb
sp;defaultStatus defaultValue description disableExternalCapture disablePrivilege document doma
in E Echo element elements embeds enabledPlugin enableExternalCapture enablePri
vilege encoding escape eval event exec exp expando FromPoint fgColor fileNa
me find fixed floor focus fontColor fontSize form forms forward frames 
;fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear
getHours getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot&nbs
p;getTime getTimezoneOffset getUTCDate getUTCDay getUTCFullYear getUTCHours getUTCMillise
conds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent
Height hash hidden history home host hostName href hspace id id
s ignoreCase images index indexOf inner innerHTML innerText innerWidth insertAdj
acentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode&nbs
p;Links LN10 LN2 LOG10E LOG2E lang language lastIndex lastIndexOf lastMatc
h lastModified lastParen layers layerX layerY left leftContext length link
linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins 
;match max menubar method mimeTypes min modifiers moveAbove moveBelow moveBy&nbs
p;moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator 
;netscape next number offscreenBuffering offset offsetHeight offsetLeft offsetParent
offsetTop offsetWidth offsetX offsetY onabort onblur onchange onclick ondblclick 
;ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmoused
own onmousemove onmouseout onmouseover onmouseup onmove onreset onresize onsubmit&nbs
p;onunload open opener options outerHeight outerHTML outerText outerWidth POSIT
IVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentEleme
nt parentLayer parentWindow parse parseFloat parseInt pathname personalbar pixelDepth
platform plugins pop port pow preference previous print prompt proto
col prototype push random readyState reason referrer refresh releaseEvents reloa
d removeAttribute removeMember replace resizeBy resizeTo returnValue reverse right&nb
sp;rightcontext round SQRT1_2 SQRT2 screenX screenY scroll scrollbars scrollBy&
nbsp;scrollIntoView scrollTo search select selected selectedIndex self setAttribute s
etDay setFullYear setHotkeys setHours setInterval setMember setMilliseconds setMinut
es setMonth setResizable setSeconds setSlot setTime setTimeout setUTCDate setUTCFullY
ear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear se
tZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort
source sourceIndex splice split sqrt src srcElement srcFilter status statu
sbar stop strike style sub submit substr substring suffixes sun sup sy
stemLanguage TYPE tagName tags taint taintEnabled tan target test text&nbs
p;title toElement toGMTString toLocaleString toLowerCase toolbar top toString toUpper
Case toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent 
;userLanguage value valueOf visibility vlinkColor vspace watch which width 
;window write writeln x y zIndex"; var OPS="! $ %
& * + - // / : < = > ? [ ]
^ | ~ is new sizeof typeof unchecked"; var
regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)
","g"); var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|
(\\W")+"$)","g"); var regMP=new RegExp("
(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)
","g"); //var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")
+"$)","g"); //------------------ // Global Variables //--
----------------
var divJSInput, txtJSInput, divMain, divJSOutputLineNo, divJSOutputPlus, divJSOutput,
divWaiting; var spnProcess, cmdStop, divJSExport, selJSExport, divJSExportContent;
3; var glbStr, glbP, glbRe, curRe, glbTimer, glbBusy, glbFuntionNames; &
#10; function init()
{ // init global variables divJSInput=document.getElementById
("divJSInput"); txtJSInput=document.getElementById
("txtJSInput"); divMain=document.getElementById
("divMain"); divJSOutputLineNo=document.getElementById
("divJSOutputLineNo"); divJSOutputPlus=document.getElementById
("divJSOutputPlus"); divJSOutput=document.getElementById
("divJSOutput"); divWaiting=document.getElementById
("divWaiting"); spnProcess=document.getElementById
("spnProcess"); cmdStop=document.getElementById
("cmdStop"); divJSExport=document.getElementById
("divJSExport"); selJSExport=document.getElementById
("selJSExport"); divJSExportContent=document.getElementById
("divJSExportContent"); // init window state maximizeW
indow(); divMain.style.width=document.body.clientWidth-
4; divMain.style.height=document.body.clientHeight-
26; divJSOutput.style.width=document.body.clientWidth-
52; // init global events divJSOutputLineNo.onse
lectstart=divJSOutputLineNo.onselect=divJSOutputPlus.onselectstart=divJSOutputPlus.onselect=cancelEvents; divJ
SOutput.onscroll=divJSOutput_onscroll; divJSInput.onkeydown=divJSInput_keydown;  
;divJSExport.onkeydown=divJSExport_keydown; } //------------------
// event scripts //------------------ function cancelEvents(e)
{ var e=window.event?window.event:e; e.returnValue=false; return
(false); } function divJSInput_keydown(e){ var e=window.event?
window.event:e; var srcEle=e.srcElement?
e.srcElement:e.target; var sel; if(e.keyCode==27)hideJSInput(); if
(e.keyCode==13&&e.ctrlKey)execJSInput(); if(e.keyCode==9&&srcEle==txtJSInput)
{ document.selection.createRange().text="\t";return
(false); // not support FF } }
function divJSExport_keydown(e){ var e=window.event?
window.event:e; var srcEle=e.srcElement?
e.srcElement:e.target; var sel; if(e.keyCode==27)hideJSExport(); if
(e.keyCode==13&&e.ctrlKey)hideJSExport(); } function divJSOutput_onscroll()
{ divJSOutputLineNo.scrollTop=divJSOutputPlus.scrollTop=divJSOutput.scrollTop; }
//------------------ // functional scripts //-----------
------- function showJSInput(){ if(glbBusy)return; hideJSExport
(); with(divJSInput.style){ display="block"; left=
(document.body.clientWidth-divJSInput.offsetWidth)/2; top=(document.body.clientHeight-
divJSInput.offsetHeight)/2; } txtJSInput.focus
(); return(false); } function showJSExport()
{ if(glbBusy)return; hideJSInput(); with(divJSExport.style)
{ display="block"; left=(document.body.clientWidth-
divJSExport.offsetWidth)/2; top=(document.body.clientHeight-
divJSExport.offsetHeight)/2; }
divJSExportContent.style.display="none"; selJSExport.style.display="block"
; selJSExport.focus(); return(false); }
function hideJSInput(){ divJSInput.style.display="none"; }
function hideJSExport(){ divJSExport.style.display="none"; }
function execJSInput(){ hideJSInput
(); divJSOutput.innerHTML=""; divJSOutputLineNo.innerHTML=""
;; divJSOutputPlus.innerHTML=""; glbStr=txtJSInput.value; &n
bsp;glbP=0; glbFuntionNames=new Array(); curRe=glbRe=document.createElement
("div"); divJSOutput.appendChild
(glbRe); glbRe.className="codeRoot"; while
(selJSExport.options.length>0)selJSExport.options[0]=null; showWait
(startRecalcLine); core_analysis(); } function execJSExport()
{ var fns=new Array(), fcs=new Array(), str; for
(var i=0; i<selJSExport.options.length; i++){ if(selJSExport.options[i].selected)
{ fns.push(selJSExport.options[i].value); str=selJSExport.options
[i].obj.outerHTML; try{ str+=selJSExport.options
[i].obj.nextSibling.outerHTML; str+=selJSExport.options
[i].obj.nextSibling.nextSibling.outerHTML; }catch(e){} fcs.push
(str); } } if(fns.length==0)
return; divJSExportContent.style.display="block"; selJSExport.style.d
isplay="none"; divJSExportContent.innerHTML=fcs.join
("\r\n<br>\r\n"); } function execJSExport_Dep()
{ var fns=new Array(), fcs=new Array(), str, regFNs=new Array
(), needDepthTest; for(var i=0; i<selJSExport.options.length; i++)
{ if(selJSExport.options[i].selected){ fns.push(selJSExport.options
[i].value); try{ str=selJSExport.options
[i].obj.nextSibling.outerHTML; }catch(e){} fcs.push
(str); } } if(fns.length==0)
return; divJSExportContent.style.display="none"; selJSExport.style.di
splay="block"; needDepthTest=false; for
(var i=0;i<glbFuntionNames.length;i+=1){ if(!selJSExport.options[i].selected)
{ for(j=0;j<fcs.length;j++){ if(html2txt(fcs[j]).match
(glbFuntionNames[i].replace(/\./g,"\\."))){ selJSExport.options
[i].selected=true; needDepthTest=true; break;&#
13; } } } } if
(needDepthTest)execJSExport_Dep(); } function showWait(onstop)
{ glbBusy=true; document.body.style.cursor="wait"; wit
h(divWaiting.style){ display="block"; left=(document.body.clientWidth-
divWaiting.offsetWidth)/2; top=(document.body.clientHeight-divWaiting.offsetHeight)/2; }
spnProcess.innerHTML="0.00% ( 0 / 0 )
"; divWaiting.onstop=onstop; cmdStop.focus(); return(false); }
function hideWait()
{ glbBusy=false; document.body.style.cursor=""; divWaiting.style.displ
ay="none"; try{clearTimeout(glbTimer);}catch(e){} try{divWaiting.onstop();}catch(e)
{} return(false); } function stopExec(){ hideWait(); }
function startRecalcLine()
{ var re="", re2=""; if(glbBusy)
return; glbBusy=true; for(var i=0;i<parseInt
(divJSOutput.scrollHeight/14+200);i++){ re+="<p>"+(i+1)
+"</p>"; re2+="<p>&nbsp;</p>"; }
divJSOutputLineNo.innerHTML=re; divJSOutputPlus.innerHTML=re2;
divJSOutputPlus.buttons=new Array(); glbP=0; showWait
(); recalcLine(); return(false); }
function recalcLine()
{ var objs, j; objs=document.getElementsByTagName
("div"); for(var i=glbP;i<objs.length&&(i-glbP<30);i++){ if
(objs[i].className=="indent"){ j=parseInt(objs[i].offsetTop/14)-
1; divJSOutputPlus.childNodes
[j].className="colsp"; divJSOutputPlus.childNodes[j].innerHTML="-
"; divJSOutputPlus.childNodes[j].linkedDIV=objs
[i]; divJSOutputPlus.childNodes
[j].startIndex=j+1; divJSOutputPlus.childNodes[j].endIndex=j+Math.round(objs[i].offsetHeight/14)
+1; divJSOutputPlus.childNodes[j].switchDIV=divJSOutputPlus.childNodes
[j].onclick=switchDIV; divJSOutputPlus.buttons.push(divJSOutputPlus.childNodes
[j]); } } spnProcess.innerHTML=parseFloat(glbP/objs.length*100).toFixed
(2)+"% ( "+glbP+" / "+objs.length+" )"; if
(i<objs.length){glbP=i; glbTimer=setTimeout(recalcLine); return;} stopExec
(); divJSOutput_onscroll(); } function switchDIV(disp)
{ var y, obj; if((this.className=="colsp"||disp=="hide")
&&disp!="show")
{ this.className="colsp2"; this.innerHTML="+"; &
nbsp;for(var i=this.startIndex;i<this.endIndex;i++){ divJSOutputLineNo.childNodes
[i].style.display="none"; divJSOutputPlus.childNodes
[i].style.display="none"; }
this.linkedDIV.style.display="none"; }else
{ this.className="colsp"; this.innerHTML="-
"; this.linkedDIV.style.display="block"; for
(var i=this.startIndex;i<this.endIndex;i++){ divJSOutputLineNo.childNodes
[i].style.display="block"; divJSOutputPlus.childNodes
[i].style.display="block"; if(divJSOutputPlus.childNodes
[i].className=="colsp2"){ i=divJSOutputPlus.childNodes[i].endIndex-
1; } } } divJSOutput_onscroll(); }
function collapseAll(index){ index=isNaN(parseInt(index))?0:parseInt
(index); if(!divJSOutputPlus.buttons)return; if(index<0)index=0; if
(index>divJSOutputPlus.buttons.length)return; for
(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV
("hide"); setTimeout("collapseAll("+i+")"); }
function expandAll(index){ index=isNaN(parseInt(index))?0:parseInt
(index); if(!divJSOutputPlus.buttons)return; if(index<0)index=0; if
(index>divJSOutputPlus.buttons.length)return; for
(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV
("show"); setTimeout("expandAll("+i+")"); }
function core_analysis()
{ var str=" ", c="", lastState="", seq, intNextQuo
te, intTemp, intCount, intWordStart; spnProcess.innerHTML=parseFloat
(glbP/glbStr.length*100).toFixed(2)+"%
( "+glbP+" / "+glbStr.length+" )"; for
(var i=glbP;i<glbStr.length;i++){ c=glbStr.charAt(i); str+=htmlEncode
(c); switch(c)
{ case "\r": case " ": case "\t":
if(lastState=="\r\n"){str=" ";break;}
str=str.substring(0,str.length-htmlEncode(c).length); if
(lastState=="blank")break; if(c.match(/\W/)&&glbStr.charAt(i-1).match(/
\w/)){ str=str.replace(regKW,clKW).replace(regObj,clObj).replace
(regMP,clMP); } str+=htmlEncode
(c); lastState="blank"; break; &nb
sp;case ";": if(str.match(/\Wfor.*?\(/i))
break; // attention there's no break here &nbs
p;case "\n": if(lastState=="\r\n"){str=" ";break;}
outputLn
(str); str=" "; lastState="\r\n";&
#13; if(i-glbP>200)
{ glbP=i+1; glbTimer=setTimeout
(core_analysis); return; }
break; case "\"":  
;intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length)
{ intNextQuote=glbStr.indexOf
("\"",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote
-1)!="\\")
break; intCount=0; intTemp=intNextQuote; w
hile(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)
break; } if(intNextQuote==-1)
break; str+="<span class=\"quote\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\""; i=intNextQuote; lastSta
te=""; break; case "\'":
intNextQuote=i; while(intNextQuote!=-1&&intNextQuote<glbStr.length)
{ intNextQuote=glbStr.indexOf
("\'",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!
="\\")
break; intCount=0; intTemp=intNextQuote; w
hile(glbStr.charAt(--intTemp)=="\\")intCount++; if(intCount%2==0)
break; } if(intNextQuote==-1)
break; str+="<span class=\"quote\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\'"; i=intNextQuote; lastState=&q
uot;"; break; case "\/":  
; if(glbStr.charAt(i+1)=="\/")
{ intNextQuote=i; intNextQuote=glbStr.indexOf
("\r\n",intNextQuote+1); if(intNextQuote==-1)
intNextQuote=glbStr.length; str=str.substring(0,str.length-
1); str+="<span class=\"comments\">\/"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>"; i=intNextQuote; }
else if(glbStr.charAt(i+1)=="*")
{ intNextQuote=i; intNextQuote=glbStr.indexOf
("*\/",intNextQuote+1); if(intNextQuote==-1)
return; str=str.substring(0,str.length-
1); str+="<span class=\"comments\">\/"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"*\/<\/span>"; i=intNextQuote+1; }
else if(str.match(/[=(][ \t]*\//))
{ intNextQuote=i; while(intNextQuote!=-
1&&intNextQuote<glbStr.length){ intNextQuote=glbStr.indexOf
("\/",intNextQuote+1); if(intNextQuote==-1||glbStr.charAt
(intNextQuote-1)!="\\")
break; intCount=0; intTemp=intNextQuote; &
nbsp; while(glbStr.charAt(--intTemp)=="\\")intCount++; if
(intCount%2==0)break; } if(intNextQuote==-1)
break; str+="<span class=\"regexp\">"+htmlEncode
(glbStr.substring(i+1,intNextQuote))
+"<\/span>\/"; i=intNextQuote;
lastState=""; }
lastState=""; break; case&n
bsp;"{": outputLn
(str); str=" "; seq=document.createElement
("div"); seq.className="indent"; curRe.
appendChild
(seq); curRe=seq; lastState="\r\n"; &nbs
p; if(i-glbP>200)
{ glbP=i+1; glbTimer=setTimeout
(core_analysis); return; }
break; case "}
": outputLn(str.substring(0,str.length-
1)); str="}
"; lastState=""; curRe=curRe.parentNod
e; break; default: if(c.match(/\w/)
&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;} if(c.match(/\W/)
&&glbStr.charAt(i-1).match(/\w/)){ str=str.substring(0,str.length-htmlEncode
(c).length); str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)
+htmlEncode(c); }
lastState=""; break; }
} if(i==glbStr.length){ if(str!="")
{ outputLn(str); str=" "; } stopExec(); }
} function outputLn(theStr)
{ var seq, txt, fn; if(html2txt(theStr).match(/^[ \t\r\n]*$/))
return; seq=document.createElement
("p"); seq.innerHTML=theStr; curRe.appendChild
(seq); txt=html2txt(theStr); if(!txt)return; fn=txt.match
(/function[ \t\r\n]+([\.\w]+?)[ \t\r\n]*\(.*?\)[ \t\r\n]*\{/); if(fn)
{ glbFuntionNames.push(fn[1]); selJSExport.options[selJSExport.options.length]
=new Option(fn[0]+"}",fn[1]); selJSExport.options[selJSExport.options.length-
1].obj=seq; } fn=txt.match(/([\.\w]+?)[ \t\r\n]*=[ \t\r\n]*function\W*\(.*?\)
[ \t\r\n]*\{/); if(fn){ glbFuntionNames.push(fn
[1]); selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn
[1]); selJSExport.options[selJSExport.options.length-1].obj=seq; } }
function clKW(str){ return(str.charAt(0)
+"<span class=\"keyWord\">"+str.substring(1)+"</span>"); }
function clObj(str){ return(str.charAt(0)
+"<span class=\"object\">"+str.substring(1)+"</span>"); }
function clMP(str){ return(str.charAt(0)
+"<span class=\"method_property\">"+str.substring(1)+"</span>"); }
function clOP(str){ return(str.charAt(0)
+"<span class=\"operator\">"+str.substring(1)+"</span>"); }
//------------------ // global scripts //------------------
function maximizeWindow(){ window.moveTo(0,0); window.resizeTo
(screen.availWidth,screen.availHeight); } function htmlEncode(strS){ return
(strS.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace
(/>/g,"&gt;").replace(/ /g,"&nbsp;").replace(/
\r\n/g,"<br\/>")); } function html2txt(strS){ return
(strS.replace(/<.+?>/g,"").replace(/&lt;/g,"<").replace
(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/<br\/?>/g,"\r\n").replace
(/&amp;/g,"&")); }
</textarea>
<div id="divJSInputBar">
<input type="button" value="OK" onclick="execJSInput();" />
<input type="button" value="Cancel" onclick="hideJSInput();" />
</div>
</div>
<div id="divJSExport">
<div id="divJSExportTitle">Function List:</div>
<select id="selJSExport" multiple size="2" ></select>
<div id="divJSExportContent"></div>
<div id="divJSExportBar">
<input type="button" value="Calculate Dependentce" onclick="execJSExport_Dep();"/>
<input type="button" value="Export Selected Functions" onclick="execJSExport();"/>
<input type="button" value="Cancel" onclick="hideJSExport();" />
</div>
</div>
<div id="divMain">
<div id="divJSOutputLineNo"></div>
<div id="divJSOutputPlus"></div>
<div id="divJSOutput"></div>
</div>
<div id="divWaiting">
Processing...<span id="spnProcess"></span><br>
<input type="button" value="Stop" onclick="stopExec();" id="cmdStop"/>
</div>
</body>
</html>
相關(guān)文章
js在瀏覽器中的event loop事件隊(duì)列示例詳解
大家都知道js是單線程的腳本語(yǔ)言,在同一時(shí)間只能做同一件事,為了協(xié)調(diào)事件、用戶交互、腳本、UI渲染和網(wǎng)絡(luò)處理等行為,防止主線程阻塞,Event Loop方案應(yīng)運(yùn)而生,這篇文章主要給大家介紹了關(guān)于js在瀏覽器中的event loop事件隊(duì)列的相關(guān)資料,需要的朋友可以參考下2021-11-11web開發(fā)js字符串拼接占位符及conlose對(duì)象Api詳解
本篇文章主要為大家介紹了web開發(fā)中字符串的拼接,占位符的使用以及conlose對(duì)象Api的使用,有需要的朋友可以借鑒參考下,希望可以有所幫助2021-09-09IE與FF下javascript獲取網(wǎng)頁(yè)及窗口大小的區(qū)別詳解
本篇文章主要是對(duì)IE與FF下javascript獲取網(wǎng)頁(yè)及窗口大小的區(qū)別進(jìn)行了詳細(xì)的介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-01-01JavaScript高級(jí)編程之Array的用法總結(jié)
這篇文章主要為大家介紹了JavaScript中Array常見用法的總結(jié),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2022-11-11BootStrap響應(yīng)式導(dǎo)航條實(shí)例介紹
響應(yīng)式導(dǎo)航條就是可以在不同的設(shè)備下查看不同的效果。這篇文章主要介紹了BootStrap響應(yīng)式導(dǎo)航條實(shí)例介紹的相關(guān)資料,小編認(rèn)為本文介紹的非常的不錯(cuò),特此分享給大家,供大家參考2016-05-05JavaScript 語(yǔ)句之常用 for 循環(huán)詳解
這篇文章主要介紹了JavaScript 語(yǔ)句之常用 for 循環(huán),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03js采用map取到id集合組并且實(shí)現(xiàn)點(diǎn)擊一行選中一行
本文為大家介紹下如何使用js采用map取到id集合組,并且點(diǎn)擊一行選中一行2013-12-12