Skip to content

Instantly share code, notes, and snippets.

@FrozenCow
Created March 4, 2013 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrozenCow/5085195 to your computer and use it in GitHub Desktop.
Save FrozenCow/5085195 to your computer and use it in GitHub Desktop.
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 collaborativel…
(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);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment