Port most javascript to jQuery

Partially fix #13.
Dialog API still needs to be ported