well, not really. miniCodeEditor (like codepen.io or jsfiddle.net) is more like a tool helping to quickly setup a HTML/CSS/JS prototype, not to build a website.
Nice and you could probably make it save in under 512 bytes. Just persist everything to localStorage like the tiny spreadsheet http://jsfiddle.net/ondras/hYfN3/
Or save everything on the URL so it can be bookmarked too.
You know, thare's already a save function: you can write stuff in the cross-browser editor and save it on your desktop as a standalone HTML page (Ctrl-S / File > "Save as...")
Very impressive work, however, your "Keys Pressed" code could let a keypress position in the array on "true" if a key is pressed more than 1 second. I think you should set up a timeout to ensure a keypress position state is returned to false after the user interaction.
I recommend reading K&R (http://en.wikipedia.org/wiki/The_C_Programming_Language) if you haven't already. It's got all sorts of elegant tricks like this. But of course it depends on very particular implementation details at times.
Don't worry, I have (hence my disbelief at the first comment). Funny we've come full circle (via e.g. Java) back to the point where that is valid code.
A lot of people forget (or never knew) that the increment and decrement operators return a value as well as affecting the target variable, and that you can put what-ever you like in the iteration end control portion of a for statement as long as it returns truey/falsey.
There's pre-increment (++i), post-increment (i++), pre-decrement (--i), post-decrement (i--). The pre-ops operate on the variable and resolve to the new value. The post-ops resolve to the current value, and then operate on the variable.
Thanks :) I write a ton of CSS every day but I'm still learning JavaScript. Expanding this helped me understand a few things already, I'll go update that right now!
Looks like you're setting the <iframe>'s contents with a data uri in the src attribute, you save some characters if you use the HTML5 srcdoc attribute:
56 comments
[ 2.9 ms ] story [ 38.4 ms ] threadOr 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.
;)
In fact, I created a CSS library, min, that's 995 bytes - http://minfwk.com/.
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.
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
I also thought of this approach this morning, but didn't mention it because I thought people would just add the editor in their bookmarks.
Github: https://github.com/tomhodgins/liveeditor
Screenshot: http://i.imgur.com/SuXoXHb.png
Demo: http://staticresource.com/editor
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.
http://www.whatwg.org/specs/web-apps/current-work/multipage/...
http://xem.github.io/miniCodeEditor/tweet.html