Browse Source

Loading of Helios with qs-passed baseUrl

(used to load config.js, thus have the right mappings).
Herbert Vojčík 9 years ago
parent
commit
ec28b4050e
2 changed files with 19 additions and 15 deletions
  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();
         }
     };
 });