1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00
lancedikson_bowser/bowser.min.js
2014-02-25 01:54:03 +01:00

6 lines
3.3 KiB
JavaScript

/*!
* Bowser - a browser detector
* https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2014
*/
!function(e,t){typeof module!="undefined"&&module.exports?module.exports.browser=t():typeof define=="function"?define(t):this[e]=t()}("bowser",function(){function n(e,t,n){var r=e.match(t);return r&&r.length>n&&r[n]||0}function r(r){var i=/(msie|trident)/i.test(r),s=/chrome|crios|crmo/i.test(r),o=/phantom/i.test(r),u=/iphone/i.test(r),a=/ipad/i.test(r),f=/ipod/i.test(r),l=/silk/i.test(r),c=/safari/i.test(r)&&!s&&!o&&!l,h=/android/i.test(r),p=/opera/i.test(r)||/opr/i.test(r),d=/firefox/i.test(r),m=/gecko\//i.test(r),g=/seamonkey\//i.test(r),y=/(?:web|hpw)os/i.test(r),b=/touchpad\//i.test(r),w=/windows phone/i.test(r),E=/(blackberry|\bbb\d+)/i.test(r),S=/rim\stablet/i.test(r),x=/bada\//i.test(r),T=/version\/(\d+(\.\d+)?)/i,N=/firefox[ \/](\d+(\.\d+)?)/i,C=/mobi/i.test(r),k=/tablet/i.test(r),L={};f&&(u=!1);if(w)L={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,T,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),L={name:"Opera",opera:e,version:t},h&&(L.android=e),s&&(L.webkit=e);else if(i)L={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){L={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(L.android=e);if(a||f||u)L[u?"iphone":a?"ipad":"ipod"]=e,L.ios=e}else o?L={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?L={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(L={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},L[u?"iphone":a?"ipad":"ipod"]=e,T.test(r)&&(L.version=n(r,T,1))):E||S?(L={name:"BlackBerry",blackberry:e},(t=n(r,T,1))?(L.version=t,L.webkit=e):L.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(L={name:"WebOS",webkit:e,webos:e,version:n(r,T,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(L.touchpad=e)):x?L={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)}:m?(L={name:"Gecko",gecko:e,mozilla:e,version:n(r,N,1)},g?(L.name="SeaMonkey",L.seamonkey=e,L.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(L.name="Firefox",L.firefox=e),h?L.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(L.firefoxos=e)):h?L={name:"Android",webkit:e,android:e,version:n(r,T,1)}:c&&(L={name:"Safari",webkit:e,safari:e,version:n(r,T,1)});var A;h?(A=n(r,/android[ \/-](\d+(\.\d+)*)/i,1),A&&(L.osversion=A)):u||a||f?(A=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),A=(A||"").replace(/[_\s]/g,".")):w?A=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?A=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?A=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x&&(A=n(r,/bada\/(\d+(\.\d+)*)/i,1)),A&&(L.osversion=A);var O=(A||"").split(".")[0];if(k||a||h&&(O==3||O==4&&!C)||S||l||b)L.tablet=e;else if(u||f||h&&C||w||E||y||x||C)L.mobile=e;return L.msie&&L.version>=9||L.chrome&&L.version>=20||L.firefox&&L.version>=10||L.safari&&L.version>=5||L.opera&&L.version>=10||L.ios&&L.osversion&&L.osversion.split(".")[0]>=6?L.a=e:L.msie&&L.version<9||L.chrome&&L.version<20||L.firefox&&L.version<10||L.safari&&L.version<5||L.opera&&L.version<10||L.ios&&L.osversion&&L.osversion.split(".")[0]<6?L.c=e:L.x=e,L}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i})