search
HomeWeb Front-endJS TutorialJS code formatting and syntax coloring V2_javascript tips

Upgraded to the second version, open a post to celebrate, hahaha

Upgrade content from Ver1.1
1. Add function list
2. Add function Export function
3. Add Function dependency analysis (I have never seen this function implemented by other software. I am creative and have many problems. At present, the analysis ability is still relatively limited. I can only analyze global function dependencies. Bugs may occur in complex code)
4. Fix the for statement analysis bug
5. Fix the syntax folding bug
6. Improve the working method of Collapse All ※ Expand All function to avoid crash when the number of rows is too large
7. Improve the line number analysis mechanism , to avoid crashes when the number of lines is too large

Copy code The code is as follows:



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("rn<br>rn"); <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=="rn"){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=="rn"){str=" ";break;}<BR>                outputLn(str); <BR>                str=" "; <BR>                lastState="rn"; <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)) """; <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)) "'"; <BR>                i=intNextQuote; <BR>                lastState=""; <BR>            break; <BR>            case "/": <BR>                if(glbStr.charAt(i 1)=="/"){ <BR>                    intNextQuote=i; <BR>                    intNextQuote=glbStr.indexOf("rn",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> ""; <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> "*/"; <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> "/"; <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="rn"; <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:

    
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
C   and JavaScript: The Connection ExplainedC and JavaScript: The Connection ExplainedApr 23, 2025 am 12:07 AM

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

From Websites to Apps: The Diverse Applications of JavaScriptFrom Websites to Apps: The Diverse Applications of JavaScriptApr 22, 2025 am 12:02 AM

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python vs. JavaScript: Use Cases and Applications ComparedPython vs. JavaScript: Use Cases and Applications ComparedApr 21, 2025 am 12:01 AM

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

The Role of C/C   in JavaScript Interpreters and CompilersThe Role of C/C in JavaScript Interpreters and CompilersApr 20, 2025 am 12:01 AM

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript in Action: Real-World Examples and ProjectsJavaScript in Action: Real-World Examples and ProjectsApr 19, 2025 am 12:13 AM

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

JavaScript and the Web: Core Functionality and Use CasesJavaScript and the Web: Core Functionality and Use CasesApr 18, 2025 am 12:19 AM

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding the JavaScript Engine: Implementation DetailsUnderstanding the JavaScript Engine: Implementation DetailsApr 17, 2025 am 12:05 AM

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python vs. JavaScript: The Learning Curve and Ease of UsePython vs. JavaScript: The Learning Curve and Ease of UseApr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function