Turns out the javascript is completely unnecessary.