commit 921f9544c5d625dcfff8e64d9dd59e80057e33d6
parent bb8c8991e1c0ee5bddcc8b9e24b5b1c4271710e7
Author: Davide P. Cervone <dpvc@union.edu>
Date: Thu, 20 Mar 2014 05:46:40 -0400
Merge remote-tracking branch 'dpvc/issue737' into develop. Issue #737.
Diffstat:
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js
@@ -642,31 +642,46 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individual
SCRIPTS = [];
};
+ var PATH = {};
+ PATH[BASENAME] = ""; // empty path gets the root URL
+
BASE.Ajax = {
loaded: {}, // files already loaded
loading: {}, // files currently in process of loading
loadHooks: {}, // hooks to call when files are loaded
timeout: 15*1000, // timeout for loading of files (15 seconds)
styleDelay: 1, // delay to use before styles are available
- config: {root: ""}, // URL of root directory to load from
+ config: {
+ root: "", // URL of root directory to load from
+ path: PATH // paths to named URL's (e.g., [MathJax]/...)
+ },
STATUS: {
OK: 1, // file is loading or did load OK
ERROR: -1 // file timed out during load
},
-
- rootPattern: new RegExp("^\\["+BASENAME+"\\]"),
-
+
//
- // Return a complete URL to a file (replacing the root pattern)
+ // Return a complete URL to a file (replacing any root names)
//
- fileURL: function (file) {return file.replace(this.rootPattern,this.config.root)},
+ fileURL: function (file) {
+ var match = file.match(/^\[([-._a-z0-9]+)\]/i);
+ if (match && match[1] in PATH)
+ {file = (PATH[match[1]]||this.config.root) + file.substr(match[1].length+2)}
+ return file;
+ },
//
- // Remove root if URL includes it
+ // Replace root names if URL includes one
//
fileName: function (url) {
var root = this.config.root;
- if (url.substr(0,root.length) == root) {url = "["+BASENAME+"]"+url.substr(root.length)}
+ if (url.substr(0,root.length) === root) {url = "["+BASENAME+"]"+url.substr(root.length)}
+ else {
+ for (var id in PATH) {if (PATH.hasOwnProperty(id) && PATH[id]) {
+ if (url.substr(0,PATH[id].length) === PATH[id])
+ {url = "["+id+"]"+url.substr(PATH[id].length); break}
+ }}
+ }
return url;
},
//
@@ -983,7 +998,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individual
return string;
}
};
-
+
})("MathJax");
/**********************************************************/
@@ -2967,10 +2982,10 @@ MathJax.Hub.Startup = {
CONFIG.root = scripts[i].src.replace(/(^|\/)[^\/]*(\?.*)?$/,'')
.replace(/^(https?:\/\/(cdn.mathjax.org|[0-9a-f]+(-[0-9a-f]+)?.ssl.cf1.rackcdn.com)\/mathjax\/)(latest)/,
"$1"+BASE.version+"-$4");
+ BASE.Ajax.config.root = CONFIG.root;
break;
}
}
- BASE.Ajax.config = CONFIG;
var AGENT = navigator.userAgent;
var BROWSERS = {