Restructure javascript
Create isCordova() function