forked from terkel/jquery-ua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.ua.min.js
8 lines (8 loc) · 2.9 KB
/
jquery.ua.min.js
1
2
3
4
5
6
7
8
/*!
* jQuery UA plugin v0.9.7
* https://github.com/terkel/jquery-ua
*
* Copyright (c) 2012 Takeru Suzuki - http://terkel.jp/
* Licensed under the MIT license - http://www.opensource.org/licenses/MIT
*/
(function(i){var g,e,c;i.ua=i.ua||{init:function(){g=this.platform=this.detect(this.data.platforms);e=this.browser=this.detect(this.data.browsers);c=this.engine=this.detect(this.data.engines)},detect:function(e){var j=navigator.userAgent.toLowerCase(),a={},b,h,f,d,c,g;c=0;for(g=e.length;c<g;c++)if(d=e[c],b=d.name,h=d.versionSearch,f=d.flags,d=d.versionNames,-1!==j.indexOf(b)){a.name=b.replace(/\s/g,"");a[a.name]=!0;a.version=(""+(RegExp(h+"(\\d+((\\.|_)\\d+)*)").exec(j)||[,0])[1]).replace(/_/g,".");a.versionMajor=parseInt(a.version,10);if(f){b=0;for(h=f.length;b<h;b++)a[f[b]]=!0}if(d){b=0;for(h=d.length;b<h;b++)if(f=d[b],0===a.version.indexOf(f.number)){a.versionName=f.name;a[a.versionName]=!0;break}}e===i.ua.data.platforms&&(a.mobile=/mobile|phone/.test(j)||a.blackberry,a.tablet=/tablet/.test(j)||a.ipad||a.android&&!/mobile/.test(j),a.ios&&(a.versionName="ios"+a.versionMajor));break}a.name||(a.unknown=!0,a.name="",a.version="",a.versionMajor="");return a},data:{platforms:[{name:"windows phone",versionSearch:"windows phone os ",versionNames:[{number:"7.5",name:"mango"}]},{name:"win",versionSearch:"windows(?: nt)? ",versionNames:[{number:"6.2",name:"win8"},{number:"6.1",name:"win7"},{number:"6.0",name:"winvista"},{number:"5.2",name:"winxp"},{number:"5.1",name:"winxp"},{number:"5.0",name:"win2000"}]},{name:"ipad",versionSearch:"cpu os ",flags:["ios"]},{name:"ipod",versionSearch:"iphone os ",flags:["ios"]},{name:"iphone",versionSearch:"iphone os ",flags:["ios"]},{name:"mac",versionSearch:"os x ",versionNames:[{number:"10.8",name:"mountainlion"},{number:"10.7",name:"lion"},{number:"10.6",name:"snowleopard"},{number:"10.5",name:"leopard"},{number:"10.4",name:"tiger"},{number:"10.3",name:"panther"},{number:"10.2",name:"jaguar"},{number:"10.1",name:"puma"},{number:"10.0",name:"cheetah"}]},{name:"android",versionSearch:"android ",versionNames:[{number:"4.1",name:"jellybean"},{number:"4.0",name:"icecreamsandwich"},{number:"3.",name:"honeycomb"},{number:"2.3",name:"gingerbread"},{number:"2.2",name:"froyo"},{number:"2.",name:"eclair"},{number:"1.6",name:"donut"},{number:"1.5",name:"cupcake"}]},{name:"blackberry",versionSearch:"(?:blackberry\\d{4}[a-z]?|version)/"},{name:"linux"}],browsers:[{name:"iemobile",versionSearch:"iemobile/"},{name:"msie",versionSearch:"msie "},{name:"firefox",versionSearch:"firefox/"},{name:"chrome",versionSearch:"chrome/"},{name:"safari",versionSearch:"version/"},{name:"opera",versionSearch:"version/"}],engines:[{name:"trident",versionSearch:"trident/"},{name:"webkit",versionSearch:"webkit/"},{name:"gecko",versionSearch:"rv:"},{name:"presto",versionSearch:"presto/"}]}};i.ua.init();i("html").addClass([g.name,g.versionName,e.name,e.name+e.versionMajor,c.name,c.name+c.versionMajor].join(" "))})(jQuery);