Add support for touch-enabled devices

Signed-off-by: Martin Koistinen <mkoistinen@gmail.com>
Updated JS as a result of the changes to the CS.
Refactored for DRYer code

Signed-off-by: Martin Koistinen <mkoistinen@gmail.com>