Skip to content

Instantly share code, notes, and snippets.

@jun-lu
Last active August 29, 2015 14:01
Show Gist options
  • Save jun-lu/460f0f9d11f1bbdcabc5 to your computer and use it in GitHub Desktop.
Save jun-lu/460f0f9d11f1bbdcabc5 to your computer and use it in GitHub Desktop.
getClientVersions:function(){
if( this.isInJuhuasuanAPP() ){
var ua = navigator.userAgent;
var regs = [/\@juhuasuan_iphone_(\d\.\d)/, /AliApp\(JU\/(\d\.\d)/];
var arr = null;//ua.match( v2d5 );
var i =0;
while( (arr == null || arr[1] == undefined) && regs.length > i){
arr = ua.match(regs[i]);
i++;
if(arr && arr[1]){
return parseFloat(arr[1]);
}
}
// android 2.5 没有 ua 信息
return 2.4;
}
return null;
},
isInJuhuasuanAPP:function(){
var ua = navigator.userAgent;
// ios 2.5 , ios 2.6 andriod 2.6
var is = ua.indexOf("@juhuasuan_iphone") != -1 || ua.indexOf("AliApp(JU/") != -1;
// android 2.5
if( !is ){
if( this.isInAndroidSystem() && ua.indexOf('WindVane/2.7.0') != -1){
is = true;
}
}
return is;
},
isInIOSSystem:function(){
var ua = navigator.userAgent;
return ua.indexOf("iPhone") != -1 || ua.indexOf("iPad") != -1;
},
isInAndroidSystem:function(){
return navigator.userAgent.indexOf("Android ") != -1;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment