I don't really like this html hardcoding in javascript code. What about using a javascript template mechanism (underscore or jquery template)?