浏览代码

Allow otr and CryptoJS to not be defined.

Will allow builds without OTR functionality.
JC Brand 11 年之前
父节点
当前提交
f73ab4e832
共有 1 个文件被更改,包括 11 次插入2 次删除
  1. 11 2
      converse.js

+ 11 - 2
converse.js

@@ -29,7 +29,11 @@
                 evaluate : /\{\[([\s\S]+?)\]\}/g,
                 interpolate : /\{\{([\s\S]+?)\}\}/g
             };
-            return factory(jQuery, _, CryptoJS, otr.OTR, otr.DSA, console);
+            if (typeof otr !== "undefined") {
+                return factory(jQuery, _, CryptoJS, otr.OTR, otr.DSA, console);
+            } else {
+                return factory(jQuery, _, undefined, undefined, undefined, console);
+            }
         });
     } else {
         // Browser globals
@@ -57,6 +61,11 @@
             (typeof crypto.randomBytes !== 'function') &&
             (typeof crypto.getRandomValues !== 'function')
         ));
+        var HAS_CRYPTO = HAS_CSPRNG && (
+            (typeof CryptoJS !== "undefined") &&
+            (typeof OTR !== "undefined") &&
+            (typeof DSA !== "undefined")
+        );
 
         // Default configuration values
         // ----------------------------
@@ -109,7 +118,7 @@
         ]));
 
         // Only allow OTR if we have the capability
-        this.allow_otr = this.allow_otr && HAS_CSPRNG;
+        this.allow_otr = this.allow_otr && HAS_CRYPTO;
 
         // Translation machinery
         // ---------------------