commit ba16889bb0cde38f841f30d0ad3d18620393e974
parent ca2045a3051e50537ef312ec2e0335786272a607
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 13 Jun 2006 15:14:22 +0000
Moved the Scholar.Hash constructor out of the main Scholar constructor, where I had put it for some reason -- ignore
Diffstat:
1 file changed, 38 insertions(+), 39 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js
@@ -24,8 +24,6 @@ var Scholar = new function(){
this.randomString = randomString;
this.getRandomID = getRandomID;
- this.Hash = Hash;
-
/*
* Initialize the extension
*/
@@ -233,46 +231,47 @@ var Scholar = new function(){
return rnd;
}
-
-
- /*
- * Class for creating hash arrays that behave a bit more sanely
- *
- * Hashes can be created in the constructor by alternating key and val:
- *
- * var hasharray = new Scholar.Hash('foo','foovalue','bar','barvalue');
- *
- * Or using hasharray.set(key, val)
- *
- * _val_ defaults to true if not provided
- *
- * If using foreach-style looping, be sure to use _for (i in arr.items)_
- * rather than just _for (i in arr)_, or else you'll end up with the
- * methods and members instead of the hash items
- *
- * Most importantly, hasharray.length will work as expected, even with
- * non-numeric keys
- *
- * Adapated from http://www.mojavelinux.com/articles/javascript_hashes.html
- * (c) Mojavelinux, Inc.
- * License: Creative Commons
- */
- function Hash(){
- this.length = 0;
- this.items = new Array();
-
- // Public methods defined on prototype below
-
- for (var i = 0; i < arguments.length; i += 2) {
- if (typeof(arguments[i + 1]) != 'undefined') {
- this.items[arguments[i]] = arguments[i + 1];
- this.length++;
- }
- }
- }
};
+
+
+/**
+* Class for creating hash arrays that behave a bit more sanely
+*
+* Hashes can be created in the constructor by alternating key and val:
+*
+* var hasharray = new Scholar.Hash('foo','foovalue','bar','barvalue');
+*
+* Or using hasharray.set(key, val)
+*
+* _val_ defaults to true if not provided
+*
+* If using foreach-style looping, be sure to use _for (i in arr.items)_
+* rather than just _for (i in arr)_, or else you'll end up with the
+* methods and members instead of the hash items
+*
+* Most importantly, hasharray.length will work as expected, even with
+* non-numeric keys
+*
+* Adapated from http://www.mojavelinux.com/articles/javascript_hashes.html
+* (c) Mojavelinux, Inc.
+* License: Creative Commons
+**/
+Scholar.Hash = function(){
+ this.length = 0;
+ this.items = new Array();
+
+ // Public methods defined on prototype below
+
+ for (var i = 0; i < arguments.length; i += 2) {
+ if (typeof(arguments[i + 1]) != 'undefined') {
+ this.items[arguments[i]] = arguments[i + 1];
+ this.length++;
+ }
+ }
+}
+
Scholar.Hash.prototype.get = function(in_key){
return this.items[in_key];
}