changes since migration, but not sure where these came from yet
authorJason Etheridge <jason@esilibrary.com>
Wed, 29 Feb 2012 20:20:31 +0000 (15:20 -0500)
committerJason Etheridge <jason@esilibrary.com>
Wed, 29 Feb 2012 20:20:31 +0000 (15:20 -0500)
Open-ILS/web/opac/skin/tadl/js/combined.js

index a6cee68..e0f26c5 100644 (file)
@@ -1242,19 +1242,36 @@ CGI.prototype.toString = function() {
  * See http://pajhome.org.uk/crypt/md5 for more info.
  */
 
+/*
+ * Configurable variables. You may need to tweak these to be compatible with
+ * the server-side, but the defaults work in most cases.
+ */
 var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
 var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
 var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
+
+/*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
 function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
 function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
 function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
 function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
 function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
 function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
+
+/*
+ * Perform a simple self-test to see if the VM is working
+ */
 function md5_vm_test()
 {
   return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
 }
+
+/*
+ * Calculate the MD5 of an array of little-endian words, and a bit length
+ */
 function core_md5(x, len)
 {
   /* append padding */
@@ -1349,6 +1366,10 @@ function core_md5(x, len)
   return Array(a, b, c, d);
 
 }
+
+/*
+ * These functions implement the four basic operations the algorithm uses.
+ */
 function md5_cmn(q, a, b, x, s, t)
 {
   return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
@@ -1369,6 +1390,10 @@ function md5_ii(a, b, c, d, x, s, t)
 {
   return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
 }
+
+/*
+ * Calculate the HMAC-MD5, of a key and some data
+ */
 function core_hmac_md5(key, data)
 {
   var bkey = str2binl(key);
@@ -1384,16 +1409,30 @@ function core_hmac_md5(key, data)
   var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
   return core_md5(opad.concat(hash), 512 + 128);
 }
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
 function safe_add(x, y)
 {
   var lsw = (x & 0xFFFF) + (y & 0xFFFF);
   var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
   return (msw << 16) | (lsw & 0xFFFF);
 }
+
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
 function bit_rol(num, cnt)
 {
   return (num << cnt) | (num >>> (32 - cnt));
 }
+
+/*
+ * Convert a string to an array of little-endian words
+ * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
+ */
 function str2binl(str)
 {
   var bin = Array();
@@ -1402,6 +1441,10 @@ function str2binl(str)
     bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
   return bin;
 }
+
+/*
+ * Convert an array of little-endian words to a string
+ */
 function binl2str(bin)
 {
   var str = "";
@@ -1410,6 +1453,10 @@ function binl2str(bin)
     str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
   return str;
 }
+
+/*
+ * Convert an array of little-endian words to a hex string.
+ */
 function binl2hex(binarray)
 {
   var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
@@ -1421,6 +1468,10 @@ function binl2hex(binarray)
   }
   return str;
 }
+
+/*
+ * Convert an array of little-endian words to a base-64 string
+ */
 function binl2b64(binarray)
 {
   var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -2327,7 +2378,7 @@ function doLogin(suppressEvents) {
                org             : getOrigLocation()
        };
 
-    r = fetchOrgSettingDefault(getLocation(), 'opac.barcode_regex');
+    r = fetchOrgSettingDefault(globalOrgTree.id(), 'opac.barcode_regex');
     if(r) REGEX_BARCODE = new RegExp(r);
     
     if( uname.match(REGEX_BARCODE) ) args.barcode = uname;
@@ -2880,7 +2931,7 @@ function orgIsMine(me, org, depth) {
        if(me.id() == org.id()) {
                return true;
        }
-       if (depth) {
+       if (depth !== undefined) {
                while (depth < findOrgDepth(me)) {
                        me = findOrgUnit( me.parent_ou() );
                }
@@ -2890,7 +2941,7 @@ function orgIsMine(me, org, depth) {
        }
        var kids = me.children();
        for( var i = 0; kids && i < kids.length; i++ ) {
-               if(orgIsMine(kids[i], org, false)) {
+               if(orgIsMine(kids[i], org /* intentional lack of 3rd arg */)) {
                        return true;
                }
 
@@ -3160,7 +3211,7 @@ RemoteRequest.prototype.send = function(blocking) {
                        url = 'http://'+XML_HTTP_SERVER+'/'+XML_HTTP_GATEWAY;
 
                if( url.match(/^http:/) && 
-                               (this.secure || location.href.match(/^https:/)) ) {
+                               (this.secure || location.href.match(/^https:/) || location.href.match(/^chrome:/) ) ) {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
                        url = url.replace(/^http:/, 'https:');
                }