Declare some Javascript variables with 'var'.

Closes GH-1297.