diff options
author | Alex Legler <alex@a3li.li> | 2014-12-23 17:49:26 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2014-12-23 17:49:26 +0100 |
commit | e352fff59842ca14fbfd81ee1c4a64297bb598c5 (patch) | |
tree | 153f268484aa5cc41cacf912bdce8c4847df222d /SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js | |
download | extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.gz extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.bz2 extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.zip |
Add initial set of additional extensions
Diffstat (limited to 'SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js')
-rw-r--r-- | SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js b/SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js new file mode 100644 index 00000000..71726092 --- /dev/null +++ b/SemanticResultFormats/formats/Exhibit/ajax/scripts/ajax.js @@ -0,0 +1,45 @@ +/*================================================== + * General, miscellaneous SimileAjax stuff + *================================================== + */ + +SimileAjax.ListenerQueue = function(wildcardHandlerName) { + this._listeners = []; + this._wildcardHandlerName = wildcardHandlerName; +}; + +SimileAjax.ListenerQueue.prototype.add = function(listener) { + this._listeners.push(listener); +}; + +SimileAjax.ListenerQueue.prototype.remove = function(listener) { + var listeners = this._listeners; + for (var i = 0; i < listeners.length; i++) { + if (listeners[i] == listener) { + listeners.splice(i, 1); + break; + } + } +}; + +SimileAjax.ListenerQueue.prototype.fire = function(handlerName, args) { + var listeners = [].concat(this._listeners); + for (var i = 0; i < listeners.length; i++) { + var listener = listeners[i]; + if (handlerName in listener) { + try { + listener[handlerName].apply(listener, args); + } catch (e) { + SimileAjax.Debug.exception("Error firing event of name " + handlerName, e); + } + } else if (this._wildcardHandlerName != null && + this._wildcardHandlerName in listener) { + try { + listener[this._wildcardHandlerName].apply(listener, [ handlerName ]); + } catch (e) { + SimileAjax.Debug.exception("Error firing event of name " + handlerName + " to wildcard handler", e); + } + } + } +}; + |