ソースを参照

Works with concatenated-for-node-js scenario.

Herbert Vojčík 11 年 前
コミット
4293a7cd21
1 ファイル変更15 行追加6 行削除
  1. 15 6
      js/init.js

+ 15 - 6
js/init.js

@@ -1,9 +1,18 @@
-setTimeout(function () {
-    smalltalk.initialize();
+(function () {
+    var inBrowser = typeof amber !== "undefined" && typeof amber.load === "function";
+    function init() {
+        smalltalk.initialize();
 
-    /* Similar to jQuery(document).ready() */
+        /* Similar to jQuery(document).ready() */
 
-    if (this.amber && this.amber.smalltalkReady) {
-        this.amber.smalltalkReady();
+        if (inBrowser && amber.smalltalkReady) {
+            amber.smalltalkReady();
+        }
     }
-}, 0);
+
+    if (inBrowser) {
+        setTimeout(init, 0);
+    } else {
+        init();
+    }
+})();