public
Created

Make a public pad on https://etherpad.mozilla.org/ . Open your developer console and paste the code into the Javascript evaluator. (You might need to enable popups.) A window will show where Javascript (that is in your pad) will be executed when you add/remove lines in your pad. Let someone else do the same on your pad, so you can collaboratively work on a script.

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(function() {
 
var targetWindow = window.open(null,null,'resizable=yes,scrollbars=yes,status=yes');
 
/*var iframe = document.createElement('iframe');
iframe.style.position = 'absolute';
iframe.style.zIndex = 1000;
iframe.style.left = 0;
iframe.width = '300px';
iframe.height = '300px';
iframe.style.backgroundColor = 'white';
document.body.appendChild(iframe);
 
var targetWindow = iframe.contentWindow;*/
 
var previousLineCount = 0;
setInterval(function() {
var lines = document.getElementById('editorcontainer').getElementsByTagName('iframe')[0].contentWindow.document.getElementById('outerdocbody').getElementsByTagName('iframe')[0].contentWindow.document.getElementById('innerdocbody').getElementsByTagName('div');
if (previousLineCount === lines.length) { return; }
var content = Array.prototype.map.call(lines,function(line) {
return line.textContent;
}).join('\n');
targetWindow.document.close();
targetWindow.document.write('');
targetWindow.document.write('<!DOCTYPE html>\n<html><head><script language="javascript">\n'+ content + '\n</script>\n</head>\n<body>\n</body>\n</html>');
targetWindow.document.close();
previousLineCount = lines.length;
}, 1000);
}());

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.