html/agent.js: Fix whitespace/style
html/agent.js: Move global variables into namespace

Trying to avoid overloading the global namespace, thus using the
agent-object to create a namespace.
html/agent.js: Introduce agent.statsInterval

I got tired of looking at stats requests every second.

Also removed unused variable setstate and added some hopefully descriptive
comments.