JS conversion

First part of converting Prototype code to jQuery or vanilla JS.

This includes changes/fixes from https://github.com/MarkUsProject/Markus/pull/1244 and https://github.com/MarkUsProject/Markus/pull/1247