mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
f07d14b89a
Conflicts: bowser.min.js
6 lines
3.4 KiB
JavaScript
6 lines
3.4 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|iceweasel)/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=/tizen/i.test(r),N=/version\/(\d+(\.\d+)?)/i,C=/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i,k=/mobi/i.test(r),L=/tablet/i.test(r),A={};f&&(u=!1);if(w)A={name:"Windows Phone",windowsphone:e,msie:e,version:n(r,/iemobile\/(\d+(\.\d+)?)/i,1)};else if(p)t=n(r,N,1)||n(r,/opr\/(\d+(\.\d+)?)/i,1)||n(r,/opera[ \/](\d+(\.\d+)?)/i,1),A={name:"Opera",opera:e,version:t},h&&(A.android=e),s&&(A.webkit=e);else if(i)A={name:"Internet Explorer",msie:e,version:n(r,/(msie |rv:)(\d+(\.\d+)?)/i,2)};else if(s){A={name:"Chrome",webkit:e,chrome:e,version:n(r,/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i,1)},h&&(A.android=e);if(a||f||u)A[u?"iphone":a?"ipad":"ipod"]=e,A.ios=e}else o?A={name:"PhantomJS",webkit:e,phantom:e,version:n(r,/phantomjs\/(\d+(\.\d+)?)/i,1)}:l?A={name:"Amazon Silk",silk:e,webkit:e,android:e,version:n(r,/silk\/(\d+(\.\d+)?)/i,1)}:u||a||f?(A={name:u?"iPhone":a?"iPad":"iPod",webkit:e,ios:e},A[u?"iphone":a?"ipad":"ipod"]=e,N.test(r)&&(A.version=n(r,N,1))):E||S?(A={name:"BlackBerry",blackberry:e},(t=n(r,N,1))?(A.version=t,A.webkit=e):A.version=n(r,/blackberry[\d]+\/(\d+(\.\d+)?)/i,1)):y?(A={name:"WebOS",webkit:e,webos:e,version:n(r,N,1)||n(r,/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i,1)},b&&(A.touchpad=e)):x?A={name:"Bada",webkit:e,bada:e,version:n(r,/dolfin\/(\d+(\.\d+)?)/i,1)}:T?A={name:"Tizen",webkit:e,tizen:e,version:n(r,/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i,1)||n(r,N,1)}:m?(A={name:"Gecko",gecko:e,mozilla:e,version:n(r,C,1)},g?(A.name="SeaMonkey",A.seamonkey=e,A.version=n(r,/seamonkey\/(\d+(\.\d+)?)/i,1)):d&&(A.name="Firefox",A.firefox=e),h?A.android=e:!h&&d&&/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(r)&&(A.firefoxos=e)):h?A={name:"Android",webkit:e,android:e,version:n(r,N,1)}:c&&(A={name:"Safari",webkit:e,safari:e,version:n(r,N,1)});var O;T?O=n(r,/tizen[\/\s](\d+(\.\d+)*)/i,1):w?O=n(r,/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,1):y?O=n(r,/(?:web|hpw)os\/(\d+(\.\d+)*)/i,1):S?O=n(r,/rim\stablet\sos\s(\d+(\.\d+)*)/i,1):x?O=n(r,/bada\/(\d+(\.\d+)*)/i,1):u||a||f?(O=n(r,/os (\d+([_\s]\d+)*) like mac os x/i,1),O=(O||"").replace(/[_\s]/g,".")):h&&(O=n(r,/android[ \/-](\d+(\.\d+)*)/i,1)),O&&(A.osversion=O);var M=(O||"").split(".")[0];if(L||a||h&&(M==3||M==4&&!k)||S||l||b)A.tablet=e;else if(u||f||h&&k||w||E||y||x||T||k)A.mobile=e;return A.msie&&A.version>=9||A.chrome&&A.version>=20||A.firefox&&A.version>=10||A.safari&&A.version>=5||A.opera&&A.version>=10||A.ios&&A.osversion&&A.osversion.split(".")[0]>=6?A.a=e:A.msie&&A.version<9||A.chrome&&A.version<20||A.firefox&&A.version<10||A.safari&&A.version<5||A.opera&&A.version<10||A.ios&&A.osversion&&A.osversion.split(".")[0]<6?A.c=e:A.x=e,A}var e=!0,t,i=r(typeof navigator!="undefined"?navigator.userAgent:"");return i._detect=r,i}) |