You check this a lot in the file. Maybe have a:
var isAndroid = ...; 
at the top of the file.