converting into Phonegap plugin