ignore #! in the js worker

This commit is contained in:
Fabian Jakobs 2011-02-03 14:45:45 +01:00
commit c9f3abb199
2 changed files with 11 additions and 7 deletions

View file

@ -16,6 +16,7 @@ oop.inherits(JavaScriptWorker, Mirror);
this.onUpdate = function() { this.onUpdate = function() {
var value = this.doc.getValue(); var value = this.doc.getValue();
value = value.replace(/^#!.*\n/, "");
// var start = new Date(); // var start = new Date();
var parser = require("ace/narcissus/jsparse"); var parser = require("ace/narcissus/jsparse");

View file

@ -19,7 +19,7 @@ var require = function(id) {
var chunks = id.split("/"); var chunks = id.split("/");
chunks[0] = require.tlns[chunks[0]] || chunks[0]; chunks[0] = require.tlns[chunks[0]] || chunks[0];
path = /*require.baseUrl + "/" +*/ chunks.join("/") + ".js" path = /*require.baseUrl + "/" +*/ chunks.join("/") + ".js";
require.id = id; require.id = id;
// console.log("require " + path + " " + id) // console.log("require " + path + " " + id)
@ -29,14 +29,14 @@ var require = function(id) {
require.modules = {}; require.modules = {};
require.tlns = {}; require.tlns = {};
require.baseUrl; require.baseUrl = "";
var define = function(id, factory) { var define = function(id, factory) {
if (!factory) { if (!factory) {
factory = id; factory = id;
id = require.id; id = require.id;
} }
if (id.indexOf("text!") == 0) if (id.indexOf("text!") === 0)
return; return;
require.modules[id] = { require.modules[id] = {
@ -74,7 +74,7 @@ function initSender() {
id: callbackId, id: callbackId,
data: data data: data
}); });
}, };
this.emit = function(name, data) { this.emit = function(name, data) {
postMessage({ postMessage({
@ -82,7 +82,8 @@ function initSender() {
name: name, name: name,
data: data data: data
}); });
} };
}).call(Sender.prototype); }).call(Sender.prototype);
return new Sender(); return new Sender();
@ -93,15 +94,17 @@ var sender;
onmessage = function(e) { onmessage = function(e) {
var msg = e.data; var msg = e.data;
if (msg.command) if (msg.command) {
main[msg.command].apply(main, msg.args); main[msg.command].apply(main, msg.args);
}
else if (msg.init) { else if (msg.init) {
initBaseUrls(msg.base, msg.tlns); initBaseUrls(msg.base, msg.tlns);
require("pilot/fixoldbrowsers"); require("pilot/fixoldbrowsers");
sender = initSender(); sender = initSender();
var clazz = require(msg.module)[msg.classname]; var clazz = require(msg.module)[msg.classname];
main = new clazz(sender); main = new clazz(sender);
} else if (msg.event) { }
else if (msg.event) {
sender._dispatchEvent(msg.event, msg.data); sender._dispatchEvent(msg.event, msg.data);
} }
}; };