/** * Template for FirstClass JavaScript files */ /** * FirstClass Common Code, required in every file */ if (typeof FIRSTCLASS == "undefined" || !FIRSTCLASS) { /** * The FIRSTCLASS global namespace object. If FIRSTCLASS is already defined, the * existing FIRSTCLASS object will not be overwritten so that defined * namespaces are preserved. * @class FIRSTCLASS * @static */ var FIRSTCLASS = {}; } if (typeof FIRSTCLASS.util == "undefined" || !FIRSTCLASS.util) { /** * setting up the namespace for this class, if it is not already set up */ FIRSTCLASS.util = {}; } FIRSTCLASS.util.Schema = function() { // Constructor, do any constructor-type business here }; /** * private variables */ FIRSTCLASS.util.Schema.prototype._schema = {}; /** * public methods */ FIRSTCLASS.util.Schema.prototype.setSchema = function(schemaObject) { this._schema = schemaObject; }; FIRSTCLASS.util.Schema.prototype.lookupColumnName = function(columnTitle) { for(var i = 0; i < this._schema.length; i++) { var record = this._schema[i]; if(record.title == columnTitle) { return record.name; } } }; FIRSTCLASS.util.Schema.prototype.lookupColumnType = function(columnTitle) { for(var i = 0; i < this._schema.length; i++) { var record = this._schema[i]; if(record.title == columnTitle) { return record.type; } } }; FIRSTCLASS.util.Schema.prototype.lookupColumnTitle = function(idx) { var record = this._schema[idx]; return record.title; }; FIRSTCLASS.util.Schema.prototype.lookupColumnTitleByID = function(id) { for(var i = 0; i < this._schema.length; i++) { var record = this._schema[i]; if(record.id == id) { return record.title; } } return ""; }; FIRSTCLASS.util.Schema.prototype.lookupColumnIDByIndex = function(idx) { var record = this._schema[idx]; return record.id; }; FIRSTCLASS.util.Schema.prototype.lookupColumnIDByTitle = function(columnTitle) { for(var i = 0; i < this._schema.length; i++) { var record = this._schema[i]; if(record.title == columnTitle) { return record.id; } } }; YAHOO.register("fcSchema", FIRSTCLASS.util.Schema, {version: "0.0.1", build: "1"});