⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
function BiWebService()    {    var el = document.createElement("meta");    if (el.addBehavior)        {        el.addBehavior(application.getPath() + "" + BiWebService.HTC_PATH);        document.getElementsByTagName("head")[0].appendChild(el);        return el;        }    throw new Error("Not yet implemented");    }BiWebService.HTC_PATH = "js/biwebservice.htc";BiWebService.create = function()    {    return new BiWebService;    } ;if (window.XMLHttpRequest)    {    XMLDocument.prototype.__realLoad = XMLDocument.prototype.load;    XMLDocument.prototype.load = function(sUri)        {        this.readyState = 0;        this.__realLoad(sUri);        };    XMLDocument.prototype.__defineSetter__("onreadystatechange", function(f)        {        if (this._onreadystatechange)            this.removeEventListener("load", this._onreadystatechange, false);        this._onreadystatechange = f;        if (f)            this.addEventListener("load", f, false);        return f;        });    XMLDocument.prototype.__defineGetter__("onreadystatechange", function()        {        return this._onreadystatechange;        } );    XMLDocument.prototype.loadXML = function(s)        {        var doc2 = ( new DOMParser).parseFromString(s, "text/xml");        while (this.hasChildNodes())            this.removeChild(this.lastChild);        var cs = doc2.childNodes;        var l = cs.length;        for (var i = 0; i < l; i++)            this.appendChild(this.importNode(cs[i], true));        };    BiXmlDocument._mozHasParseError = function(oDoc)        {        return !oDoc.documentElement || oDoc.documentElement.localName == "parsererror"                   && oDoc.documentElement.getAttribute(                          "xmlns") == "http://www.mozilla.org/newlayout/xml/parsererror.xml";        } ;    XMLDocument.prototype.__defineGetter__("parseError", function()        {        var hasError = BiXmlDocument._mozHasParseError(this);        var res = { errorCode: 0, filepos: 0, line: 0, linepos: 0, reason: "", srcText: "", url: "" };        if (hasError)            {            res.errorCode = -1;            try                {                res.srcText = this.getElementsByTagName("sourcetext")[0].firstChild.data;                res.srcText = res.srcText.replace(/\n\-\^$/, "");                }            catch (ex)                {                res.srcText = "";                }            try                {                var s = this.documentElement.firstChild.data;                var re = /XML Parsing Error\:(.+)\nLocation\:(.+)\nLine Number(\d+)\,Column(\d+)/;                var a = re.exec(s);                res.reason = a[1];                res.url = a[2];                res.line = a[3];                res.linepos = a[4];                }            catch (ex)                {                res.reason = "Uknown";                }            }        return res;        });    Node.prototype.__defineGetter__("xml", function()        {        return ( new XMLSerializer).serializeToString(this);        } );    Attr.prototype.__defineGetter__("xml", function()        {        var nv = ( new XMLSerializer).serializeToString(this);        return this.nodeName + "=\"" + nv.replace(/\"/g, "&quot;") + "\"";        });    Text.prototype.__defineGetter__("text", function()        {        return this.nodeValue;        } );    Node.prototype.__defineGetter__("text", function()        {        var cs = this.childNodes;        var l = cs.length;        var sb = new Array(l);        for (var i = 0; i < l; i++)            sb[i] = cs[i].text;        return sb.join("");        });    Node.prototype.selectNodes = function(sExpr)        {        var doc = this.nodeType == 9 ? this : this.ownerDocument;        var nsRes = doc.createNSResolver(this.nodeType == 9 ? this.documentElement : this);        var xpRes = doc.evaluate(sExpr, this, nsRes, 5, null);        var res = [];        var item;        while ((item = xpRes.iterateNext()))            res.push(item);        return res;        };    Node.prototype.selectSingleNode = function(sExpr)        {        var doc = this.nodeType == 9 ? this : this.ownerDocument;        var nsRes = doc.createNSResolver(this.nodeType == 9 ? this.documentElement : this);        var xpRes = doc.evaluate(sExpr, this, nsRes, 9, null);        return xpRes.singleNodeValue;        };    Node.prototype.transformNode = function(oXsltNode)        {        var doc = this.nodeType == 9 ? this : this.ownerDocument;        var processor = new XSLTProcessor();        processor.importStylesheet(oXsltNode);        var df = processor.transformToFragment(this, doc);        return df.xml;        };    Node.prototype.transformNodeToObject = function(oXsltNode, oOutputDocument)        {        var doc = this.nodeType == 9 ? this : this.ownerDocument;        var outDoc = oOutputDocument.nodeType == 9 ? oOutputDocument : oOutputDocument.ownerDocument;        var processor = new XSLTProcessor();        processor.importStylesheet(oXsltNode);        var df = processor.transformToFragment(this, doc);        while (oOutputDocument.hasChildNodes())            oOutputDocument.removeChild(oOutputDocument.lastChild);        var cs = df.childNodes;        var l = cs.length;        for (var i = 0; i < l; i++)            oOutputDocument.appendChild(outDoc.importNode(cs[i], true));        };    }function biExec(sRootPath, sAdfRelPath, bUseCurrentWindow)    {    var left, top, width, height, centered, resizable, fullScreen;    var adfPath, adfName;    function _toPixel(s, sAxis)        {        if (String(s).indexOf("%") != -1)            {            var n = Number(s.replace(/\%/g, ""));            return n / 100 * (sAxis == "x" ? screen.availWidth : screen.availHeight);            }        return s;        }    function _getAttr(el, name, def, tp)        {        var res;        if (!el || !el.getAttribute(name))            res = def;        else            res = el.getAttribute(name);        if (tp)            return _toPixel(res, tp);        return res;        }    sRootPath = String(sRootPath);    sAdfRelPath = String(sAdfRelPath);    if (sRootPath.charAt(sRootPath.length - 1) != "/")        sRootPath = sRootPath + "/";    var re = /([^\/]+\/)?(\w+)(\.[^\/]*)?$/;    var ok = re.test(sAdfRelPath);    if (ok)        adfName = RegExp.$2;    else        errorMessage = "The ADF argument cannot be parsed";    if (/(^http\:)|(^https\:)|(^file\:)|(^\/)/.test(sAdfRelPath))        {        adfPath = sAdfRelPath;        }    else        {        var curPath = document.location.href;        slashIndex = curPath.lastIndexOf("/");        curPath = curPath.substring(0, slashIndex);        adfPath = curPath + "/" + sAdfRelPath;        }    var uri = sRootPath + "bimain.html?Adf=" + encodeURIComponent(                                                   adfPath) + ";AdfName=" + adfName + ";Params=" + Math.max(0,                                                                                                            (arguments.length                                                                                                                - 3));    for (var i = 3; i < arguments.length; i++)        {        uri += ";Param" + (i - 3) + "=" + encodeURIComponent(arguments[i]);        }    var fs = /^file\:/.test(adfPath);    var error = false;    var errorMessage = "";    var xmlHttp = new BiXmlHttp();    xmlHttp.open("GET", adfPath, false);    try        {        xmlHttp.send(null);        }    catch (ex)        {        error = true;        errorMessage = "File not found"        }    if (!error)        {        if (fs)            {            var s = String(xmlHttp.responseText).replace(/<\?xml[^\?]*\?>/, "");            xmlHttp.responseXML.loadXML(s);            }        else if (xmlHttp.status != 200)            {            error = true;            errorMessage = xmlHttp.status + ": " + xmlHttp.statusText;            }        }    if (!error)        {        if (xmlHttp.responseXML.parseError.errorCode != 0)            {            error = true;            errorMessage = xmlHttp.responseXML.parseError.reason;            }        }    if (!error)        {        var doc = xmlHttp.responseXML;        var n = doc.selectSingleNode("/application/window | /Application/Window");        left = _getAttr(n, "left", "", "x");        right = _getAttr(n, "right", "", "x");        top = _getAttr(n, "top", "", "y");        bottom = _getAttr(n, "bottom", "", "y");        width = _getAttr(n, "width", "", "x");        height = _getAttr(n, "height", "", "y");        centered = _getAttr(n, "centered", "false") == "true";        resizable = _getAttr(n, "resizable", "true") != "false";        fullScreen = _getAttr(n, "fullScreen", "false") == "true";        var sw = screen.width;        var sh = screen.height;        if (right != "" && width != "")            left = sw - width - right;        else if (left != "" && right != "")            width = sw - left - right;        if (bottom != "" && height != "")            top = sh - height - bottom;        else if (top != "" && bottom != "")            height = sh - top - bottom;        if (left == "" && right == "" && centered)            left = (sw - width) / 2;        if (top == "" && bottom == "" && centered)            top = (sh - height) / 2;        if (!bUseCurrentWindow)            {            var w = window.open(uri,                                adfName, "menubar=0,location=0,status=0,toolbar=0,scrollbars=1" + (left                                                                                                      ? ",left=" + left                                                                                                      : "") + (top                                                                                                                  ? ",top=" + top                                                                                                                  : "") + (width                                                                                                                              ? ",width=" + (width - 8) : "") + (height ? ",height=" + (height - 32) : "") + (fullScreen                                                                                                                                                                                                                 ? ",fullscreen=1" : "")                                    + (resizable                                          ? ",resizable=1" : ""),                                false);            w.focus();            }        else            {            document.location.href = uri;            window.focus();            }        }    else        alert(errorMessage);    return !error;    }function BiTextLoader()    {    BiEventTarget.call(this);    this._xmlHttp = new BiXmlHttp();    var oThis = this;    this.__onreadystatechange = function()        {        oThis._onreadystatechange();        } ;    }var _p = BiTextLoader.prototype = new BiEventTarget;_p._className = "BiTextLoader";_p._method = "GET";_p._async = false;_p._uri = null;_p._user = "";_p._password = "";_p._loadCount = 0;BiTextLoader.load = function(oUri)    {    var tl = new BiTextLoader;    tl.load(oUri);    var s = tl.getText();    tl.dispose();    return s;    };BiTextLoader.prototype.getMethod = function()    {    return this._method;    } ;BiTextLoader.prototype.setMethod = function(v)    {    this._method = v;    } ;BiTextLoader.prototype.getUri = function()    {    return this._uri;    } ;BiTextLoader.prototype.getAsync = function()    {    return this._async;    } ;BiTextLoader.prototype.setAsync = function(v)    {    this._async = v;    } ;BiTextLoader.prototype.getUser = function()    {    return this._user;    } ;BiTextLoader.prototype.setUser = function(v)    {    this._user = v;    } ;BiTextLoader.prototype.getPassword = function()    {    return this._password;    } ;BiTextLoader.prototype.setPassword = function(v)    {    this._password = v;    } ;_p.setUri = function(oUri)    {    if (oUri instanceof BiUri)        this._uri = oUri;    else        this._uri = new BiUri(application.getAdfPath(), oUri);    };_p.load = function(oUri)    {    this.open("GET", oUri || this._uri, this._async);    this.send();    };_p.post = function(oUri, oXmlDocument)    {    this.open("POST", oUri || this._uri, this._async);    this.send(oXmlDocument);    };_p.open = function(sMethod, oUri, bAsync, sUser, sPassword)    {    this._method = sMethod;    this.setUri(oUri);    this._async = bAsync != null ? bAsync : true;    this._user = sUser;    this._password = sPassword;    this._xmlHttp.abort();    this._xmlHttp.onreadystatechange = this.__onreadystatechange;    this._xmlHttp.open(this._method, String(this._uri), this._async, this._user, this._password);    };_p.send = function(oObject)    {    this._loadCount = 0;    this._xmlHttp.send(oObject);    };_p.abort = function()    {    this._xmlHttp.abort();    } ;_p.getLoaded = function()    {    return this._xmlHttp.readyState == 4;    } ;_p.getLoading = function()    {    return this._xmlHttp.readyState < 4;    } ;_p.getText = function()    {    return String(this._xmlHttp.responseText);    } ;_p.getXmlHttp = function()    {    return this._xmlHttp;    } ;_p.getError = function()    {    if (this.getUri().getScheme() == "file")        {        return this._xmlHttp.status != 0;        }    return this._xmlHttp.status != 200;    };_p.dispose = function()    {    if (this._disposed)        return;    BiEventTarget.prototype.dispose.call(this);    this.__onreadystatechange = null;    this._xmlHttp.onreadystatechange = function()        {        } ;    this._xmlHttp = null;    };_p._onreadystatechange = function()    {    if (this._xmlHttp.readyState == 4)        {        if (this._loadCount == 0)            {            this._loadCount++;            this.dispatchEvent(new BiEvent("load"));            }        }    };function BiXmlLoader()    {    BiTextLoader.call(this);    this.addEventListener("load", BiXmlLoader._onLoad);    }_p = BiXmlLoader.prototype = new BiTextLoader;_p._className = "BiXmlLoader";_p.dispose();_p._disposed = false;BiXmlLoader.load = function(oUri)    {    var xl = new BiXmlLoader();    xl.load(oUri);    var doc = xl.getDocument();    xl.dispose();    return doc;    };_p.getDocument = function()    {    return this.getXmlHttp().responseXML;    } ;_p.getError = function()    {    return BiTextLoader.prototype.getError.call(this) || this.getDocument().parseError.errorCode != 0;    } ;BiXmlLoader._onLoad = function(e)    {    var xl = e.getTarget();    if (BiBrowserCheck.ie && xl.getUri().getScheme() == "file" && !xl.getError())        {        var s = xl.getText();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -