Merge pull request #22 from dirkhh/mapImprovements

Map improvements
Fix the marker position issue

On the map page the marker would occasionally disappear or be in the completely
wrong spot. This was caused by a bug that would potentially reference an
unitialized variable, especially when the car was parked.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge pull request #23 from dirkhh/markerFix

Fix the marker position issue
Consistently use the req object from Express.js

The existing code still manually parsed the URL in the req object, even though
Express.js already does that for us.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Start a small JS library file to keep shared functions in

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix the marker position issue

On the map page the marker would occasionally disappear or be in the completely
wrong spot. This was caused by a bug that would potentially reference an
unitialized variable, especially when the car was parked.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add more functions to lib.js and similar functions to visualize.js

This is a fairly big commit, but hard to break into smaller pieces.

First it adds several more functions to lib.js and then uses those in
welcome, map, stats and energy pages. This makes the code more consistent,
easier to read and much more robust regarding query arguments (it now
deals with '-' as well as ' ' and '%20' as separators for date and time in
the query strings, for example).

This adds similar helper functions to visualize.js (it's rather awkward to
share the same helper functions between client side js and node.js on the
server side, so I opted to mostly duplicate the functions - but I also
changed the way they are used a little bit to make them more applicable
for the server side.

visualize.js now redirects the requests for the individual pages to new
request URLs that have all elements of the query arguments filled - this
allows simple consistent parsing everywhere.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix incorrect redirect for map

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix more bugs in maps

This also removes support for the obsolete 'replay' option in visualize.js

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge pull request #24 from dirkhh/moreFixes

More fixes
added contributors to package.json
Always store the charge data

It has higher resolution information on ranges which we can use to do a better
job estimating energy used; the current method occurs too many accumulative
rounding errors as it gets only integer precision kWh used / regenerated every
quarter second; with this data we should also be able to track vampire losses
much more closely. And given the total amount of data we store, this really
doesn't make much difference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also store vehicle state at start so we have firmware version

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Keep map centered on car

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
change most console.log statements to util.log

adds human readable server timestamps (tremendously helps in debugging)
write header line for CSV

Implemented TODO from code (write this line to outfile for csv)
Merge pull request #25 from arthurblake/master

in streaming.js, change most console.log statements to util.log
Merge pull request #26 from dirkhh/charging

Added charging data and vehicle state into database. Keep map display centered on the car.
optionally load user & password from ~/.teslams/config.json

Got tired of having to specify -u and -p every single time
Oops- remove unnecessary extra require statement