Permalink
Browse files

a descriptive comment, tighter code, make sure we can load css even i…

…f there isn't any js code
  • Loading branch information...
1 parent c85fab4 commit e9df67877f6eec2850ee964b20e76615ff911564 @canuckistani committed Apr 4, 2012
Showing with 8 additions and 11 deletions.
  1. +8 −11 data/dotjs.js
View
@@ -1,27 +1,24 @@
-// debugging
-var L = console.log,
-D = function(o) { return JSON.stringify(o, null, ' '); };
-
+/*
+ * catch the 'load-scripts' event and inject the resilts into the current scope.
+ */
(function() {
self.port.on("load-scripts", function(msg) {
if (msg.jquery) {
eval(msg.jquery);
}
- else {
- // jQuery is a hard requirement.
- return;
- }
+
if (msg.js) {
eval(msg.js);
}
+
if (msg.coffee) {
(function() {
eval(msg.transpiler);
}).call(window); // coffee-script.js assumes this === window
eval(CoffeeScript.compile(msg.coffee));
}
- // needs testing...
- if (msg.css) {
+
+ if (msg.css) {
var headNode = document.querySelector('head');
var cssNode = document.createElement('style');
cssNode.innerHTML = msg.css;
@@ -32,4 +29,4 @@ D = function(o) { return JSON.stringify(o, null, ' '); };
if (document.URL.indexOf('http') === 0) {
self.port.emit('init', document.URL);
}
-})();
+})();

0 comments on commit e9df678

Please sign in to comment.