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

📄 databinding.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 2 页
字号:
/* * Bindows 1.01 * http://www.bindows.net/ * Copyright (c) 2003-2004 MB Technologies * * Bindows(tm) belongs to MB Technologies (Georgia, USA). All rights reserved. * You are not allowed to copy or modify this code. Commercial use requires * license. */function BiDataSet(sName){    BiEventTarget.call(this);    if (sName)        this._name = sName;    this._tables = [];    this._tablesByName = {    };}_p = BiDataSet.prototype = new BiEventTarget;_p._className = "BiDataSet";_p._name = "Unnamed Data Set";_p._dataReady = true;BiDataSet.prototype.getTables = function(){    return this._tables;} ;BiDataSet.prototype.getName = function(){    return this._name;} ;BiDataSet.prototype.getDataReady = function(){    return this._dataReady;} ;_p.getTableByName = function(s){    return this._tablesByName[String(s).toLowerCase()];} ;_p.addTable = function(oTable, oBefore){    if (oBefore == null)        this._tables.push(oTable);    else        this._tables.insertBefore(oTable, oBefore);    var tName = oTable.getName();    if (!tName)        tName = oTable._name = String(this._tables.indexOf(oTable));    this._tablesByName[tName.toLowerCase()] = oTable;    if (oTable._dataSet)        oTable._dataSet.removeTable(oTable);    oTable._dataSet = this;};_p.removeTable = function(oTable){    this._tables.remove(oTable);    delete this._tablesByName[oTable.getName().toLowerCase()];    oTable._dataSet = null;    return oTable;};_p.dispose = function(){    if (this.getDisposed())        return;    BiObject.prototype.dispose.call(this);    for (var i = this._tables.length - 1; i >= 0; i--)    {        this._tables[i].dispose();        this._tables[i] = null;    }    this._tables = null;    for (i in this._tablesByName)    {        this._tablesByName[i] = null;    }    this._tablesByName = null;};function BiDataTable(sName){    BiObject.call(this);    if (sName)        this._name = sName;    this._columns = [];    this._rows = [];    this._columnsByName = {    };}_p = BiDataTable.prototype = new BiObject;_p._className = "BiDataTable";_p._name = null;_p._dataSet = null;BiDataTable.prototype.getName = function(){    return this._name;} ;BiDataTable.prototype.getDataSet = function(){    return this._dataSet;} ;BiDataTable.prototype.getColumns = function(){    return this._columns;} ;BiDataTable.prototype.getRows = function(){    return this._rows;} ;_p.getColumnByName = function(s){    return this._columnsByName[String(s).toLowerCase()];} ;_p.addRow = function(oRow, oBefore){    if (oRow == null)        this._rows.push(oRow);    else        this._rows.insertBefore(oRow, oBefore);    if (oRow._table)        oRow._table.removeRow(oRow);    oRow._table = this;};_p.removeRow = function(oRow){    this._rows.remove(oRow);    oRow._table = null;    return oRow;};_p.addColumn = function(oColumn, oBefore){    if (oBefore == null)    {        this._columns.push(oColumn);        oColumn._index = this._columns.length - 1;    }    else    {        this._columns.insertBefore(oColumn, oBefore);        for (var i = 0; i < this._columns.length; i++)            this._columns[i]._index = i;    }    var cName = oColumn.getName();    if (!cName)        cName = oColumn._name = String(this._columns.indexOf(oColumn));    this._columnsByName[cName.toLowerCase()] = oColumn;    if (oColumn._table)        oColumn._table.removeColumn(oColumn);    oColumn._table = this;};_p.removeColumn = function(oColumn){    this._columns.remove(oColumn);    oColumn._index = null;    for (var i = 0; i < this._columns.length; i++)        this._columns[i]._index = i;    delete this._columnsByName[oColumn.getName().toLowerCase()];    oColumn._table = null;    return oColumn;};_p.dispose = function(){    if (this.getDisposed())        return;    BiObject.prototype.dispose.call(this);    for (var i = this._columns.length - 1; i >= 0; i--)    {        this._columns[i].dispose();        this._columns[i] = null;    }    this._columns = null;    for (var i = this._rows.length - 1; i >= 0; i--)    {        this._rows[i].dispose();        this._rows[i] = null;    }    this._rows = null;    for (var i in this._columnsByName)        this._columnsByName[i] = null;    this._columnsByName = null;    this._dataSet = null;};_p.getDataReady = function(){    return this._dataSet ? this._dataSet.getDataReady() : false;} ;function BiDataColumn(sName){    BiObject.call(this);    if (sName)        this._name = sName;}_p = BiDataColumn.prototype = new BiObject;_p._className = "BiDataColumn";_p._name = null;_p._table = null;_p._dataType = "string";_p._defaultValue = null;BiDataColumn.prototype.getIndex = function(){    return this._index;} ;BiDataColumn.prototype.getName = function(){    return this._name;} ;BiDataColumn.prototype.getTable = function(){    return this._table;} ;BiDataColumn.prototype.getDataType = function(){    return this._dataType;} ;BiDataColumn.prototype.setDataType = function(v){    this._dataType = v;} ;BiDataColumn.prototype.getDefaultValue = function(){    return this._defaultValue;} ;BiDataColumn.prototype.setDefaultValue = function(v){    this._defaultValue = v;} ;_p.dispose = function(){    if (this.getDisposed())        return;    BiObject.prototype.dispose.call(this);    this._table = null;};function BiDataRow(){    BiObject.call(this);}_p = BiDataRow.prototype = new BiObject;_p._className = "BiDataRow";_p._table = null;BiDataRow.prototype.getTable = function(){    return this._table;} ;_p.dispose = function(){    if (this.getDisposed())        return;    BiObject.prototype.dispose.call(this);    this._table = null;};_p.getValueByIndex = function(){    return null;} ;_p.getValueByName = function(){    return null;} ;function BiXsTypeConverter(){    BiObject.call(this);}_p = BiXsTypeConverter.prototype = new BiObject;_p._className = "BiXsTypeConverter";BiXsTypeConverter._types = {    "negativeInteger": 0, "unsignedShort": 0,    "unsignedByte": 0, "unsignedLong": 0, "unsignedInt": 0,    "decimal": 0,         "boolean": 0,          "integer": 0,      "double": 0,       "float": 0,    "short": 0,           "byte": 0,             "long": 0,         "int": 0,          "QName": 1,    "string": 1,          "normalizedString": 2, "dateTime": 3,     "date": 4,         "time": 5};BiXsTypeConverter.getJsType = function(sXsType){    switch (BiXsTypeConverter._types[sXsType])    {        case 0:            return Number;        case 1:        case 2:            return String;        case 3:        case 4:        case 5:            return Date;    }    return String;};BiXsTypeConverter.getJsTypeName = function(sXsType){    switch (BiXsTypeConverter._types[sXsType])    {        case 0:            return "number";        case 1:        case 2:            return "string";        case 3:        case 4:        case 5:            return "date";    }    return "string";};BiXsTypeConverter.getJsValue = function(sValue, sXsType){    if (sValue == null)    {        if (BiXsTypeConverter._types[sXsType] == null || BiXsTypeConverter._types[sXsType] == 1)            return "";        return null;    }    switch (BiXsTypeConverter._types[sXsType])    {        case 0:        if (sValue == "INF")            return Infinity;        if (sValue == "-INF")            return -Infinity;        return Number(sValue);        case 1:        case 2:            return sValue;        case 3:            return BiXsTypeConverter.decodeIsoDateTime(sValue);        case 4:            return BiXsTypeConverter.decodeIsoDate(sValue);        case 5:            return BiXsTypeConverter.decodeIsoTime(sValue);    }    return sValue;};BiXsTypeConverter.decodeIsoDateTime = function(s){    var parts = s.split("T");    var d = new Date;    if (parts.length > 0)    {        BiXsTypeConverter._decodeIsoDate(d, parts[0]);        if (parts.length > 1)            BiXsTypeConverter._decodeIsoTime(d, parts[1]);    }    return d;};BiXsTypeConverter.decodeIsoDate = function(s){    var d = new Date;    BiXsTypeConverter._decodeIsoDate(d, s);    return d;};BiXsTypeConverter.decodeIsoTime = function(s){    var d = new Date;    BiXsTypeConverter._decodeIsoTime(d, s);    return d;};BiXsTypeConverter._decodeIsoDate = function(d, s){    d.setFullYear(s.substr(0, 4));    d.setMonth(s.substr(5, 2) - 1);    d.setDate(s.substr(8, 2));    s = s.substr(10);    var i = s.indexOf("+");    if (i < 0)        i = s.indexOf("-");    if (i > 0)        BiXsTypeConverter._applyTimeZone(d, s.substring(i));};BiXsTypeConverter._decodeIsoTime = function(d, s){    var i = s.indexOf("+");    if (i < 0)        i = s.indexOf("-");    if (i > 0)    {        var tzs = s.substring(i);        s = s.substring(0, i);    }    d.setHours(s.substr(0, 2));    d.setMinutes(s.substr(3, 2));    d.setSeconds(s.substr(6, 2));    var msi = s.indexOf(".");    if (msi > 0)        d.setMilliseconds(parseFloat("0." + s.substr(9)) * 1000);    BiXsTypeConverter._applyTimeZone(d, tzs);};BiXsTypeConverter._applyTimeZone = function(d, s){    var tzo = 0;    var parts = s.split(":");    if (parts.length > 0)        tzo += parts[0] * 60;    if (parts.length > 1)        tzo += (tzo < 0 ? -1 : 1) * Number(parts[1]);    d.setTime(d.getTime() - (tzo + d.getTimezoneOffset()) * 60000);};function BiXmlDataSet(oSource){    BiDataSet.call(this);    if (typeof oSource == "string" || oSource instanceof BiUri)        this.setUri(oSource);    else if (typeof oSource == "object")    {        this._uri = null;        this.fromXmlNode(oSource);        this._dataReady = true;    }}_p = BiXmlDataSet.prototype = new BiDataSet;_p._className = "BiXmlDataSet";_p._uri = null;_p._rootNode = null;BiXmlDataSet.encodeName = function(s){    return s.replace(/(^\d)|(_x)|[\s\W]/gi, BiXmlDataSet._encodeName);} ;BiXmlDataSet._encodeName = function(s){    if (s == "_x" || s == "_X")        return "_x005F" + s;    var cc = s.charCodeAt(0);    var s2 = "";    if (cc < 0x10)        s2 = "000";    else if (cc < 0x100)        s2 = "00";    else if (cc < 0x1000)        s2 = "0";    return "_x" + s2 + cc.toString(16).toUpperCase() + "_";};BiXmlDataSet.decodeName = function(s){    return s.replace(/_x([0-9a-f]+)_/gi, BiXmlDataSet._decodeName);} ;BiXmlDataSet._decodeName = function(s0, s1){    return String.fromCharCode(parseInt(s1, 16));} ;_p.setUri = function(oUri){    if (this._xmlLoader)        this._xmlLoader.dispose();    if (oUri instanceof BiUri)        this._uri = oUri;    else        this._uri = new BiUri(application.getAdfPath(), oUri);    this._dataReady = false;    this._xmlLoader = new BiXmlLoader;    this._xmlLoader.setAsync(true);    this._xmlLoader.addEventListener("load", this._onXmlLoad, this);    this._xmlLoader.load(this._uri);};BiXmlDataSet.prototype.getUri = function(){    return this._uri;} ;_p.setRootNode = function(oNode){    this.fromNone(oNode);} ;BiXmlDataSet.prototype.getRootNode = function(){    return this._rootNode;} ;

⌨️ 快捷键说明

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