added jsMath files
[lambda.git] / jsMath / jsMath-loader-post.html
diff --git a/jsMath/jsMath-loader-post.html b/jsMath/jsMath-loader-post.html
new file mode 100644 (file)
index 0000000..0de7cb9
--- /dev/null
@@ -0,0 +1,78 @@
+<html>
+<head>
+<!--
+ | jsMath-loader-post.html
+ |
+ | Part of the jsMath package for mathematics on the web.
+ | 
+ | This file is used for loading jsMath components in Firefox3 when
+ | used in a file: url from a directory other than the one containing 
+ | jsMath (gets around Firefox3's more restrictive same-origin policy.
+ | 
+ | ---------------------------------------------------------------------
+ | 
+ | Copyright 2008 by Davide P. Cervone
+ |
+ | Licensed under the Apache License, Version 2.0 (the "License");
+ | you may not use this file except in compliance with the License.
+ | You may obtain a copy of the License at
+ |
+ |     http://www.apache.org/licenses/LICENSE-2.0
+ |
+ | Unless required by applicable law or agreed to in writing, software
+ | distributed under the License is distributed on an "AS IS" BASIS,
+ | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ | See the License for the specific language governing permissions and
+ | limitations under the License.
+-->
+</head>
+<body>
+
+<script>
+var isCheck = 0;
+var url = location.search.substr(1); var ID = "jsMLD";
+if (url.substr(0,9) == "autoload=") {url = url.substr(9); ID = "jsMAL"}
+
+if (url == 'http://www.math.union.edu/locate/jsMath/jsMath/jsMath-version-check.js') {
+  //
+  // Handle version check separately
+  //
+  var jsMath = {Controls: {}}; isCheck = 1;
+  document.write('<script src="'+url+'"></'+'script>');
+} else if (url != "" && url.match(/\.js$/) && !url.match('(^|[/\\?#=])[a-z]+://')) {
+  //
+  //  Load the file and pass it to jsMath
+  //
+  var request = new XMLHttpRequest;
+  try {
+    request.open("GET",url,false);
+    request.send(null);
+    window.parent.postMessage(ID+":BGN:","*");
+    window.parent.postMessage(ID+":SCR:"+request.responseText,"*");
+    window.parent.postMessage(ID+":END:1","*");
+  } catch (err) {
+    window.parent.postMessage(ID+":ERR:Can't load "+url+": "+err.message,"*");
+  }
+} else {
+  window.parent.postMessage(ID+":END:","*");
+}
+</script>
+
+<script>
+//
+//  If we are loading the version check, pass it to jsMath
+//  and run the check.
+//
+if (isCheck) {
+  var fn = jsMath.Controls.TestVersion.toString();
+  window.parent.postMessage(ID+":SCR:" +
+    "jsMath.Controls.TestVersion = "+fn+";" +
+    "jsMath.Message.Clear(); jsMath.Message.doClear();" +
+    "jsMath.Controls.TestVersion()","*"
+  );
+  window.parent.postMessage(ID+":END:","*");
+}
+</script>
+
+</body>
+</html>