An HTML/CSS/JS code editor in 230+ bytes
xem.github.io
xem.github.io
data:text/html,%20<x%20id=e><script>for(i=4;i--;)e.innerHTML+=(i?'<textarea%20id=t'+i:'<iframe')+'%20style=width:49%;height:48%%20oninput=\'e.lastChild.src="data:text/html;base64,"+btoa(t3[v="value"]+"<script>"+t1[v]+"<\/script><style>"+t2[v])\'>'</script>
Taken from this: https://coderwall.com/p/lhsrcqI also thought of this approach this morning, but didn't mention it because I thought people would just add the editor in their bookmarks.
data:text/html,%20<x%20id=e><script>d=['','//js','/*css*/','<!--HTML-->'];for(i=4;i--;)e.innerHTML+=(i?'<textarea%20id=t'+i:'<iframe')+'%20style=width:49%;height:48%%20oninput=\'e.lastChild.src="data:text/html;base64,"+btoa(t3[v="value"]+"<script>"+t1[v]+"<\/script><style>"+t2[v])\'>'+d[i]+'\n'</script>Wow! This topic is successful!
You can also take a look at this 512b project that didn't live long on HN yesterday:
A minesweeper game https://news.ycombinator.com/item?id=6853868
And my other code golfing projects: http://xem.github.io/?golfing
==========
t3[v="value"] ... t2[v] ... t1[v]
rather than
t3.value ... t2.value ... t1.value
to save 1 fucking char.
Github: https://github.com/tomhodgins/liveeditor
Screenshot: http://i.imgur.com/SuXoXHb.png
This user interface is very nice, bravo!
In your JS, you can replace html["value"], css["value"] and js["value"] with html.value, css.value and js.value
Extra HTTP request has more overhead then few inline bytes.
if you put that code at bottom, you won't need jQuery to know if page is ready, and won't need extra HTTP request.
In fact, I created a CSS library, min, that's 995 bytes - http://minfwk.com/.
<x id=e><script>for(i=4;i--;)e.innerHTML+=(i?'<textarea':'<iframe')+' id=t'+i+' style=width:49%;height:48% oninput=\'t0.srcdoc=t3[v="value"]+"<script>"+t1[v]+"<\/script><style>"+t2[v]\'>'</script>
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/if...http://www.whatwg.org/specs/web-apps/current-work/multipage/...
Or save everything on the URL so it can be bookmarked too.
I've made something in this manner recently: http://tinyurl.com/selfcontained-editable-datauri
Feel free to fork miniCodeEditor and add this kind of features :)
http://xem.github.io/miniCodeEditor/editor.html
I recommend you to use Firefox: it will keep the code in the textareas. Chrome will only save the iframe's content.
;)
Use of `i--` in loop for condition check wasn't intuitive at first. Apparently `i--` will return the current value of i (before decrementing).
for(i=4;i--;)
instead of the more common (off by one?)
for(i=4; i > 0; i--) syntax