lookup and stash
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 05:48:44 +0000 (05:48 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 4 Aug 2006 05:48:44 +0000 (05:48 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5277 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js

index 70a64cc..a86d501 100644 (file)
@@ -50,6 +50,26 @@ OpenILS.data.prototype = {
                }
        },
 
+       'lookup' : function(key,value) {
+               try {
+                       var obj = this; var found;
+                       if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
+                       switch(key) {
+                               case 'acpl': 
+                                       found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID',[ value ]);
+                               break;
+                               default: return undefined; break;
+                       }
+                       if (typeof found.ilsevent != 'undefined') throw(found);
+                       if (!obj.hash[key]) obj.hash[key] = {};
+                       obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
+                       return found;
+               } catch(E) {
+                       this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
+                       return undefined;
+               }
+       },
+
        '_debug_stash' : function() {
                try {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");