fix for loading of files generated by r.js from the worker

This commit is contained in:
nightwing 2012-08-07 19:13:23 +04:00
commit 94ea9a5845
2 changed files with 9 additions and 0 deletions

View file

@ -56,6 +56,10 @@ require.tlns = {};
var define = function(id, deps, factory) { var define = function(id, deps, factory) {
if (arguments.length == 2) { if (arguments.length == 2) {
factory = deps; factory = deps;
if (typeof id != "string") {
deps = id;
id = require.id;
}
} else if (arguments.length == 1) { } else if (arguments.length == 1) {
factory = id; factory = id;
id = require.id; id = require.id;
@ -135,4 +139,7 @@ onmessage = function(e) {
else if (msg.event && sender) { else if (msg.event && sender) {
sender._emit(msg.event, msg.data); sender._emit(msg.event, msg.data);
} }
if (msg.eval) {
console.log(eval(msg.eval));
}
}; };

View file

@ -114,6 +114,8 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
this.$normalizePath = function(path) { this.$normalizePath = function(path) {
if (!location.host) // needed for file:// protocol
return path;
path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
path = location.protocol + "//" + location.host path = location.protocol + "//" + location.host
// paths starting with a slash are relative to the root (host) // paths starting with a slash are relative to the root (host)