JS代码格式化和语法着色V2_javascript技巧
升级到第二版,开一贴以示庆贺,哈哈哈
自 Ver1.1 升级内容
1. 增加函数列表
2. 增加函数 Export 功能
3. 增加函数依存关系分析 (这个功能个人未见其他软件实现过,自己创意,问题多多,目前分析能力还是比较有限的,只能分析全局函数依存关系,可能在复杂代码的情况下出现 bug)
4. 修正 for 语句分析 bug
5. 修正 语法折叠的 bug
6. 改进 Collapse All ※ Expand All 函数工作方式,避免行数太大时的死机
7. 改进行号分析机制,避免行数太大时的死机
<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>

Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

Penjelasan terperinci mengenai kaedah penggantian rentetan javascript dan Soalan Lazim Artikel ini akan meneroka dua cara untuk menggantikan watak rentetan dalam JavaScript: Kod JavaScript dalaman dan HTML dalaman untuk laman web. Ganti rentetan di dalam kod JavaScript Cara yang paling langsung ialah menggunakan kaedah pengganti (): str = str.replace ("cari", "ganti"); Kaedah ini hanya menggantikan perlawanan pertama. Untuk menggantikan semua perlawanan, gunakan ungkapan biasa dan tambahkan bendera global g: str = str.replace (/fi

Tutorial ini menunjukkan kepada anda bagaimana untuk mengintegrasikan API carian Google tersuai ke dalam blog atau laman web anda, menawarkan pengalaman carian yang lebih halus daripada fungsi carian tema WordPress standard. Ia menghairankan mudah! Anda akan dapat menyekat carian ke y

Jadi di sini anda, bersedia untuk mempelajari semua perkara ini yang dipanggil Ajax. Tetapi, apa sebenarnya? Istilah Ajax merujuk kepada kumpulan teknologi longgar yang digunakan untuk membuat kandungan web yang dinamik dan interaktif. Istilah Ajax, yang asalnya dicipta oleh Jesse J

Siri artikel ini ditulis semula pada pertengahan 2017 dengan maklumat terkini dan contoh segar. Dalam contoh JSON ini, kita akan melihat bagaimana kita dapat menyimpan nilai mudah dalam fail menggunakan format JSON. Menggunakan notasi pasangan nilai utama, kami boleh menyimpan apa-apa jenis

Leverage JQuery untuk Layouts Laman Web yang mudah: 8 Plugin Essential JQuery memudahkan susun atur laman web dengan ketara. Artikel ini menyoroti lapan plugin jQuery yang kuat yang menyelaraskan proses, terutamanya berguna untuk penciptaan laman web manual

Mata teras Ini dalam JavaScript biasanya merujuk kepada objek yang "memiliki" kaedah, tetapi ia bergantung kepada bagaimana fungsi dipanggil. Apabila tidak ada objek semasa, ini merujuk kepada objek global. Dalam penyemak imbas web, ia diwakili oleh tetingkap. Apabila memanggil fungsi, ini mengekalkan objek global; tetapi apabila memanggil pembina objek atau mana -mana kaedahnya, ini merujuk kepada contoh objek. Anda boleh mengubah konteks ini menggunakan kaedah seperti panggilan (), memohon (), dan mengikat (). Kaedah ini memanggil fungsi menggunakan nilai dan parameter yang diberikan. JavaScript adalah bahasa pengaturcaraan yang sangat baik. Beberapa tahun yang lalu, ayat ini

JQuery adalah rangka kerja JavaScript yang hebat. Walau bagaimanapun, seperti mana -mana perpustakaan, kadang -kadang perlu untuk mendapatkan di bawah tudung untuk mengetahui apa yang sedang berlaku. Mungkin kerana anda mengesan bug atau hanya ingin tahu tentang bagaimana jQuery mencapai UI tertentu

Siaran ini menyusun helaian cheat berguna, panduan rujukan, resipi cepat, dan coretan kod untuk perkembangan aplikasi Android, BlackBerry, dan iPhone. Tiada pemaju harus tanpa mereka! Panduan Rujukan Gesture Touch (PDF) Sumber yang berharga untuk desig
