Day 6 - It's Not Me, It's You
Today was a whirlwind of a day, and I feel like I got a lot of code done. The first thing I did today was work on automatically changing the langauge of the new snippet code entry box when the user changes the dropdown. This turned out to be pretty easy, and I will show the code in a couple lines.
First, though, we need to talk. CoffeeScript, we’ve been seeing each other for almost six days now, and I know it’s shallow, but your syntax just looks so unelegant. Don’t cry, you’re just making this harder than it already is. So yeah I’m switching back to JavaScript. So here’s the code for what I talked about above (not included in this post so as to keep it semi-short).
Now this code downloads the associated JavaScript file whenever a change happens to the dropdown. This code changed around a lot, but we’ll talk about that later. Firstly, why isn’t there better syntax for dynamically loading a JavaScript file?! If I want to do that, then I have to literally insert a script tag into the head tag. This really is unacceptable, but I guess Google is right…
So the other thing that I worked on today was integrating the CodeMirror editor into the code display in addition to the snippet new page. It turns out that you can make CodeMirror read-only and turn off line numbers to make it display a snippet really nicely! Here is my final function to download language data and stick it into a code editor:
You can see a demo version of this app on Heroku.