Moar stuff:
* Added
- check out the code at
https://github.com/fwielstra/gobox/blob/master/static/client.html#L62 and send me pull requests if you'd like to see moar. It'd probably be best to eventually replace all replacement smilies in one iteration, but for now, just going
Code:
function parseSmileys(poast) {
var result = poast
var result = result.replace(":monster:", "<img src=\"http://thelifestream.net/forums/images/smilies/cookiemonster.gif\">");
result = result.replace(":something:", "some other smiley");
}
will be fine.
* Added link auto-parsing to clickable links using
javascript-linkify. That one hasn't been updated for 6 years though, so with the recent trend of being able to register any top level domain you want for monies, it probably won't work properly anymore. I'll replace it with something more generic if that proves to be an issue.
* Implemented etag headers; basically, the server has a timestamp that indicates when someone last poasted something. That timestamp is sent to a client when it polls for new poasts. The client stores that timestamp, and sends it back to the server when it polls again. If the client timestamp is equal to the server timestamp, the server returns a 304 Not Modified header back. If the client gets a 304 header back, it won't re-render anything. Actually I had to hack around this; it turns out that if you do an xmlhttprequest to a server that returns 304 Not Modified, the callback method gets a regular 200 OK message - which would still trigger a re-render of posts, even if said posts hadn't changed. I haxed this by sending the etag back in the GET response from the server, which is compared on the client (see
https://github.com/fwielstra/gobox/blob/master/static/client.html#L70). If it's the same from the previous etag stored on the client, then nothing changed and nothing needs to be done.
TL;DR: moar efficiency, less suboptimality.