diff --git a/package.json b/package.json
index e85f354c..fef8af7a 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"url": "git://github.com/remy/jsbin.git"
},
"scripts": {
- "test": "./node_modules/mocha/bin/mocha"
+ "test": "mocha"
},
"dependencies": {
"express": "3.0.x",
diff --git a/public/js/render/render.js b/public/js/render/render.js
index 5aa8855b..77b15598 100644
--- a/public/js/render/render.js
+++ b/public/js/render/render.js
@@ -1,202 +1,174 @@
-var consoleTest = /(^.|\b)console\./;
+var getPreparedCode = (function () {
-var iframedelay = (function () {
- var iframedelay = { active : false },
- iframe = document.createElement('iframe'),
- doc,
- callbackName = '__callback' + (+new Date);
+ var consoleTest = /(^.|\b)console\./,
+ re = {
+ docReady: /\$\(document\)\.ready/,
+ shortDocReady: /\$\(function/,
+ console: /(^.|\b)console\.(\S+)/g,
+ script: /<\/script/ig,
+ code: /%code%/,
+ title: /
(.*)<\/title>/i,
+ winLoad: /window\.onload\s*=/,
+ scriptopen: /');
- doc.close();
- } catch (e) {
- iframedelay.active = true;
- }
+ return function (nojs) {
+ // reset all the regexp positions for reuse
+ re.docReady.lastIndex = 0;
+ re.shortDocReady.lastIndex = 0;
+ re.console.lastIndex = 0;
+ re.script.lastIndex = 0;
+ re.code.lastIndex = 0;
+ re.title.lastIndex = 0;
+ re.winLoad.lastIndex = 0;
+ re.scriptopen.lastIndex = 0;
- return iframedelay;
-}());
+ var parts = [],
+ source = '',
+ js = '',
+ css = '',
+ close = '',
+ hasHTML = false,
+ hasCSS = false,
+ hasJS = false,
+ date = new Date(),
+ scriptOffset = 0;
-var re = null;
-
-function two(i) {
- return ('0'+i).slice(-2);
-}
-
-function getPreparedCode(nojs) {
- // init the regular expression cache because this function
- // is called much earlier than the above code is actually encountered
- // yay for massive .js app!
- if (!re) {
- re = {
- docReady: /\$\(document\)\.ready/,
- shortDocReady: /\$\(function/,
- console: /(^.|\b)console\.(\S+)/g,
- script: /<\/script/ig,
- code: /%code%/,
- title: /(.*)<\/title>/i,
- winLoad: /window\.onload\s*=/,
- scriptopen: /\n" + close;
- }
-
- // redirect console logged to our custom log while debugging
- if (re.console.test(source)) {
- var replaceWith = 'window.runnerWindow.proxyconsole.';
- // yes, this code looks stupid, but in fact what it does is look for
- // 'console.' and then checks the position of the code. If it's inside
- // an openning script tag, it'll change it to window.top._console,
- // otherwise it'll leave it.
- source = source.replace(re.console, function (all, str, arg, pos) {
- var open = source.lastIndexOf('\n" + close;
+ }
+
+ // redirect console logged to our custom log while debugging
+ if (re.console.test(source)) {
+ var replaceWith = 'window.runnerWindow.proxyConsole.';
+ // yes, this code looks stupid, but in fact what it does is look for
+ // 'console.' and then checks the position of the code. If it's inside
+ // an openning script tag, it'll change it to window.top._console,
+ // otherwise it'll leave it.
+ source = source.replace(re.console, function (all, str, arg, pos) {
+ var open = source.lastIndexOf('