1
0
فهرست منبع

Loading of Helios with qs-passed baseUrl

(used to load config.js, thus have the right mappings).
Herbert Vojčík 10 سال پیش
والد
کامیت
ec28b4050e
2فایلهای تغییر یافته به همراه19 افزوده شده و 15 حذف شده
  1. 12 13
      index.html
  2. 7 2
      index.js

+ 12 - 13
index.html

@@ -11,20 +11,19 @@
 
     <div id="includes">
       <script type='text/javascript' src='../requirejs/require.min.js'></script>
-        <script type='text/javascript' src='../../config.js'></script>
-        <script type='text/javascript'>
-          require.config({baseUrl: '../..'});
-          require(
-                  ["helios/set"],
-                  function (smalltalk) {
-                      window.onbeforeunload = function() {
-                          return 'Do you want to close Amber? All uncommitted changes will be lost.';
-                      };
+      <script type='text/javascript'>
+        var base = decodeURIComponent(window.location.search.slice(1));
+        if (base) require.config({baseUrl: base});
+        require(["require", "config"], function (require) {
+          require(["helios/set"], function (smalltalk) {
+            window.onbeforeunload = function() {
+              return 'Do you want to close Amber? All uncommitted changes will be lost.';
+            };
 
-                      smalltalk.initialize({'transport.defaultAmdNamespace': "amber_core"});
-					  smalltalk.globals.HLManager._setup();
-                  }
-          );
+            smalltalk.initialize({'transport.defaultAmdNamespace': "amber_core"});
+            smalltalk.globals.HLManager._setup();
+          });
+        });
       </script>
     </div>
   </body>

+ 7 - 2
index.js

@@ -1,10 +1,15 @@
 define(["require"], function (require) {
     return  {
+        pageUrl: function () {
+            var a = document.createElement("a");
+            a.href = require.toUrl("..");
+            return require.toUrl('./index.html') + "?" + encodeURIComponent(a.href);
+        },
         popup: function () {
-            window.open(require.toUrl('./index.html'), "Helios", "menubar=no, width=1000, height=600");
+            window.open(this.pageUrl(), "Helios", "menubar=no, width=1000, height=600");
         },
         go: function () {
-            window.location.href = require.toUrl('./index.html');
+            window.location.href = this.pageUrl();
         }
     };
 });