refactor to use javascript Pad API. closes #7.

decouples the handling of state (text and selection) with the act of interfacing
with the UI to get and set it.