Home Web Front-end JS Tutorial Script Bar - Huanyu Studio uses js, highly recommended base.js_javascript skills

Script Bar - Huanyu Studio uses js, highly recommended base.js_javascript skills

May 16, 2016 pm 07:22 PM
-

base.js
Copy code The code is as follows:

browser_init()
function browser_init(){
    window.isIE=navigator.appName.indexOf("Microsoft")==0
    window.$sys={}
    window.$my={}
    String.prototype.trim=function(){return this.replace(/(^[s]*)|([s]*$)/g,"")}
    String.prototype.inc=function(s1,s2){if(s2==null){s2=","};return (s2 this s2).indexOf(s2 s1 s2)>-1?1:0}
    String.prototype.lenB=function(){return this.replace(/[^x00-xff]/g,"**").length}
    String.prototype.leftB=function(len,isOmit){var s;s=this.replace(/*/g," ").replace(/[^x00-xff]/g,"**");if(s.length>len&&isOmit){len-=3};return this.slice(0,s.slice(0,len).replace(/***/g,"").length) (s.length>len&&isOmit?"...":"")}
    String.prototype.getVar=function(str,def){if(this.inc(str,";"))return 1;var a=this.match(new RegExp("(^|;)" str ":[^;]*"));return a==null||str==""?(def==null?"":def):a[0].replace(";","").slice(str.length 1)}
    String.prototype._slice="".slice
    String.prototype.slice=function(n1,n2){var v,b1=typeof(n1)=="number",b2=typeof(n2)=="number";if(!b1||typeof(n2)=="string"){v=eval("this._slice(" (b1?n1:this.indexOf(n1) (n2==null?1:0) (this.indexOf(n1)==-1?this.length:0)) (n2==null?"":(b2?n2:(this.indexOf(n2)==-1?"":"," this.indexOf(n2)))) ")")}else{v=eval("this._slice(n1" (n2==null?"":"," n2) ")")}return v}
    Array.prototype.parseInt=function(){var i,count=this.length;for(i=0;i    Array.prototype.remove=function(item){var i,count=this.length;for(i=0;i    Array.prototype.plus=function(item){for(var i=0;i    window.$=function(obj){return typeof(obj)=="string"?document.getElementById(obj):obj}
    window.ow=function(win){return $(win).contentWindow}
    window.oDel=function(obj){if($(obj)!=null){$(obj).parentNode.removeChild($(obj))}}
    window.oHide=function(obj){if($(obj)!=null){$(obj).style.visibility="hidden"}}
    window.oShow=function(obj){if($(obj)!=null){$(obj).style.visibility=""}}
    window.oFocu=function(obj){window.tempObj=$(obj);window.setTimeout("try{window.tempObj.focus()}catch(e){}",10)}
    window.fmCheck=function(){return true}

    $sys.url=location.href
    $sys.path=$sys.url.slice(0,"?").slice(0,$sys.url.lastIndexOf("/") 1)
    document.write("")
    if(document.all){
        document.execCommand("BackgroundImageCache",false,true)
    }
    else{
        HTMLElement.prototype.attachEvent=function(type,foo){this.addEventListener(type.slice(2),foo,false)}
        HTMLElement.prototype.contains=function(node){if(!node)return false;do if(node==this){return true}while(node=node.parentNode){return false}}
        HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){var r=this.ownerDocument.createRange();r.setStartBefore(this);var df=r.createContextualFragment(sHTML);this.parentNode.replaceChild(df,this);return sHTML;})
        HTMLElement.prototype.__defineGetter__("innerText",function(){var r = this.ownerDocument.createRange();r.selectNodeContents(this);return r.toString()})
        Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1){node=node.parentNode}return node})
        Event.prototype.__defineGetter__("fromElement",function(){return this.relatedTarget})
        Event.prototype.__defineGetter__("toElement",function(){return this.relatedTarget})
        Event.prototype.__defineGetter__("offsetX",function(){return this.layerX})
        Event.prototype.__defineGetter__("offsetY",function(){return this.layerY})
    }
    drag_init()
    thd_init()
    document_onload()
}
function document_onload(){
    var l
    l="
"
    l+=""
    l+=""
    l+="
"
    insHtm(document.body,l)
    document.body.onmouseover=document.body.onmouseout=document.body.onmousedown=document.body.onmouseup=function(e){
        var ee
        e=e||event
        ee=e.srcElement
        if(e.type=="mouseover"&&(ee.tagName=="A"||ee.tagName=="INPUT"||ee.tagName=="LABEL")&&!ee.hideFocus)
            ee.hideFocus=true
    }
    document.body.onkeydown=function(e){
        var ee
        e=e||event
        ee=e.srcElement
        if(ee.tagName=="INPUT"&&e.keyCode==13&&isIE&&ee.form!=null){
            if(ee.form.btSubmit!=null)
                ee.form.btSubmit.click()
        }
    }
    if(window.body_onload!=null)
        body_onload()
}
function drag_init(){
    window.$drag={}
    window.startDrag=function(obj,e){
        $drag.obj=$(obj)
        $drag.x0=$drag.obj.offsetLeft
        $drag.y0=$drag.obj.offsetTop
        $drag.sx=e.clientX
        $drag.sy=e.clientY
        if(document.all)
            $drag.obj.setCapture()
    }
    document.onmouseup=function(){
        if($drag.obj==null)
            return
        if(document.all)
            $drag.obj.releaseCapture()
        $drag.obj=null
    }
    document.onmousemove=function(e){
        var x,y
        if($drag.obj==null)
            return
        e=e||event
        x=Math.min(e.clientX-$drag.sx $drag.x0,document.body.scrollLeft document.body.clientWidth-$drag.obj.offsetWidth)
        y=Math.min(e.clientY-$drag.sy $drag.y0,document.body.scrollTop document.body.clientHeight-$drag.obj.offsetHeight)
        x=Math.max(x,0)
        y=Math.max(y,document.body.scrollTop)
        $drag.obj.style.left=x "px"
        $drag.obj.style.top=y "px"
    }
}
function thd_init(){
    window.$thd={}
    $thd.items=[]
    $thd.index=0
    $thd.push=function(foo,interval){
        foo.interval=interval==null?1:interval
        $thd.items.push(foo)
    }
    $thd.remove=function(foo){
        $thd.items.remove(foo)
    }
    $thd.run=function(){
        var ol=$thd.items,i
        for(i=0;i            if($thd.index%ol[i].interval==0||ol[i].start==null){
                ol[i].start=1
                ol[i]()
            }
        }
        $thd.index
        window.setTimeout("$thd.run()",10)
    }
    $thd.run()
}
function $x(obj,op){
    var o,x=0
    op=op||document.body
    do{
        o=o==null?$(obj):o.parentNode
        if(op==o)
            break
        x =o.offsetLeft
    }while(op.contains(o))
    return x
}
function $y(obj,op){
    var o,y=0
    op=op||document.body
    do{
        o=o==null?$(obj):o.parentNode
        if(op==o)
            break
        if(o.tagName=="TR")
            continue
        y =o.offsetTop-o.scrollTop
    }while(op.contains(o))
    return y
}
function getPngBg(url){
    return document.all&&/.png/i.test(url)?"filter:progid:dximagetransform.microsoft.alphaimageloader(src=" url ",sizingMethod=scale)":"background:url(" url ")"
}
function setHtm(op,str){
    op=$(op)
    if(op.tagName=="TABLE"){
        if(op.tBodies.length==0)
            op.appendChild(document.createElement("tbody"))
        op.replaceChild(document.createElement("tbody"),op.tBodies[0])
    }
    else
        op.innerHTML=""
    insHtm(op,str)
}
function insHtm(op,str,oRefer){
    var bx=document.createElement("div"),ol,i
    op=$(op)
    if(op.tagName=="TABLE"){
        bx.innerHTML="" str "
"
        ol=bx.childNodes[0].tBodies[0].rows
        if(op.tBodies.length==0)
            op.appendChild(document.createElement("tbody"))
        while(ol.length>0){
            op.tBodies[0].insertBefore(ol[0],oRefer==null?null:oRefer)
        }
    }
    else{
        op.insertBefore(bx,oRefer==null?null:oRefer)
        bx.outerHTML=str
    }
    btBinding(op)
    fmBinding(op)
}
function btBinding(op){
    var ol,i,a,bg
    ol=(op||document.body).getElementsByTagName("SPAN")
    for(i=0;i        if(ol[i].getAttribute("type")!="button"||ol[i].getAttribute("bg")==null)
            continue
        bg=ol[i].getAttribute("bg")
        ol[i].removeAttribute("bg")
        a=ol[i].getAttribute("pos").split(",")
        ol[i].style.cssText="position:absolute;overflow:hidden;left:" a[0] ";top:" a[1] ";width:" a[2] ";height:" a[3]
        ol[i].innerHTML=""
        ol[i].onmouseover=function(){this.scrollTop=this.offsetHeight}
        ol[i].onmouseout=function(){this.scrollTop=0}
        ol[i].onmousedown=function(){this.scrollTop=this.offsetHeight*2}
        ol[i].onmouseup=function(){this.scrollTop=this.offsetHeight}
    }
}
function fmBinding(op){
    var ol,i,sResult,foo
    ol=(op||document.body).getElementsByTagName("FORM")
    for(i=0;i        if(ol[i].onsubmit!=null)
            continue
        insHtm(ol[i],"",ol[i].firstChild)
        ol[i].onkeydown=function(e){
            e=e||event
            if(e.keyCode==13)
                return false
        }
        ol[i].onsubmit=function(e){
            var fm=this
            if(!fmCheck(fm))
                return false
            sResult=1
            try{
                foo=fm.getAttribute("onbeforeload")
                if(typeof(foo)=="function")
                    sResult=foo()
                else if(typeof(foo)=="string")
                    eval(foo.replace(/return /,"sResult="))
            }catch(e){alert(e.description)}
            if(sResult==false)
                return false
            if(fm.method=="post"){
                fm.target="wForm"
                $sys.fmWinType=fm
                return true
            }
            loadXml(fmv(fm),function(xml){
                var foo=fm.getAttribute("onload")
                if(typeof(foo)=="function")
                    foo(xml)
                else if(typeof(foo)=="string")
                    eval(foo)
            })
            return false
        }
    }
}
function fmWinOnLoad(win){
    var xml,str,foo,error
    if(document.all){
        str=win.contentWindow.document.body.innerText.replace(/n[s]*-/g,"n")
        if(str=="")
            return
        if(!/<[^>] /.test(str)){
            alert(str)
            return        
        }
        str=str.slice(1)
        xml=createXml(str)
    }
    else{
        if((win.contentWindow.document "").indexOf("XML")==-1)
            return
        xml=win.contentWindow.document.documentElement
    }
    error=ndv(xml,"error")
    if(error!=null)
        return alert(error)
    foo=$sys.fmWinType.onload
    if(typeof(foo)=="function")
        foo(xml)
    else if(typeof(foo)=="string")
        eval(foo)
}
function fmv(fm){
    var i,f,v,l
    l=fm.action
    for(i=0;i        if(!"INPUT,TEXTAREA,SELECT".inc(fm[i].tagName)||"submit,button".inc(fm[i].type))
            continue
        v=fm[i].value.trim()
        f=fm[i].getAttribute("postName")||fm[i].name
        if(f==""||(fm[i].type=="radio"&&!fm[i].checked)||fm[i].readOnly==true)
            continue
        if(fm[i].type=="checkbox")
            v=fm[i].checked?v.replace(/^on$/g,1):0
        l ="&" f "=" escape(v)
    }
    if(l.indexOf("?")==-1)
        l=l.replace("&","?")
    return l
}
function createXml(str){
    if(isIE){
        var xml=new ActiveXObject("Microsoft.XMLDOM")
            xml.loadXML(str)
        xml.setProperty("SelectionLanguage","XPath")
    }
    else
        var xml=new DOMParser().parseFromString(str,"text/xml")
    return xml.documentElement
}
function getXmlNode(node,expr,isAll){
    var ol
    if(isIE)
        ol=node.selectNodes(expr)
    else{
        var xpe=new XPathEvaluator(),nsr,res,ol=[],r
        nsr=xpe.createNSResolver(node.ownerDocument==null?node.documentElement:node.ownerDocument.documentElement)
        res=xpe.evaluate(expr,node,nsr,0,null)
        while(r=res.iterateNext()){
            r.text=r.textContent
            ol.push(r)
        }
    }
    return isAll?ol:ol[0]
}
function ndv(node,expr,def){
    var ol,s,$0,r
    if(expr.indexOf("@")==0)
        return node.getAttribute(expr.slice(1))||def
    ol=getXmlNode(node,unescape(expr.slice(0,"?")))
    if(ol==null)
        return
    if(ol.length==0)
        return def
    r=$0=ol.length==0?def:unescape(ol.text)
    return r
}
function loadXml(url,foo){
    var xh,method,ondataok
    xh=isIE?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()
    method=url.indexOf(".xml")?"GET":"POST"
    xh.open(method,url,true)
    xh.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    xh.send(method=="POST"?url.slice("?"):null)
    ondataok=function(){
        var xml=xh.responseXML,error
        if(xml!=null)
            xml=xh.responseXML.documentElement
        if(xml==null){
            window.clipboardData.setData("text",$sys.path url)
            alert("载入xml数据出错!")
            return
        }
        error=ndv(xml,"error")
        if(error!=null){
            alert(error)
            return
        }
        foo(xml)
    }
    if(xh.readyState==4)
        ondataok()
       xh.onreadystatechange=function(){
        if(xh.readyState==4)
            ondataok()
    }
}

Statement of this Website
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

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
JavaScript Engines: Comparing Implementations JavaScript Engines: Comparing Implementations Apr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 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.

From C/C   to JavaScript: How It All Works From C/C to JavaScript: How It All Works Apr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

JavaScript and the Web: Core Functionality and Use Cases JavaScript and the Web: Core Functionality and Use Cases Apr 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.

JavaScript in Action: Real-World Examples and Projects JavaScript in Action: Real-World Examples and Projects Apr 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.

Understanding the JavaScript Engine: Implementation Details Understanding the JavaScript Engine: Implementation Details Apr 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: Community, Libraries, and Resources Python vs. JavaScript: Community, Libraries, and Resources Apr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

Python vs. JavaScript: Development Environments and Tools Python vs. JavaScript: Development Environments and Tools Apr 26, 2025 am 12:09 AM

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

See all articles