Moved the Scholar.Hash constructor out of the main Scholar constructor, where I had put it for some reason -- ignore

This commit is contained in:
Dan Stillman 2006-06-13 15:14:22 +00:00
parent ca2045a305
commit ba16889bb0

View file

@ -24,8 +24,6 @@ var Scholar = new function(){
this.randomString = randomString; this.randomString = randomString;
this.getRandomID = getRandomID; this.getRandomID = getRandomID;
this.Hash = Hash;
/* /*
* Initialize the extension * Initialize the extension
*/ */
@ -233,31 +231,34 @@ var Scholar = new function(){
return rnd; 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: * Class for creating hash arrays that behave a bit more sanely
* *
* var hasharray = new Scholar.Hash('foo','foovalue','bar','barvalue'); * Hashes can be created in the constructor by alternating key and val:
* *
* Or using hasharray.set(key, val) * var hasharray = new Scholar.Hash('foo','foovalue','bar','barvalue');
* *
* _val_ defaults to true if not provided * Or using hasharray.set(key, val)
* *
* If using foreach-style looping, be sure to use _for (i in arr.items)_ * _val_ defaults to true if not provided
* rather than just _for (i in arr)_, or else you'll end up with the *
* methods and members instead of the hash items * 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
* Most importantly, hasharray.length will work as expected, even with * methods and members instead of the hash items
* non-numeric keys *
* * Most importantly, hasharray.length will work as expected, even with
* Adapated from http://www.mojavelinux.com/articles/javascript_hashes.html * non-numeric keys
* (c) Mojavelinux, Inc. *
* License: Creative Commons * Adapated from http://www.mojavelinux.com/articles/javascript_hashes.html
*/ * (c) Mojavelinux, Inc.
function Hash(){ * License: Creative Commons
**/
Scholar.Hash = function(){
this.length = 0; this.length = 0;
this.items = new Array(); this.items = new Array();
@ -269,9 +270,7 @@ var Scholar = new function(){
this.length++; this.length++;
} }
} }
} }
};
Scholar.Hash.prototype.get = function(in_key){ Scholar.Hash.prototype.get = function(in_key){
return this.items[in_key]; return this.items[in_key];