This file is used in Dojo's back/fwd button management.
- - diff --git a/source/web/scripts/ajax/src/AdapterRegistry.js b/source/web/scripts/ajax/src/AdapterRegistry.js deleted file mode 100644 index 8e1e281724..0000000000 --- a/source/web/scripts/ajax/src/AdapterRegistry.js +++ /dev/null @@ -1,79 +0,0 @@ -dojo.provide("dojo.AdapterRegistry"); -dojo.require("dojo.lang.func"); - -dojo.AdapterRegistry = function(/*boolean, optional*/returnWrappers){ - // summary: - // A registry to make contextual calling/searching easier. - // description: - // Objects of this class keep list of arrays in the form [name, check, - // wrap, directReturn] that are used to determine what the contextual - // result of a set of checked arguments is. All check/wrap functions - // in this registry should be of the same arity. - this.pairs = []; - this.returnWrappers = returnWrappers || false; -} - -dojo.lang.extend(dojo.AdapterRegistry, { - register: function( /*string*/ name, /*function*/ check, /*function*/ wrap, - /*boolean, optional*/ directReturn, - /*boolean, optional*/ override){ - // summary: - // register a check function to determine if the wrap function or - // object gets selected - // name: a way to identify this matcher. - // check: - // a function that arguments are passed to from the adapter's - // match() function. The check function should return true if the - // given arguments are appropriate for the wrap function. - // directReturn: - // If directReturn is true, the value passed in for wrap will be - // returned instead of being called. Alternately, the - // AdapterRegistry can be set globally to "return not call" using - // the returnWrappers property. Either way, this behavior allows - // the registry to act as a "search" function instead of a - // function interception library. - // override: - // If override is given and true, the check function will be given - // highest priority. Otherwise, it will be the lowest priority - // adapter. - - var type = (override) ? "unshift" : "push"; - this.pairs[type]([name, check, wrap, directReturn]); - }, - - match: function(/* ... */){ - // summary: - // Find an adapter for the given arguments. If no suitable adapter - // is found, throws an exception. match() accepts any number of - // arguments, all of which are passed to all matching functions - // from the registered pairs. - for(var i = 0; i < this.pairs.length; i++){ - var pair = this.pairs[i]; - if(pair[1].apply(this, arguments)){ - if((pair[3])||(this.returnWrappers)){ - return pair[2]; - }else{ - return pair[2].apply(this, arguments); - } - } - } - throw new Error("No match found"); - // dojo.raise("No match found"); - }, - - unregister: function(name){ - // summary: Remove a named adapter from the registry - - // FIXME: this is kind of a dumb way to handle this. On a large - // registry this will be slow-ish and we can use the name as a lookup - // should we choose to trade memory for speed. - for(var i = 0; i < this.pairs.length; i++){ - var pair = this.pairs[i]; - if(pair[0] == name){ - this.pairs.splice(i, 1); - return true; - } - } - return false; - } -}); diff --git a/source/web/scripts/ajax/src/Deferred.js b/source/web/scripts/ajax/src/Deferred.js deleted file mode 100644 index 6f99fe8767..0000000000 --- a/source/web/scripts/ajax/src/Deferred.js +++ /dev/null @@ -1,305 +0,0 @@ -dojo.provide("dojo.Deferred"); -dojo.require("dojo.lang.func"); - -dojo.Deferred = function(/* optional */ canceller){ - /* - NOTE: this namespace and documentation are imported wholesale - from MochiKit - - Encapsulates a sequence of callbacks in response to a value that - may not yet be available. This is modeled after the Deferred class - from Twisted- * var a = dataProvider.newItem("kermit"); - * var b = dataProvider.newItem("elmo"); - * var c = dataProvider.newItem("grover"); - * var array = new Array(a, b, c); - * array.sort(dojo.data.Item.compare); - *- */ - dojo.lang.assertType(itemOne, dojo.data.Item); - if (!dojo.lang.isOfType(itemTwo, dojo.data.Item)) { - return -1; - } - var nameOne = itemOne.getName(); - var nameTwo = itemTwo.getName(); - if (nameOne == nameTwo) { - var attributeArrayOne = itemOne.getAttributes(); - var attributeArrayTwo = itemTwo.getAttributes(); - if (attributeArrayOne.length != attributeArrayTwo.length) { - if (attributeArrayOne.length > attributeArrayTwo.length) { - return 1; - } else { - return -1; - } - } - for (var i in attributeArrayOne) { - var attribute = attributeArrayOne[i]; - var arrayOfValuesOne = itemOne.getValues(attribute); - var arrayOfValuesTwo = itemTwo.getValues(attribute); - dojo.lang.assert(arrayOfValuesOne && (arrayOfValuesOne.length > 0)); - if (!arrayOfValuesTwo) { - return 1; - } - if (arrayOfValuesOne.length != arrayOfValuesTwo.length) { - if (arrayOfValuesOne.length > arrayOfValuesTwo.length) { - return 1; - } else { - return -1; - } - } - for (var j in arrayOfValuesOne) { - var value = arrayOfValuesOne[j]; - if (!itemTwo.hasAttributeValue(value)) { - return 1; - } - } - return 0; - } - } else { - if (nameOne > nameTwo) { - return 1; - } else { - return -1; // 0, 1, or -1 - } - } -}; - -// ------------------------------------------------------------------- -// Public instance methods -// ------------------------------------------------------------------- -dojo.data.Item.prototype.toString = function() { - /** - * Returns a simple string representation of the item. - */ - var arrayOfStrings = []; - var attributes = this.getAttributes(); - for (var i in attributes) { - var attribute = attributes[i]; - var arrayOfValues = this.getValues(attribute); - var valueString; - if (arrayOfValues.length == 1) { - valueString = arrayOfValues[0]; - } else { - valueString = '['; - valueString += arrayOfValues.join(', '); - valueString += ']'; - } - arrayOfStrings.push(' ' + attribute + ': ' + valueString); - } - var returnString = '{ '; - returnString += arrayOfStrings.join(',\n'); - returnString += ' }'; - return returnString; // string -}; - -dojo.data.Item.prototype.compare = function(/* dojo.data.Item */ otherItem) { - /** - * summary: Compares this Item to another Item, and returns 0, 1, or -1. - */ - return dojo.data.Item.compare(this, otherItem); // 0, 1, or -1 -}; - -dojo.data.Item.prototype.isEqual = function(/* dojo.data.Item */ otherItem) { - /** - * summary: Returns true if this Item is equal to the otherItem, or false otherwise. - */ - return (this.compare(otherItem) == 0); // boolean -}; - -dojo.data.Item.prototype.getName = function() { - return this.get('name'); -}; - -dojo.data.Item.prototype.get = function(/* string or dojo.data.Attribute */ attributeId) { - /** - * summary: Returns a single literal value, like "foo" or 33. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId]; - if (dojo.lang.isUndefined(literalOrValueOrArray)) { - return null; // null - } - if (literalOrValueOrArray instanceof dojo.data.Value) { - return literalOrValueOrArray.getValue(); // literal - } - if (dojo.lang.isArray(literalOrValueOrArray)) { - var dojoDataValue = literalOrValueOrArray[0]; - return dojoDataValue.getValue(); // literal - } - return literalOrValueOrArray; // literal -}; - -dojo.data.Item.prototype.getValue = function(/* string or dojo.data.Attribute */ attributeId) { - /** - * summary: Returns a single instance of dojo.data.Value. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId]; - if (dojo.lang.isUndefined(literalOrValueOrArray)) { - return null; // null - } - if (literalOrValueOrArray instanceof dojo.data.Value) { - return literalOrValueOrArray; // dojo.data.Value - } - if (dojo.lang.isArray(literalOrValueOrArray)) { - var dojoDataValue = literalOrValueOrArray[0]; - return dojoDataValue; // dojo.data.Value - } - var literal = literalOrValueOrArray; - dojoDataValue = new dojo.data.Value(literal); - this._dictionaryOfAttributeValues[attributeId] = dojoDataValue; - return dojoDataValue; // dojo.data.Value -}; - -dojo.data.Item.prototype.getValues = function(/* string or dojo.data.Attribute */ attributeId) { - /** - * summary: Returns an array of dojo.data.Value objects. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId]; - if (dojo.lang.isUndefined(literalOrValueOrArray)) { - return null; // null - } - if (literalOrValueOrArray instanceof dojo.data.Value) { - var array = [literalOrValueOrArray]; - this._dictionaryOfAttributeValues[attributeId] = array; - return array; // Array - } - if (dojo.lang.isArray(literalOrValueOrArray)) { - return literalOrValueOrArray; // Array - } - var literal = literalOrValueOrArray; - var dojoDataValue = new dojo.data.Value(literal); - array = [dojoDataValue]; - this._dictionaryOfAttributeValues[attributeId] = array; - return array; // Array -}; - -dojo.data.Item.prototype.load = function(/* string or dojo.data.Attribute */ attributeId, /* anything */ value) { - /** - * summary: - * Used for loading an attribute value into an item when - * the item is first being loaded into memory from some - * data store (such as a file). - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - this._dataProvider.registerAttribute(attributeId); - var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId]; - if (dojo.lang.isUndefined(literalOrValueOrArray)) { - this._dictionaryOfAttributeValues[attributeId] = value; - return; - } - if (!(value instanceof dojo.data.Value)) { - value = new dojo.data.Value(value); - } - if (literalOrValueOrArray instanceof dojo.data.Value) { - var array = [literalOrValueOrArray, value]; - this._dictionaryOfAttributeValues[attributeId] = array; - return; - } - if (dojo.lang.isArray(literalOrValueOrArray)) { - literalOrValueOrArray.push(value); - return; - } - var literal = literalOrValueOrArray; - var dojoDataValue = new dojo.data.Value(literal); - array = [dojoDataValue, value]; - this._dictionaryOfAttributeValues[attributeId] = array; -}; - -dojo.data.Item.prototype.set = function(/* string or dojo.data.Attribute */ attributeId, /* anything */ value) { - /** - * summary: - * Used for setting an attribute value as a result of a - * user action. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - this._dataProvider.registerAttribute(attributeId); - this._dictionaryOfAttributeValues[attributeId] = value; - this._dataProvider.noteChange(this, attributeId, value); -}; - -dojo.data.Item.prototype.setValue = function(/* string or dojo.data.Attribute */ attributeId, /* dojo.data.Value */ value) { - this.set(attributeId, value); -}; - -dojo.data.Item.prototype.addValue = function(/* string or dojo.data.Attribute */ attributeId, /* anything */ value) { - /** - * summary: - * Used for adding an attribute value as a result of a - * user action. - */ - this.load(attributeId, value); - this._dataProvider.noteChange(this, attributeId, value); -}; - -dojo.data.Item.prototype.setValues = function(/* string or dojo.data.Attribute */ attributeId, /* Array */ arrayOfValues) { - /** - * summary: - * Used for setting an array of attribute values as a result of a - * user action. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - dojo.lang.assertType(arrayOfValues, Array); - this._dataProvider.registerAttribute(attributeId); - var finalArray = []; - this._dictionaryOfAttributeValues[attributeId] = finalArray; - for (var i in arrayOfValues) { - var value = arrayOfValues[i]; - if (!(value instanceof dojo.data.Value)) { - value = new dojo.data.Value(value); - } - finalArray.push(value); - this._dataProvider.noteChange(this, attributeId, value); - } -}; - -dojo.data.Item.prototype.getAttributes = function() { - /** - * summary: - * Returns an array containing all of the attributes for which - * this item has attribute values. - */ - var arrayOfAttributes = []; - for (var key in this._dictionaryOfAttributeValues) { - arrayOfAttributes.push(this._dataProvider.getAttribute(key)); - } - return arrayOfAttributes; // Array -}; - -dojo.data.Item.prototype.hasAttribute = function(/* string or dojo.data.Attribute */ attributeId) { - /** - * summary: Returns true if the given attribute of the item has been assigned any value. - */ - // dojo.lang.assertType(attributeId, [String, dojo.data.Attribute]); - return (attributeId in this._dictionaryOfAttributeValues); // boolean -}; - -dojo.data.Item.prototype.hasAttributeValue = function(/* string or dojo.data.Attribute */ attributeId, /* anything */ value) { - /** - * summary: Returns true if the given attribute of the item has been assigned the given value. - */ - var arrayOfValues = this.getValues(attributeId); - for (var i in arrayOfValues) { - var candidateValue = arrayOfValues[i]; - if (candidateValue.isEqual(value)) { - return true; // boolean - } - } - return false; // boolean -}; - - diff --git a/source/web/scripts/ajax/src/data/Kind.js b/source/web/scripts/ajax/src/data/Kind.js deleted file mode 100644 index b7f26c54ae..0000000000 --- a/source/web/scripts/ajax/src/data/Kind.js +++ /dev/null @@ -1,18 +0,0 @@ -dojo.provide("dojo.data.Kind"); -dojo.require("dojo.data.Item"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.Kind = function(/* dojo.data.provider.Base */ dataProvider) { - /** - * summary: - * A Kind represents a kind of item. In the dojo data model - * the item Snoopy might belong to the 'kind' Dog, where in - * a Java program the object Snoopy would belong to the 'class' - * Dog, and in MySQL the record for Snoopy would be in the - * table Dog. - */ - dojo.data.Item.call(this, dataProvider); -}; -dojo.inherits(dojo.data.Kind, dojo.data.Item); diff --git a/source/web/scripts/ajax/src/data/Observable.js b/source/web/scripts/ajax/src/data/Observable.js deleted file mode 100644 index 327f00bab6..0000000000 --- a/source/web/scripts/ajax/src/data/Observable.js +++ /dev/null @@ -1,49 +0,0 @@ -dojo.provide("dojo.data.Observable"); -dojo.require("dojo.lang.common"); -dojo.require("dojo.lang.assert"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.Observable = function() { -}; - -// ------------------------------------------------------------------- -// Public instance methods -// ------------------------------------------------------------------- -dojo.data.Observable.prototype.addObserver = function(/* object */ observer) { - /** - * summary: Registers an object as an observer of this item, - * so that the object will be notified when the item changes. - */ - dojo.lang.assertType(observer, Object); - dojo.lang.assertType(observer.observedObjectHasChanged, Function); - if (!this._arrayOfObservers) { - this._arrayOfObservers = []; - } - if (!dojo.lang.inArray(this._arrayOfObservers, observer)) { - this._arrayOfObservers.push(observer); - } -}; - -dojo.data.Observable.prototype.removeObserver = function(/* object */ observer) { - /** - * summary: Removes the observer registration for a previously - * registered object. - */ - if (!this._arrayOfObservers) { - return; - } - var index = dojo.lang.indexOf(this._arrayOfObservers, observer); - if (index != -1) { - this._arrayOfObservers.splice(index, 1); - } -}; - -dojo.data.Observable.prototype.getObservers = function() { - /** - * summary: Returns an array with all the observers of this item. - */ - return this._arrayOfObservers; // Array or undefined -}; - diff --git a/source/web/scripts/ajax/src/data/ResultSet.js b/source/web/scripts/ajax/src/data/ResultSet.js deleted file mode 100644 index a5839971e2..0000000000 --- a/source/web/scripts/ajax/src/data/ResultSet.js +++ /dev/null @@ -1,60 +0,0 @@ -dojo.provide("dojo.data.ResultSet"); -dojo.require("dojo.lang.assert"); -dojo.require("dojo.collections.Collections"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.ResultSet = function(/* dojo.data.provider.Base */ dataProvider, /* Array */ arrayOfItems) { - /** - * summary: - * A ResultSet holds a collection of Items. A data provider - * returns a ResultSet in reponse to a query. - * (The name "Result Set" comes from the MySQL terminology.) - */ - dojo.lang.assertType(dataProvider, dojo.data.provider.Base, {optional: true}); - dojo.lang.assertType(arrayOfItems, Array, {optional: true}); - dojo.data.Observable.call(this); - this._dataProvider = dataProvider; - this._arrayOfItems = []; - if (arrayOfItems) { - this._arrayOfItems = arrayOfItems; - } -}; -dojo.inherits(dojo.data.ResultSet, dojo.data.Observable); - -// ------------------------------------------------------------------- -// Public instance methods -// ------------------------------------------------------------------- -dojo.data.ResultSet.prototype.toString = function() { - var returnString = this._arrayOfItems.join(', '); - return returnString; // string -}; - -dojo.data.ResultSet.prototype.toArray = function() { - return this._arrayOfItems; // Array -}; - -dojo.data.ResultSet.prototype.getIterator = function() { - return new dojo.collections.Iterator(this._arrayOfItems); -}; - -dojo.data.ResultSet.prototype.getLength = function() { - return this._arrayOfItems.length; // integer -}; - -dojo.data.ResultSet.prototype.getItemAt = function(/* numeric */ index) { - return this._arrayOfItems[index]; -}; - -dojo.data.ResultSet.prototype.indexOf = function(/* dojo.data.Item */ item) { - return dojo.lang.indexOf(this._arrayOfItems, item); // integer -}; - -dojo.data.ResultSet.prototype.contains = function(/* dojo.data.Item */ item) { - return dojo.lang.inArray(this._arrayOfItems, item); // boolean -}; - -dojo.data.ResultSet.prototype.getDataProvider = function() { - return this._dataProvider; // dojo.data.provider.Base -}; \ No newline at end of file diff --git a/source/web/scripts/ajax/src/data/SimpleStore.js b/source/web/scripts/ajax/src/data/SimpleStore.js deleted file mode 100644 index 29d830fd77..0000000000 --- a/source/web/scripts/ajax/src/data/SimpleStore.js +++ /dev/null @@ -1,194 +0,0 @@ -dojo.provide("dojo.data.SimpleStore"); -dojo.require("dojo.lang"); - -dojo.require("dojo.experimental"); -dojo.experimental("dojo.data.SimpleStore"); - -/* SimpleStore - * Designed to be a simple store of data with access methods... - * specifically to be mixed into other objects (such as widgets). - * - * This *might* be better in collections, we'll see. - */ -dojo.data.SimpleStore = function(/* array? */json){ - // summary - // Data Store with accessor methods. - var data = []; - this.keyField = "Id"; - - this.get = function(){ - // summary - // Get the internal data array, should not be used. - return data; // array - }; - this.getByKey = function(/* string */key){ - // summary - // Find the internal data object by key. - for(var i=0; i
- * [["Title", "Year", "Producer"] - * ["Alien", "1979", "Ridley Scott"], - * ["Blade Runner", "1982", "Ridley Scott"]] - *- */ - dojo.lang.assertType(csvFileContents, String); - - var lineEndingCharacters = new RegExp("\r\n|\n|\r"); - var leadingWhiteSpaceCharacters = new RegExp("^\\s+",'g'); - var trailingWhiteSpaceCharacters = new RegExp("\\s+$",'g'); - var doubleQuotes = new RegExp('""','g'); - var arrayOfOutputRecords = []; - - var arrayOfInputLines = csvFileContents.split(lineEndingCharacters); - for (var i in arrayOfInputLines) { - var singleLine = arrayOfInputLines[i]; - if (singleLine.length > 0) { - var listOfFields = singleLine.split(','); - var j = 0; - while (j < listOfFields.length) { - var space_field_space = listOfFields[j]; - var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, ''); // trim leading whitespace - var field = field_space.replace(trailingWhiteSpaceCharacters, ''); // trim trailing whitespace - var firstChar = field.charAt(0); - var lastChar = field.charAt(field.length - 1); - var secondToLastChar = field.charAt(field.length - 2); - var thirdToLastChar = field.charAt(field.length - 3); - if ((firstChar == '"') && - ((lastChar != '"') || - ((lastChar == '"') && (secondToLastChar == '"') && (thirdToLastChar != '"')) )) { - if (j+1 === listOfFields.length) { - // alert("The last field in record " + i + " is corrupted:\n" + field); - return null; - } - var nextField = listOfFields[j+1]; - listOfFields[j] = field_space + ',' + nextField; - listOfFields.splice(j+1, 1); // delete element [j+1] from the list - } else { - if ((firstChar == '"') && (lastChar == '"')) { - field = field.slice(1, (field.length - 1)); // trim the " characters off the ends - field = field.replace(doubleQuotes, '"'); // replace "" with " - } - listOfFields[j] = field; - j += 1; - } - } - arrayOfOutputRecords.push(listOfFields); - } - } - return arrayOfOutputRecords; // Array - }; - - this.loadDataProviderFromFileContents = function(/* dojo.data.provider.Base */ dataProvider, /* string */ csvFileContents) { - dojo.lang.assertType(dataProvider, dojo.data.provider.Base); - dojo.lang.assertType(csvFileContents, String); - var arrayOfArrays = this.getArrayStructureFromCsvFileContents(csvFileContents); - if (arrayOfArrays) { - var arrayOfKeys = arrayOfArrays[0]; - for (var i = 1; i < arrayOfArrays.length; ++i) { - var row = arrayOfArrays[i]; - var item = dataProvider.getNewItemToLoad(); - for (var j in row) { - var value = row[j]; - var key = arrayOfKeys[j]; - item.load(key, value); - } - } - } - }; - - this.getCsvStringFromResultSet = function(/* dojo.data.ResultSet */ resultSet) { - dojo.unimplemented('dojo.data.format.Csv.getCsvStringFromResultSet'); - var csvString = null; - return csvString; // String - }; - -}(); diff --git a/source/web/scripts/ajax/src/data/format/Json.js b/source/web/scripts/ajax/src/data/format/Json.js deleted file mode 100644 index 16e3d07863..0000000000 --- a/source/web/scripts/ajax/src/data/format/Json.js +++ /dev/null @@ -1,93 +0,0 @@ -dojo.provide("dojo.data.format.Json"); -dojo.require("dojo.lang.assert"); - -dojo.data.format.Json = new function() { - - // ------------------------------------------------------------------- - // Public functions - // ------------------------------------------------------------------- - this.loadDataProviderFromFileContents = function(/* dojo.data.provider.Base */ dataProvider, /* string */ jsonFileContents) { - dojo.lang.assertType(dataProvider, dojo.data.provider.Base); - dojo.lang.assertType(jsonFileContents, String); - var arrayOfJsonData = eval("(" + jsonFileContents + ")"); - this.loadDataProviderFromArrayOfJsonData(dataProvider, arrayOfJsonData); - }; - - this.loadDataProviderFromArrayOfJsonData = function(/* dojo.data.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) { - dojo.lang.assertType(arrayOfJsonData, Array, {optional: true}); - if (arrayOfJsonData && (arrayOfJsonData.length > 0)) { - var firstRow = arrayOfJsonData[0]; - dojo.lang.assertType(firstRow, [Array, "pureobject"]); - if (dojo.lang.isArray(firstRow)) { - _loadDataProviderFromArrayOfArrays(dataProvider, arrayOfJsonData); - } else { - dojo.lang.assertType(firstRow, "pureobject"); - _loadDataProviderFromArrayOfObjects(dataProvider, arrayOfJsonData); - } - } - }; - - this.getJsonStringFromResultSet = function(/* dojo.data.ResultSet */ resultSet) { - dojo.unimplemented('dojo.data.format.Json.getJsonStringFromResultSet'); - var jsonString = null; - return jsonString; // String - }; - - // ------------------------------------------------------------------- - // Private functions - // ------------------------------------------------------------------- - function _loadDataProviderFromArrayOfArrays(/* dojo.data.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) { - /** - * Example: - * var arrayOfJsonStates = [ - * [ "abbr", "population", "name" ] - * [ "WA", 5894121, "Washington" ], - * [ "WV", 1808344, "West Virginia" ], - * [ "WI", 5453896, "Wisconsin" ], - * [ "WY", 493782, "Wyoming" ] ]; - * this._loadFromArrayOfArrays(arrayOfJsonStates); - */ - var arrayOfKeys = arrayOfJsonData[0]; - for (var i = 1; i < arrayOfJsonData.length; ++i) { - var row = arrayOfJsonData[i]; - var item = dataProvider.getNewItemToLoad(); - for (var j in row) { - var value = row[j]; - var key = arrayOfKeys[j]; - item.load(key, value); - } - } - } - - function _loadDataProviderFromArrayOfObjects(/* dojo.data.provider.Base */ dataProvider, /* Array */ arrayOfJsonData) { - /** - * Example: - * var arrayOfJsonStates = [ - * { abbr: "WA", name: "Washington" }, - * { abbr: "WV", name: "West Virginia" }, - * { abbr: "WI", name: "Wisconsin", song: "On, Wisconsin!" }, - * { abbr: "WY", name: "Wyoming", cities: ["Lander", "Cheyenne", "Laramie"] } ]; - * this._loadFromArrayOfArrays(arrayOfJsonStates); - */ - // dojo.debug("_loadDataProviderFromArrayOfObjects"); - for (var i in arrayOfJsonData) { - var row = arrayOfJsonData[i]; - var item = dataProvider.getNewItemToLoad(); - for (var key in row) { - var value = row[key]; - if (dojo.lang.isArray(value)) { - var arrayOfValues = value; - for (var j in arrayOfValues) { - value = arrayOfValues[j]; - item.load(key, value); - // dojo.debug("loaded: " + key + " = " + value); - } - } else { - item.load(key, value); - } - } - } - } - -}(); - diff --git a/source/web/scripts/ajax/src/data/provider/Base.js b/source/web/scripts/ajax/src/data/provider/Base.js deleted file mode 100644 index 2dd45ce85e..0000000000 --- a/source/web/scripts/ajax/src/data/provider/Base.js +++ /dev/null @@ -1,173 +0,0 @@ -dojo.provide("dojo.data.provider.Base"); -dojo.require("dojo.lang.assert"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.provider.Base = function() { - /** - * summary: - * A Data Provider serves as a connection to some data source, - * like a relational database. This data provider Base class - * serves as an abstract superclass for other data provider - * classes. - */ - this._countOfNestedTransactions = 0; - this._changesInCurrentTransaction = null; -}; - -// ------------------------------------------------------------------- -// Public instance methods -// ------------------------------------------------------------------- -dojo.data.provider.Base.prototype.beginTransaction = function() { - /** - * Marks the beginning of a transaction. - * - * Each time you call beginTransaction() you open a new transaction, - * which you need to close later using endTransaction(). Transactions - * may be nested, but the beginTransaction and endTransaction calls - * always need to come in pairs. - */ - if (this._countOfNestedTransactions === 0) { - this._changesInCurrentTransaction = []; - } - this._countOfNestedTransactions += 1; -}; - -dojo.data.provider.Base.prototype.endTransaction = function() { - /** - * Marks the end of a transaction. - */ - this._countOfNestedTransactions -= 1; - dojo.lang.assert(this._countOfNestedTransactions >= 0); - - if (this._countOfNestedTransactions === 0) { - var listOfChangesMade = this._saveChanges(); - this._changesInCurrentTransaction = null; - if (listOfChangesMade.length > 0) { - // dojo.debug("endTransaction: " + listOfChangesMade.length + " changes made"); - this._notifyObserversOfChanges(listOfChangesMade); - } - } -}; - -dojo.data.provider.Base.prototype.getNewItemToLoad = function() { - return this._newItem(); // dojo.data.Item -}; - -dojo.data.provider.Base.prototype.newItem = function(/* string */ itemName) { - /** - * Creates a new item. - */ - dojo.lang.assertType(itemName, String, {optional: true}); - var item = this._newItem(); - if (itemName) { - item.set('name', itemName); - } - return item; // dojo.data.Item -}; - -dojo.data.provider.Base.prototype.newAttribute = function(/* string */ attributeId) { - /** - * Creates a new attribute. - */ - dojo.lang.assertType(attributeId, String, {optional: true}); - var attribute = this._newAttribute(attributeId); - return attribute; // dojo.data.Attribute -}; - -dojo.data.provider.Base.prototype.getAttribute = function(/* string */ attributeId) { - dojo.unimplemented('dojo.data.provider.Base'); - var attribute; - return attribute; // dojo.data.Attribute -}; - -dojo.data.provider.Base.prototype.getAttributes = function() { - dojo.unimplemented('dojo.data.provider.Base'); - return this._arrayOfAttributes; // Array -}; - -dojo.data.provider.Base.prototype.fetchArray = function() { - dojo.unimplemented('dojo.data.provider.Base'); - return []; // Array -}; - -dojo.data.provider.Base.prototype.fetchResultSet = function() { - dojo.unimplemented('dojo.data.provider.Base'); - var resultSet; - return resultSet; // dojo.data.ResultSet -}; - -dojo.data.provider.Base.prototype.noteChange = function(/* dojo.data.Item */ item, /* string or dojo.data.Attribute */ attribute, /* anything */ value) { - var change = {item: item, attribute: attribute, value: value}; - if (this._countOfNestedTransactions === 0) { - this.beginTransaction(); - this._changesInCurrentTransaction.push(change); - this.endTransaction(); - } else { - this._changesInCurrentTransaction.push(change); - } -}; - -dojo.data.provider.Base.prototype.addItemObserver = function(/* dojo.data.Item */ item, /* object */ observer) { - /** - * summary: Registers an object as an observer of an item, - * so that the object will be notified when the item changes. - */ - dojo.lang.assertType(item, dojo.data.Item); - item.addObserver(observer); -}; - -dojo.data.provider.Base.prototype.removeItemObserver = function(/* dojo.data.Item */ item, /* object */ observer) { - /** - * summary: Removes the observer registration for a previously - * registered object. - */ - dojo.lang.assertType(item, dojo.data.Item); - item.removeObserver(observer); -}; - -// ------------------------------------------------------------------- -// Private instance methods -// ------------------------------------------------------------------- -dojo.data.provider.Base.prototype._newItem = function() { - var item = new dojo.data.Item(this); - return item; // dojo.data.Item -}; - -dojo.data.provider.Base.prototype._newAttribute = function(/* String */ attributeId) { - var attribute = new dojo.data.Attribute(this); - return attribute; // dojo.data.Attribute -}; - -dojo.data.provider.Base.prototype._saveChanges = function() { - var arrayOfChangesMade = this._changesInCurrentTransaction; - return arrayOfChangesMade; // Array -}; - -dojo.data.provider.Base.prototype._notifyObserversOfChanges = function(/* Array */ arrayOfChanges) { - var arrayOfResultSets = this._getResultSets(); - for (var i in arrayOfChanges) { - var change = arrayOfChanges[i]; - var changedItem = change.item; - var arrayOfItemObservers = changedItem.getObservers(); - for (var j in arrayOfItemObservers) { - var observer = arrayOfItemObservers[j]; - observer.observedObjectHasChanged(changedItem, change); - } - for (var k in arrayOfResultSets) { - var resultSet = arrayOfResultSets[k]; - var arrayOfResultSetObservers = resultSet.getObservers(); - for (var m in arrayOfResultSetObservers) { - observer = arrayOfResultSetObservers[m]; - observer.observedObjectHasChanged(resultSet, change); - } - } - } -}; - -dojo.data.provider.Base.prototype._getResultSets = function() { - dojo.unimplemented('dojo.data.provider.Base'); - return []; // Array -}; - diff --git a/source/web/scripts/ajax/src/data/provider/Delicious.js b/source/web/scripts/ajax/src/data/provider/Delicious.js deleted file mode 100644 index 307b8e9207..0000000000 --- a/source/web/scripts/ajax/src/data/provider/Delicious.js +++ /dev/null @@ -1,75 +0,0 @@ -dojo.provide("dojo.data.provider.Delicious"); -dojo.require("dojo.data.provider.FlatFile"); -dojo.require("dojo.data.format.Json"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.provider.Delicious = function() { - /** - * summary: - * The Delicious Data Provider can be used to take data from - * del.icio.us and make it available as dojo.data.Items - * In order to use the Delicious Data Provider, you need - * to have loaded a script tag that looks like this: - * - */ - dojo.data.provider.FlatFile.call(this); - // Delicious = null; - if (Delicious && Delicious.posts) { - dojo.data.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts); - } else { - // document.write(""); - /* - document.write(""); - document.write(""); - document.write(""); - fetchComplete(); - */ - // dojo.debug("Delicious line 29: constructor"); - } - var u = this.registerAttribute('u'); - var d = this.registerAttribute('d'); - var t = this.registerAttribute('t'); - - u.load('name', 'Bookmark'); - d.load('name', 'Description'); - t.load('name', 'Tags'); - - u.load('type', 'String'); - d.load('type', 'String'); - t.load('type', 'String'); -}; -dojo.inherits(dojo.data.provider.Delicious, dojo.data.provider.FlatFile); - -/******************************************************************** - * FIXME: the rest of this is work in progress - * - -dojo.data.provider.Delicious.prototype.getNewItemToLoad = function() { - var newItem = this._newItem(); - this._currentArray.push(newItem); - return newItem; // dojo.data.Item -}; - -dojo.data.provider.Delicious.prototype.fetchArray = function(query) { - if (!query) { - query = "gumption"; - } - this._currentArray = []; - alert("Delicious line 60: loadDataProviderFromArrayOfJsonData"); - alert("Delicious line 61: " + dojo); - var sourceUrl = "http://del.icio.us/feeds/json/" + query + "?count=8"; - document.write(""); - document.write(""); - document.write(""); - alert("line 66"); - dojo.data.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts); - return this._currentArray; // Array -}; - -callMe = function() { - alert("callMe!"); -}; - -*/ diff --git a/source/web/scripts/ajax/src/data/provider/FlatFile.js b/source/web/scripts/ajax/src/data/provider/FlatFile.js deleted file mode 100644 index 23b0b395af..0000000000 --- a/source/web/scripts/ajax/src/data/provider/FlatFile.js +++ /dev/null @@ -1,143 +0,0 @@ -dojo.provide("dojo.data.provider.FlatFile"); -dojo.require("dojo.data.provider.Base"); -dojo.require("dojo.data.Item"); -dojo.require("dojo.data.Attribute"); -dojo.require("dojo.data.ResultSet"); -dojo.require("dojo.data.format.Json"); -dojo.require("dojo.data.format.Csv"); -dojo.require("dojo.lang.assert"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.provider.FlatFile = function(/* keywords */ keywordParameters) { - /** - * summary: - * A Json Data Provider knows how to read in simple JSON data - * tables and make their contents accessable as Items. - */ - dojo.lang.assertType(keywordParameters, "pureobject", {optional: true}); - dojo.data.provider.Base.call(this); - this._arrayOfItems = []; - this._resultSet = null; - this._dictionaryOfAttributes = {}; - - if (keywordParameters) { - var jsonObjects = keywordParameters["jsonObjects"]; - var jsonString = keywordParameters["jsonString"]; - var fileUrl = keywordParameters["url"]; - if (jsonObjects) { - dojo.data.format.Json.loadDataProviderFromArrayOfJsonData(this, jsonObjects); - } - if (jsonString) { - dojo.data.format.Json.loadDataProviderFromFileContents(this, jsonString); - } - if (fileUrl) { - var arrayOfParts = fileUrl.split('.'); - var lastPart = arrayOfParts[(arrayOfParts.length - 1)]; - var formatParser = null; - if (lastPart == "json") { - formatParser = dojo.data.format.Json; - } - if (lastPart == "csv") { - formatParser = dojo.data.format.Csv; - } - if (formatParser) { - var fileContents = dojo.hostenv.getText(fileUrl); - formatParser.loadDataProviderFromFileContents(this, fileContents); - } else { - dojo.lang.assert(false, "new dojo.data.provider.FlatFile({url: }) was passed a file without a .csv or .json suffix"); - } - } - } -}; -dojo.inherits(dojo.data.provider.FlatFile, dojo.data.provider.Base); - -// ------------------------------------------------------------------- -// Public instance methods -// ------------------------------------------------------------------- -dojo.data.provider.FlatFile.prototype.getProviderCapabilities = function(/* string */ keyword) { - dojo.lang.assertType(keyword, String, {optional: true}); - if (!this._ourCapabilities) { - this._ourCapabilities = { - transactions: false, - undo: false, - login: false, - versioning: false, - anonymousRead: true, - anonymousWrite: false, - permissions: false, - queries: false, - strongTyping: false, - datatypes: [String, Date, Number] - }; - } - if (keyword) { - return this._ourCapabilities[keyword]; - } else { - return this._ourCapabilities; - } -}; - -dojo.data.provider.FlatFile.prototype.registerAttribute = function(/* string or dojo.data.Attribute */ attributeId) { - var registeredAttribute = this.getAttribute(attributeId); - if (!registeredAttribute) { - var newAttribute = new dojo.data.Attribute(this, attributeId); - this._dictionaryOfAttributes[attributeId] = newAttribute; - registeredAttribute = newAttribute; - } - return registeredAttribute; // dojo.data.Attribute -}; - -dojo.data.provider.FlatFile.prototype.getAttribute = function(/* string or dojo.data.Attribute */ attributeId) { - var attribute = (this._dictionaryOfAttributes[attributeId] || null); - return attribute; // dojo.data.Attribute or null -}; - -dojo.data.provider.FlatFile.prototype.getAttributes = function() { - var arrayOfAttributes = []; - for (var key in this._dictionaryOfAttributes) { - var attribute = this._dictionaryOfAttributes[key]; - arrayOfAttributes.push(attribute); - } - return arrayOfAttributes; // Array -}; - -dojo.data.provider.FlatFile.prototype.fetchArray = function(query) { - /** - * summary: Returns an Array containing all of the Items. - */ - return this._arrayOfItems; // Array -}; - -dojo.data.provider.FlatFile.prototype.fetchResultSet = function(query) { - /** - * summary: Returns a ResultSet containing all of the Items. - */ - if (!this._resultSet) { - this._resultSet = new dojo.data.ResultSet(this, this.fetchArray(query)); - } - return this._resultSet; // dojo.data.ResultSet -}; - -// ------------------------------------------------------------------- -// Private instance methods -// ------------------------------------------------------------------- -dojo.data.provider.FlatFile.prototype._newItem = function() { - var item = new dojo.data.Item(this); - this._arrayOfItems.push(item); - return item; // dojo.data.Item -}; - -dojo.data.provider.FlatFile.prototype._newAttribute = function(/* String */ attributeId) { - dojo.lang.assertType(attributeId, String); - dojo.lang.assert(this.getAttribute(attributeId) === null); - var attribute = new dojo.data.Attribute(this, attributeId); - this._dictionaryOfAttributes[attributeId] = attribute; - return attribute; // dojo.data.Attribute -}; - -dojo.data.provider.Base.prototype._getResultSets = function() { - return [this._resultSet]; // Array -}; - diff --git a/source/web/scripts/ajax/src/data/provider/JotSpot.js b/source/web/scripts/ajax/src/data/provider/JotSpot.js deleted file mode 100644 index e5c7cc3989..0000000000 --- a/source/web/scripts/ajax/src/data/provider/JotSpot.js +++ /dev/null @@ -1,17 +0,0 @@ -dojo.provide("dojo.data.provider.JotSpot"); -dojo.require("dojo.data.provider.Base"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.provider.JotSpot = function() { - /** - * summary: - * A JotSpot Data Provider knows how to read data from a JotSpot data - * store and make the contents accessable as dojo.data.Items. - */ - dojo.unimplemented('dojo.data.provider.JotSpot'); -}; - -dojo.inherits(dojo.data.provider.JotSpot, dojo.data.provider.Base); - diff --git a/source/web/scripts/ajax/src/data/provider/MySql.js b/source/web/scripts/ajax/src/data/provider/MySql.js deleted file mode 100644 index 6b3036075d..0000000000 --- a/source/web/scripts/ajax/src/data/provider/MySql.js +++ /dev/null @@ -1,17 +0,0 @@ -dojo.provide("dojo.data.provider.MySql"); -dojo.require("dojo.data.provider.Base"); - -// ------------------------------------------------------------------- -// Constructor -// ------------------------------------------------------------------- -dojo.data.provider.MySql = function() { - /** - * summary: - * A MySql Data Provider knows how to connect to a MySQL database - * on a server and and make the content records available as - * dojo.data.Items. - */ - dojo.unimplemented('dojo.data.provider.MySql'); -}; - -dojo.inherits(dojo.data.provider.MySql, dojo.data.provider.Base); diff --git a/source/web/scripts/ajax/src/data/to_do.txt b/source/web/scripts/ajax/src/data/to_do.txt deleted file mode 100644 index 6e705fc6c3..0000000000 --- a/source/web/scripts/ajax/src/data/to_do.txt +++ /dev/null @@ -1,45 +0,0 @@ -Existing Features - * can import data from .json or .csv format files - * can import data from del.icio.us - * can create and modify data programmatically - * can bind data to dojo.widget.Chart - * can bind data to dojo.widget.SortableTable - * can bind one data set to multiple widgets - * notifications: widgets are notified when data changes - * notification available per-item or per-resultSet - * can create ad-hoc attributes - * attributes can be loosely-typed - * attributes can have meta-data like type and display name - * half-implemented support for sorting - * half-implemented support for export to .json - * API for getting data in simple arrays - * API for getting ResultSets with iterators (precursor to support for something like the openrico.org live grid) - -~~~~~~~~~~~~~~~~~~~~~~~~ -To-Do List - * be able to import data from an html