replaced the table with templates and jQuery

* but the code is abysmal