Added device query functionality from task1
Extracted out a lot of JS into common.js