搜尋
首頁web前端js教程JS代码格式化和语法着色V2_javascript技巧

升级到第二版,开一贴以示庆贺,哈哈哈

自 Ver1.1 升级内容
1. 增加函数列表
2. 增加函数 Export 功能
3. 增加函数依存关系分析 (这个功能个人未见其他软件实现过,自己创意,问题多多,目前分析能力还是比较有限的,只能分析全局函数依存关系,可能在复杂代码的情况下出现 bug)
4. 修正 for 语句分析 bug
5. 修正 语法折叠的 bug
6. 改进 Collapse All ※ Expand All 函数工作方式,避免行数太大时的死机
7. 改进行号分析机制,避免行数太大时的死机

复制代码 代码如下:



JSer Ver 2.0


<script> <BR>/********************** <BR> Author: Hutia <br><br>*********************/ <br><br>window.onload=init; <br><br><BR>//------------------ <BR>// Static Variable <BR>//------------------ <br><br>var KEYWORDS="abstract break byte case catch char class const continue default delete do double else extends false final <BR>finally float for function goto if implements import in instanceof int interface long native null package private protected <BR>public reset return short static super switch synchronized this throw transient true try var void while with"; <BR>var OBJECTS="Anchor Applet Area Arguments Array Boolean Button Checkbox Collection Crypto Date Dictionary Document Drive <BR>Drives Element Enumerator Event File FileObject FileSystemObject FileUpload Folder Folders Form Frame Function Global Hidden <BR>History HTMLElement Image Infinity Input JavaArray JavaClass JavaObject JavaPackage JSObject Layer Link Math MimeType <BR>Navigator Number Object Option Packages Password Plugin PrivilegeManager Random RegExp Screen Select String Submit Text <BR>Textarea URL VBArray Window WScript"; <BR>var METHODS_PROPERTIES="above abs acos action activeElement alert alinkColor all altKey anchor anchors appCodeName applets <BR>apply appName appVersion arguments arity asin assign atan atan2 atob availHeight availLeft availTop availWidth ActiveXObject <BR>back background below bgColor big blink blur bold border borderWidths bottom btoa button call callee caller cancelBubble <BR>captureEvents ceil charAt charCodeAt charset checked children classes className clear clearInterval clearTimeout click <BR>clientInformation clientX clientY close closed colorDepth compile complete concat confirm constructir contains contextual <BR>cookie cos crypto ctrlKey current data defaultCharset defaultChecked defaultSelected defaultStatus defaultValue description <BR>disableExternalCapture disablePrivilege document domain E Echo element elements embeds enabledPlugin enableExternalCapture <BR>enablePrivilege encoding escape eval event exec exp expando FromPoint fgColor fileName find fixed floor focus fontColor <BR>fontSize form forms forward frames fromCharCode fromElement getAttribute get getClass getDate getDay getFullYear getHours <BR>getMember getMilliseconds getMinutes getMonth getSeconds getSelection getSlot getTime getTimezoneOffset getUTCDate getUTCDay <BR>getUTCFullYear getUTCHours getUTCMilliseconds getUTCMinutes getUTCMonth getUTCSeconds getWindow getYear global go HandleEvent <BR>Height hash hidden history home host hostName href hspace id ids ignoreCase images index indexOf inner innerHTML innerText <BR>innerWidth insertAdjacentHTML insertAdjacentText isFinite isNAN italics java javaEnabled join keyCode Links LN10 LN2 LOG10E <BR>LOG2E lang language lastIndex lastIndexOf lastMatch lastModified lastParen layers layerX layerY left leftContext length link <BR>linkColor load location locationBar log lowsrc MAX_VALUE MIN_VALUE margins match max menubar method mimeTypes min modifiers <BR>moveAbove moveBelow moveBy moveTo moveToAbsolute multiline NaN NEGATIVE_INFINITY name navigate navigator netscape next <BR>number offscreenBuffering offset offsetHeight offsetLeft offsetParent offsetTop offsetWidth offsetX offsetY onabort onblur <BR>onchange onclick ondblclick ondragdrop onerror onfocus onHelp onkeydown onkeypress onkeyup onload onmousedown onmousemove <BR>onmouseout onmouseover onmouseup onmove onreset onresize onsubmit onunload open opener options outerHeight outerHTML <BR>outerText outerWidth POSITIVE_INFINITY PI paddings pageX pageXOffset pageY pageYOffset parent parentElement parentLayer <BR>parentWindow parse parseFloat parseInt pathname personalbar pixelDepth platform plugins pop port pow preference previous <BR>print prompt protocol prototype push random readyState reason referrer refresh releaseEvents reload removeAttribute <BR>removeMember replace resizeBy resizeTo returnValue reverse right rightcontext round SQRT1_2 SQRT2 screenX screenY scroll <BR>scrollbars scrollBy scrollIntoView scrollTo search select selected selectedIndex self setAttribute setDay setFullYear <BR>setHotkeys setHours setInterval setMember setMilliseconds setMinutes setMonth setResizable setSeconds setSlot setTime <BR>setTimeout setUTCDate setUTCFullYear setUTCHours setUTCMillseconds setUTCMinutes setUTCMonth setUTCSeconds setYear <BR>setZOptions shift shiftKey siblingAbove siblingBelow signText sin slice smallsort source sourceIndex splice split sqrt src <BR>srcElement srcFilter status statusbar stop strike style sub submit substr substring suffixes sun sup systemLanguage TYPE <BR>tagName tags taint taintEnabled tan target test text title toElement toGMTString toLocaleString toLowerCase toolbar top <BR>toString toUpperCase toUTCString type typeOf UTC unescape unshift untaint unwatch userAgent userLanguage value valueOf <BR>visibility vlinkColor vspace watch which width window write writeln x y zIndex"; <BR>var OPS="! $ % & * + - // / : < = > ? [ ] ^ | ~ is new sizeof typeof unchecked"; <br><br>var regKW=new RegExp("(\\W"+KEYWORDS.replace(/ /g,"$)|(\\W")+"$)","g"); <BR>var regObj=new RegExp("(\\W"+OBJECTS.replace(/ /g,"$)|(\\W")+"$)","g"); <BR>var regMP=new RegExp("(\\W"+METHODS_PROPERTIES.replace(/ /g,"$)|(\\W")+"$)","g"); <BR>//var regOP=new RegExp("(\\W"+OPS.replace(/ /g,"$)|(\\W")+"$)","g"); <br><br>//------------------ <BR>// Global Variables <BR>//------------------ <BR>var divJSInput, txtJSInput, divMain, divJSOutputLineNo, divJSOutputPlus, divJSOutput, divWaiting; <BR>var spnProcess, cmdStop, divJSExport, selJSExport, divJSExportContent; <BR>var glbStr, glbP, glbRe, curRe, glbTimer, glbBusy, glbFuntionNames; <br><br><BR>function init(){ <BR> // init global variables <BR> divJSInput=document.getElementById("divJSInput"); <BR> txtJSInput=document.getElementById("txtJSInput"); <BR> divMain=document.getElementById("divMain"); <BR> divJSOutputLineNo=document.getElementById("divJSOutputLineNo"); <BR> divJSOutputPlus=document.getElementById("divJSOutputPlus"); <BR> divJSOutput=document.getElementById("divJSOutput"); <BR> divWaiting=document.getElementById("divWaiting"); <BR> spnProcess=document.getElementById("spnProcess"); <BR> cmdStop=document.getElementById("cmdStop"); <BR> divJSExport=document.getElementById("divJSExport"); <BR> selJSExport=document.getElementById("selJSExport"); <BR> divJSExportContent=document.getElementById("divJSExportContent"); <br><br> // init window state <BR> maximizeWindow(); <br><br> divMain.style.width=document.body.clientWidth-4; <BR> divMain.style.height=document.body.clientHeight-26; <br><br> divJSOutput.style.width=document.body.clientWidth-72; <br><br> <BR> // init global events <br><br>divJSOutputLineNo.onselectstart=divJSOutputLineNo.onselect=divJSOutputPlus.onselectstart=divJSOutputPlus.onselect=cancelEvent <br><br> divJSOutput.onscroll=divJSOutput_onscroll; <br><br> divJSInput.onkeydown=divJSInput_keydown; <BR> divJSExport.onkeydown=divJSExport_keydown; <br><br>} <br><br><BR>//------------------ <BR>// event scripts <BR>//------------------ <br><br>function cancelEvents(e){ <BR> var e=window.event?window.event:e; <BR> e.returnValue=false; <BR> return(false); <BR>} <br><br>function divJSInput_keydown(e){ <BR> var e=window.event?window.event:e; <BR> var srcEle=e.srcElement?e.srcElement:e.target; <BR> var sel; <BR> if(e.keyCode==27)hideJSInput(); <BR> if(e.keyCode==13&&e.ctrlKey)execJSInput(); <BR> if(e.keyCode==9&&srcEle==txtJSInput){ <BR> document.selection.createRange().text="\t";return(false); // not support FF <BR> } <BR>} <br><br>function divJSExport_keydown(e){ <BR> var e=window.event?window.event:e; <BR> var srcEle=e.srcElement?e.srcElement:e.target; <BR> var sel; <BR> if(e.keyCode==27)hideJSExport(); <BR> if(e.keyCode==13&&e.ctrlKey)hideJSExport(); <BR>} <br><br>function divJSOutput_onscroll(){ <BR> divJSOutputLineNo.scrollTop=divJSOutputPlus.scrollTop=divJSOutput.scrollTop; <BR>} <br><br><br><br>//------------------ <BR>// functional scripts <BR>//------------------ <br><br>function showJSInput(){ <BR> if(glbBusy)return; <BR> hideJSExport(); <BR> with(divJSInput.style){ <BR> display="block"; <BR> left=(document.body.clientWidth-divJSInput.offsetWidth)/2; <BR> top=(document.body.clientHeight-divJSInput.offsetHeight)/2; <BR> } <br><br> txtJSInput.focus(); <br><br> return(false); <BR>} <br><br>function showJSExport(){ <BR> if(glbBusy)return; <BR> hideJSInput(); <BR> with(divJSExport.style){ <BR> display="block"; <BR> left=(document.body.clientWidth-divJSExport.offsetWidth)/2; <BR> top=(document.body.clientHeight-divJSExport.offsetHeight)/2; <BR> } <BR> divJSExportContent.style.display="none"; <BR> selJSExport.style.display="block"; <br><br> selJSExport.focus(); <BR> return(false); <BR>} <br><br>function hideJSInput(){ <BR> divJSInput.style.display="none"; <BR>} <br><br>function hideJSExport(){ <BR> divJSExport.style.display="none"; <BR>} <br><br>function execJSInput(){ <BR> hideJSInput(); <br><br> divJSOutput.innerHTML=""; <BR> divJSOutputLineNo.innerHTML=""; <BR> divJSOutputPlus.innerHTML=""; <br><br> glbStr=txtJSInput.innerText; // not support FF <BR> glbP=0; <BR> glbFuntionNames=new Array(); <BR> curRe=glbRe=document.createElement("div"); <br><br> divJSOutput.appendChild(glbRe); <BR> glbRe.className="codeRoot"; <br><br> while(selJSExport.options.length>0)selJSExport.options[0]=null; <br><br> showWait(startRecalcLine); <BR> core_analysis(); <BR>} <br><br>function execJSExport(){ <BR> var fns=new Array(), fcs=new Array(), str; <br><br> for(var i=0; i<selJSExport.options.length; i++){ <BR> if(selJSExport.options[i].selected){ <BR> fns.push(selJSExport.options[i].value); <BR> str=selJSExport.options[i].obj.outerHTML; <BR> try{ <BR> str+=selJSExport.options[i].obj.nextSibling.outerHTML; <BR> str+=selJSExport.options[i].obj.nextSibling.nextSibling.outerHTML; <BR> }catch(e){} <BR> fcs.push(str); <BR> } <BR> } <BR> if(fns.length==0)return; <br><br> divJSExportContent.style.display="block"; <BR> selJSExport.style.display="none"; <br><br> divJSExportContent.innerHTML=fcs.join("\r\n<br>\r\n"); <BR>} <br><br>function execJSExport_Dep(){ <BR> var fns=new Array(), fcs=new Array(), str, regFNs=new Array(), needDepthTest; <br><br> for(var i=0; i<selJSExport.options.length; i++){ <BR> if(selJSExport.options[i].selected){ <BR> fns.push(selJSExport.options[i].value); <BR> try{ <BR> str=selJSExport.options[i].obj.nextSibling.outerHTML; <BR> }catch(e){} <BR> fcs.push(str); <BR> } <BR> } <BR> if(fns.length==0)return; <br><br> divJSExportContent.style.display="none"; <BR> selJSExport.style.display="block"; <br><br> needDepthTest=false; <BR> for(var i=0;i<glbFuntionNames.length;i+=1){ <BR> if(!selJSExport.options[i].selected){ <BR> for(j=0;j<fcs.length;j++){ <BR> if(html2txt(fcs[j]).match(glbFuntionNames[i].replace(/\./g,"\\."))){ <BR> selJSExport.options[i].selected=true; <BR> needDepthTest=true; <BR> break; <BR> } <BR> } <BR> } <BR> } <BR> if(needDepthTest)execJSExport_Dep(); <BR>} <br><br><BR>function showWait(onstop){ <BR> glbBusy=true; <BR> document.body.style.cursor="wait"; <br><br> with(divWaiting.style){ <BR> display="block"; <BR> left=(document.body.clientWidth-divWaiting.offsetWidth)/2; <BR> top=(document.body.clientHeight-divWaiting.offsetHeight)/2; <BR> } <BR> spnProcess.innerHTML="0.00% ( 0 / 0 )"; <BR> divWaiting.onstop=onstop; <BR> cmdStop.focus(); <BR> return(false); <BR>} <br><br>function hideWait(){ <BR> glbBusy=false; <BR> document.body.style.cursor=""; <BR> divWaiting.style.display="none"; <BR> try{clearTimeout(glbTimer);}catch(e){} <BR> try{divWaiting.onstop();}catch(e){} <BR> return(false); <BR>} <br><br>function stopExec(){ hideWait(); } <br><br>function startRecalcLine(){ <BR> var re="", re2=""; <BR> if(glbBusy)return; <BR> glbBusy=true; <br><br> for(var i=0;i<parseInt(divJSOutput.scrollHeight/14+200);i++){ <BR> re+="<p>"+(i+1)+""; <BR> re2+="<p> "; <BR> } <br><br> divJSOutputLineNo.innerHTML=re; <BR> divJSOutputPlus.innerHTML=re2; <BR> divJSOutputPlus.buttons=new Array(); <br><br> glbP=0; <br><br> showWait(); <BR> recalcLine(); <BR> return(false); <br><br>} <br><br><BR>function recalcLine(){ <BR> var objs, j; <br><br> objs=document.getElementsByTagName("div"); <BR> for(var i=glbP;i<objs.length&&(i-glbP<30);i++){ <BR> if(objs[i].className=="indent"){ <BR> j=parseInt(objs[i].offsetTop/14)-1; <BR> divJSOutputPlus.childNodes[j].className="colsp"; <BR> divJSOutputPlus.childNodes[j].innerHTML="-"; <BR> divJSOutputPlus.childNodes[j].linkedDIV=objs[i]; <BR> divJSOutputPlus.childNodes[j].startIndex=j+1; <BR> divJSOutputPlus.childNodes[j].endIndex=j+Math.round(objs[i].offsetHeight/14); <BR> if(objs[i].innerHTML!="")divJSOutputPlus.childNodes[j].endIndex++; <BR> divJSOutputPlus.childNodes[j].switchDIV=divJSOutputPlus.childNodes[j].onclick=switchDIV; <BR> divJSOutputPlus.buttons.push(divJSOutputPlus.childNodes[j]); <BR> } <BR> } <BR> spnProcess.innerHTML=parseFloat(glbP/objs.length*100).toFixed(2)+"% ( "+glbP+" / "+objs.length+" )"; <BR> if(i<objs.length){glbP=i; glbTimer=setTimeout(recalcLine); return;} <BR> stopExec(); <BR> divJSOutput_onscroll(); <BR>} <br><br>function switchDIV(disp){ <BR> var y, obj; <BR> if((this.className=="colsp"||disp=="hide")&&disp!="show"){ <BR> this.className="colsp2"; <BR> this.innerHTML="+"; <BR> for(var i=this.startIndex;i<this.endIndex;i++){ <BR> divJSOutputLineNo.childNodes[i].style.display="none"; <BR> divJSOutputPlus.childNodes[i].style.display="none"; <BR> } <BR> this.linkedDIV.style.display="none"; <BR> }else{ <BR> this.className="colsp"; <BR> this.innerHTML="-"; <BR> this.linkedDIV.style.display="block"; <BR> for(var i=this.startIndex;i<this.endIndex;i++){ <BR> divJSOutputLineNo.childNodes[i].style.display="block"; <BR> divJSOutputPlus.childNodes[i].style.display="block"; <BR> if(divJSOutputPlus.childNodes[i].className=="colsp2"){ <BR> i=divJSOutputPlus.childNodes[i].endIndex-1; <BR> } <BR> } <BR> } <BR> divJSOutput_onscroll(); <BR>} <br><br>function collapseAll(index){ <BR> index=isNaN(parseInt(index))?0:parseInt(index); <BR> if(!divJSOutputPlus.buttons)return; <BR> if(index<0)index=0; <BR> if(index>divJSOutputPlus.buttons.length)return; <BR> for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("hide"); <BR> setTimeout("collapseAll("+i+")"); <BR>} <br><br>function expandAll(index){ <BR> index=isNaN(parseInt(index))?0:parseInt(index); <BR> if(!divJSOutputPlus.buttons)return; <BR> if(index<0)index=0; <BR> if(index>divJSOutputPlus.buttons.length)return; <BR> for(var i=index;i<divJSOutputPlus.buttons.length&&i-index<10;i++)divJSOutputPlus.buttons[i].switchDIV("show"); <BR> setTimeout("expandAll("+i+")"); <BR>} <br><br><BR>function core_analysis(){ <BR> var str=" ", c="", lastState="", seq, intNextQuote, intTemp, intCount, intWordStart; <BR> spnProcess.innerHTML=parseFloat(glbP/glbStr.length*100).toFixed(2)+"% ( "+glbP+" / "+glbStr.length+" )"; <BR> for(var i=glbP;i<glbStr.length;i++){ <BR> c=glbStr.charAt(i); <BR> str+=htmlEncode(c); <BR> switch(c){ <BR> case "\r": case " ": case "\t": <BR> if(lastState=="\r\n"){str=" ";break;} <BR> str=str.substring(0,str.length-htmlEncode(c).length); <BR> if(lastState=="blank")break; <BR> if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){ <BR> str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP); <BR> } <BR> str+=htmlEncode(c); <BR> lastState="blank"; <BR> break; <BR> case ";": <BR> if(str.match(/\Wfor.*?\(/i))break; <BR> // attention there's no break here <BR> case "\n": <BR> if(lastState=="\r\n"){str=" ";break;} <BR> outputLn(str); <BR> str=" "; <BR> lastState="\r\n"; <BR> if(i-glbP>200){ <BR> glbP=i+1; <BR> glbTimer=setTimeout(core_analysis); <BR> return; <BR> } <BR> break; <BR> case "\"": <BR> intNextQuote=i; <BR> while(intNextQuote!=-1&&intNextQuote<glbStr.length){ <BR> intNextQuote=glbStr.indexOf("\"",intNextQuote+1); <BR> if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break; <BR> intCount=0; intTemp=intNextQuote; <BR> while(glbStr.charAt(--intTemp)=="\\")intCount++; <BR> if(intCount%2==0)break; <BR> } <BR> if(intNextQuote==-1)break; <BR> str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\""; <BR> i=intNextQuote; <BR> lastState=""; <BR> break; <BR> case "\'": <BR> intNextQuote=i; <BR> while(intNextQuote!=-1&&intNextQuote<glbStr.length){ <BR> intNextQuote=glbStr.indexOf("\'",intNextQuote+1); <BR> if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break; <BR> intCount=0; intTemp=intNextQuote; <BR> while(glbStr.charAt(--intTemp)=="\\")intCount++; <BR> if(intCount%2==0)break; <BR> } <BR> if(intNextQuote==-1)break; <BR> str+="<span class=\"quote\">"+htmlEncode(glbStr.substring(i+1,intNextQuote))+"<\/span>\'"; <BR> i=intNextQuote; <BR> lastState=""; <BR> break; <BR> case "\/": <BR> if(glbStr.charAt(i+1)=="\/"){ <BR> intNextQuote=i; <BR> intNextQuote=glbStr.indexOf("\r\n",intNextQuote+1); <BR> if(intNextQuote==-1)intNextQuote=glbStr.length; <BR> str=str.substring(0,str.length-1); <BR> str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote)) <BR>+"<\/span>"; <BR> i=intNextQuote; <BR> }else if(glbStr.charAt(i+1)=="*"){ <BR> intNextQuote=i; <BR> intNextQuote=glbStr.indexOf("*\/",intNextQuote+1); <BR> if(intNextQuote==-1)return; <BR> str=str.substring(0,str.length-1); <BR> str+="<span class=\"comments\">\/"+htmlEncode(glbStr.substring(i+1,intNextQuote)) <BR>+"*\/<\/span>"; <BR> i=intNextQuote+1; <BR> }else if(str.match(/[=(][ \t]*\//)){ <BR> intNextQuote=i; <BR> while(intNextQuote!=-1&&intNextQuote<glbStr.length){ <BR> intNextQuote=glbStr.indexOf("\/",intNextQuote+1); <BR> if(intNextQuote==-1||glbStr.charAt(intNextQuote-1)!="\\")break; <BR> intCount=0; intTemp=intNextQuote; <BR> while(glbStr.charAt(--intTemp)=="\\")intCount++; <BR> if(intCount%2==0)break; <BR> } <BR> if(intNextQuote==-1)break; <BR> str+="<span class=\"regexp\">"+htmlEncode(glbStr.substring(i+1,intNextQuote)) <BR>+"<\/span>\/"; <BR> i=intNextQuote; <BR> lastState=""; <BR> } <BR> lastState=""; <BR> break; <BR> case "{": <BR> outputLn(str); <BR> str=" "; <BR> seq=document.createElement("div"); <BR> seq.className="indent"; <BR> curRe.appendChild(seq); <BR> curRe=seq; <BR> lastState="\r\n"; <BR> if(i-glbP>200){ <BR> glbP=i+1; <BR> glbTimer=setTimeout(core_analysis); <BR> return; <BR> } <BR> break; <BR> case "}": <BR> outputLn(str.substring(0,str.length-1)); <BR> str="} "; <BR> lastState=""; <BR> curRe=curRe.parentNode; <BR> break; <BR> default: <BR> if(c.match(/\w/)&&glbStr.charAt(i-1).match(/\W/)){intWordStart=i;} <BR> if(c.match(/\W/)&&glbStr.charAt(i-1).match(/\w/)){ <BR> str=str.substring(0,str.length-htmlEncode(c).length); <BR> str=str.replace(regKW,clKW).replace(regObj,clObj).replace(regMP,clMP)+htmlEncode(c); <BR> } <BR> lastState=""; <BR> break; <BR> } <BR> } <br><br> if(i==glbStr.length){ <BR> if(str!=""){ outputLn(str); str=" "; } <BR> stopExec(); <BR> } <br><br>} <br><br>function outputLn(theStr){ <BR> var seq, txt, fn; <BR> if(html2txt(theStr).match(/^[ \t\r\n]*$/))return; <BR> seq=document.createElement("p"); <BR> seq.innerHTML=theStr; <BR> curRe.appendChild(seq); <br><br> txt=html2txt(theStr); <BR> if(!txt)return; <BR> fn=txt.match(/function[ \t\r\n]+([\.\w]+?)[ \t\r\n]*\(.*?\)[ \t\r\n]*\{/); <BR> if(fn){ <BR> glbFuntionNames.push(fn[1]); <BR> selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]); <BR> selJSExport.options[selJSExport.options.length-1].obj=seq; <BR> } <BR> fn=txt.match(/([\.\w]+?)[ \t\r\n]*=[ \t\r\n]*function\W*\(.*?\)[ \t\r\n]*\{/); <BR> if(fn){ <BR> glbFuntionNames.push(fn[1]); <BR> selJSExport.options[selJSExport.options.length]=new Option(fn[0]+"}",fn[1]); <BR> selJSExport.options[selJSExport.options.length-1].obj=seq; <BR> } <BR>} <br><br>function clKW(str){ return(str.charAt(0)+"<span class=\"keyWord\">"+str.substring(1)+""); } <br><br>function clObj(str){ return(str.charAt(0)+"<span class=\"object\">"+str.substring(1)+""); } <br><br>function clMP(str){ return(str.charAt(0)+"<span class=\"method_property\">"+str.substring(1)+""); } <br><br>function clOP(str){ return(str.charAt(0)+"<span class=\"operator\">"+str.substring(1)+""); } <br><br><BR>//------------------ <BR>// global scripts <BR>//------------------ <br><br>function maximizeWindow(){ <BR> window.moveTo(0,0); <BR> window.resizeTo(screen.availWidth,screen.availHeight); <BR>} <br><br>function htmlEncode(strS){ <BR> return(strS.replace(/&/g,"&").replace(/,"<").replace(/>/g,">").replace(/ /g," ").replace(/ <BR>\r\n/g,"<br\/>")); <BR>} <br><br>function html2txt(strS){ <BR> return(strS.replace(/<.+?>/g,"").replace(/,"<").replace(/>/g,">").replace(/ /g," ").replace(/<br\/? <BR>>/g,"\r\n").replace(/&/g,"&")); <BR>} <br><br></script>




Input JS
Collapse All
Expand All
Export JS



    
Please Input the JS:

    
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
Java vs JavaScript:開發人員的詳細比較Java vs JavaScript:開發人員的詳細比較May 16, 2025 am 12:01 AM

javaandjavascriptaredistinctlanguages:javaisusedforenterpriseandmobileapps,while javascriptifforInteractiveWebpages.1)JavaisComcompoppored,statieldinglationallyTypted,statilly tater astrunsonjvm.2)

JavaScript數據類型:瀏覽器和nodejs之間是否有區別?JavaScript數據類型:瀏覽器和nodejs之間是否有區別?May 14, 2025 am 12:15 AM

JavaScript核心數據類型在瀏覽器和Node.js中一致,但處理方式和額外類型有所不同。 1)全局對像在瀏覽器中為window,在Node.js中為global。 2)Node.js獨有Buffer對象,用於處理二進制數據。 3)性能和時間處理在兩者間也有差異,需根據環境調整代碼。

JavaScript評論:使用//和 / * * / * / * /JavaScript評論:使用//和 / * * / * / * /May 13, 2025 pm 03:49 PM

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python vs. JavaScript:開發人員的比較分析Python vs. JavaScript:開發人員的比較分析May 09, 2025 am 12:22 AM

Python和JavaScript的主要區別在於類型系統和應用場景。 1.Python使用動態類型,適合科學計算和數據分析。 2.JavaScript採用弱類型,廣泛用於前端和全棧開發。兩者在異步編程和性能優化上各有優勢,選擇時應根據項目需求決定。

Python vs. JavaScript:選擇合適的工具Python vs. JavaScript:選擇合適的工具May 08, 2025 am 12:10 AM

選擇Python還是JavaScript取決於項目類型:1)數據科學和自動化任務選擇Python;2)前端和全棧開發選擇JavaScript。 Python因其在數據處理和自動化方面的強大庫而備受青睞,而JavaScript則因其在網頁交互和全棧開發中的優勢而不可或缺。

Python和JavaScript:了解每個的優勢Python和JavaScript:了解每個的優勢May 06, 2025 am 12:15 AM

Python和JavaScript各有優勢,選擇取決於項目需求和個人偏好。 1.Python易學,語法簡潔,適用於數據科學和後端開發,但執行速度較慢。 2.JavaScript在前端開發中無處不在,異步編程能力強,Node.js使其適用於全棧開發,但語法可能複雜且易出錯。

JavaScript的核心:它是在C還是C上構建的?JavaScript的核心:它是在C還是C上構建的?May 05, 2025 am 12:07 AM

javascriptisnotbuiltoncorc; sanInterpretedlanguagethatrunsonenginesoftenwritteninc.1)JavascriptwasdesignedAsignedAsalightWeight,drackendedlanguageforwebbrowsers.2)Enginesevolvedfromsimpleterterpretpretpretpretpreterterpretpretpretpretpretpretpretpretpretcompilerers,典型地,替代品。

JavaScript應用程序:從前端到後端JavaScript應用程序:從前端到後端May 04, 2025 am 12:12 AM

JavaScript可用於前端和後端開發。前端通過DOM操作增強用戶體驗,後端通過Node.js處理服務器任務。 1.前端示例:改變網頁文本內容。 2.後端示例:創建Node.js服務器。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。