<!-- A friend of mine wrote this “microblogging” program in the Unix
shell:

while read line; do ENTRY="$(date +'%d-%m %H:%M:%S'): $line"; echo "$ENTRY" >> \
microb.log; clear; cat microb.log; echo -n "sup-> "; done

I thought, hmm, wouldn’t it be nice if you could do things that simply
on the Web?  And then I thought, hmm, how much harder is it, really?
So here’s a DHTML version that's almost as simple and almost as
capable.  It depends on the following microframework.js:

var ls = localStorage, d = document;
function add(name, html) { ls[name] = (ls[name] || '') + html }
function esc(text) { return text.replace(/&/g, '&amp;').replace(/</g, '&lt;'); }

Given that, you can put together an equivalent of the 139-byte
tweet-sized “microblogging” shell script above in under 200
characters, as follows.

 -->
<script src="microframework.js"></script>
<script>d.write(ls['microblog'] || '');</script>
<form onsubmit="add('microblog', new Date+': '+esc(this.line.value)+'<br />')">
<input name=line autofocus>

-- 
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-hacks

Reply via email to