mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
build v1.0.1
This commit is contained in:
parent
6f151970bf
commit
7d17f92ee5
33
bowser.js
33
bowser.js
@ -30,7 +30,17 @@
|
||||
var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()
|
||||
, likeAndroid = /like android/i.test(ua)
|
||||
, android = !likeAndroid && /android/i.test(ua)
|
||||
, chromeBook = /CrOS/.test(ua)
|
||||
, nexusMobile = /nexus\s*[4-6]\s*/i.test(ua)
|
||||
, nexusTablet = !nexusMobile && /nexus\s*[0-9]+/i.test(ua)
|
||||
, chromeos = /CrOS/.test(ua)
|
||||
, silk = /silk/i.test(ua)
|
||||
, sailfish = /sailfish/i.test(ua)
|
||||
, tizen = /tizen/i.test(ua)
|
||||
, webos = /(web|hpw)os/i.test(ua)
|
||||
, windowsphone = /windows phone/i.test(ua)
|
||||
, windows = !windowsphone && /windows/i.test(ua)
|
||||
, mac = !iosdevice && !silk && /macintosh/i.test(ua)
|
||||
, linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)
|
||||
, edgeVersion = getFirstMatch(/edge\/(\d+(\.\d+)?)/i)
|
||||
, versionIdentifier = getFirstMatch(/version\/(\d+(\.\d+)?)/i)
|
||||
, tablet = /tablet/i.test(ua)
|
||||
@ -51,7 +61,7 @@
|
||||
, version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/windows phone/i.test(ua)) {
|
||||
else if (windowsphone) {
|
||||
result = {
|
||||
name: 'Windows Phone'
|
||||
, windowsphone: t
|
||||
@ -71,9 +81,10 @@
|
||||
, msie: t
|
||||
, version: getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i)
|
||||
}
|
||||
} else if (chromeBook) {
|
||||
} else if (chromeos) {
|
||||
result = {
|
||||
name: 'Chrome'
|
||||
, chromeos: t
|
||||
, chromeBook: t
|
||||
, chrome: t
|
||||
, version: getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)
|
||||
@ -101,7 +112,7 @@
|
||||
result.version = versionIdentifier
|
||||
}
|
||||
}
|
||||
else if (/sailfish/i.test(ua)) {
|
||||
else if (sailfish) {
|
||||
result = {
|
||||
name: 'Sailfish'
|
||||
, sailfish: t
|
||||
@ -125,7 +136,7 @@
|
||||
result.firefoxos = t
|
||||
}
|
||||
}
|
||||
else if (/silk/i.test(ua)) {
|
||||
else if (silk) {
|
||||
result = {
|
||||
name: 'Amazon Silk'
|
||||
, silk: t
|
||||
@ -152,7 +163,7 @@
|
||||
, version: versionIdentifier || getFirstMatch(/blackberry[\d]+\/(\d+(\.\d+)?)/i)
|
||||
}
|
||||
}
|
||||
else if (/(web|hpw)os/i.test(ua)) {
|
||||
else if (webos) {
|
||||
result = {
|
||||
name: 'WebOS'
|
||||
, webos: t
|
||||
@ -167,7 +178,7 @@
|
||||
, version: getFirstMatch(/dolfin\/(\d+(\.\d+)?)/i)
|
||||
};
|
||||
}
|
||||
else if (/tizen/i.test(ua)) {
|
||||
else if (tizen) {
|
||||
result = {
|
||||
name: 'Tizen'
|
||||
, tizen: t
|
||||
@ -207,6 +218,12 @@
|
||||
} else if (iosdevice) {
|
||||
result[iosdevice] = t
|
||||
result.ios = t
|
||||
} else if (windows) {
|
||||
result.windows = t
|
||||
} else if (mac) {
|
||||
result.mac = t
|
||||
} else if (linux) {
|
||||
result.linux = t
|
||||
}
|
||||
|
||||
// OS version extraction
|
||||
@ -233,7 +250,7 @@
|
||||
|
||||
// device type extraction
|
||||
var osMajorVersion = osVersion.split('.')[0];
|
||||
if (tablet || iosdevice == 'ipad' || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || result.silk) {
|
||||
if (tablet || nexusTablet || iosdevice == 'ipad' || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || result.silk) {
|
||||
result.tablet = t
|
||||
} else if (mobile || iosdevice == 'iphone' || iosdevice == 'ipod' || android || result.blackberry || result.webos || result.bada) {
|
||||
result.mobile = t
|
||||
|
2
bowser.min.js
vendored
2
bowser.min.js
vendored
@ -3,4 +3,4 @@
|
||||
* https://github.com/ded/bowser
|
||||
* MIT License | (c) Dustin Diaz 2015
|
||||
*/
|
||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports=t():typeof define=="function"&&define.amd?define(t):this[e]=t()}("bowser",function(){function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}var i=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=/like android/i.test(t),o=!s&&/android/i.test(t),u=/CrOS/.test(t),a=n(/edge\/(\d+(\.\d+)?)/i),f=n(/version\/(\d+(\.\d+)?)/i),l=/tablet/i.test(t),c=!l&&/[^-]mobi/i.test(t),h;/opera|opr/i.test(t)?h={name:"Opera",opera:e,version:f||n(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?h={name:"Yandex Browser",yandexbrowser:e,version:f||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?(h={name:"Windows Phone",windowsphone:e},a?(h.msedge=e,h.version=a):(h.msie=e,h.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?h={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:u?h={name:"Chrome",chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?h={name:"Microsoft Edge",msedge:e,version:a}:/chrome|crios|crmo/i.test(t)?h={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:i?(h={name:i=="iphone"?"iPhone":i=="ipad"?"iPad":"iPod"},f&&(h.version=f)):/sailfish/i.test(t)?h={name:"Sailfish",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?h={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(h={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(h.firefoxos=e)):/silk/i.test(t)?h={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:o?h={name:"Android",version:f}:/phantom/i.test(t)?h={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?h={name:"BlackBerry",blackberry:e,version:f||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(h={name:"WebOS",webos:e,version:f||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(h.touchpad=e)):/bada/i.test(t)?h={name:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?h={name:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||f}:/safari/i.test(t)?h={name:"Safari",safari:e,version:f}:h={name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!h.msedge&&/(apple)?webkit/i.test(t)?(h.name=h.name||"Webkit",h.webkit=e,!h.version&&f&&(h.version=f)):!h.opera&&/gecko\//i.test(t)&&(h.name=h.name||"Gecko",h.gecko=e,h.version=h.version||n(/gecko\/(\d+(\.\d+)?)/i)),!h.msedge&&(o||h.silk)?h.android=e:i&&(h[i]=e,h.ios=e);var p="";h.windowsphone?p=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):i?(p=n(/os (\d+([_\s]\d+)*) like mac os x/i),p=p.replace(/[_\s]/g,".")):o?p=n(/android[ \/-](\d+(\.\d+)*)/i):h.webos?p=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):h.blackberry?p=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):h.bada?p=n(/bada\/(\d+(\.\d+)*)/i):h.tizen&&(p=n(/tizen[\/\s](\d+(\.\d+)*)/i)),p&&(h.osversion=p);var d=p.split(".")[0];if(l||i=="ipad"||o&&(d==3||d==4&&!c)||h.silk)h.tablet=e;else if(c||i=="iphone"||i=="ipod"||o||h.blackberry||h.webos||h.bada)h.mobile=e;return h.msedge||h.msie&&h.version>=10||h.yandexbrowser&&h.version>=15||h.chrome&&h.version>=20||h.firefox&&h.version>=20||h.safari&&h.version>=6||h.opera&&h.version>=10||h.ios&&h.osversion&&h.osversion.split(".")[0]>=6||h.blackberry&&h.version>=10.1?h.a=e:h.msie&&h.version<10||h.chrome&&h.version<20||h.firefox&&h.version<20||h.safari&&h.version<6||h.opera&&h.version<10||h.ios&&h.osversion&&h.osversion.split(".")[0]<6?h.c=e:h.x=e,h}var e=!0,n=t(typeof navigator!="undefined"?navigator.userAgent:"");return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if(typeof r=="string"&&r in n)return!0}return!1},n._detect=t,n})
|
||||
!function(e,t){typeof module!="undefined"&&module.exports?module.exports=t():typeof define=="function"&&define.amd?define(t):this[e]=t()}("bowser",function(){function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}var i=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=/like android/i.test(t),o=!s&&/android/i.test(t),u=/nexus\s*[4-6]\s*/i.test(t),a=!u&&/nexus\s*[0-9]+/i.test(t),f=/CrOS/.test(t),l=/silk/i.test(t),c=/sailfish/i.test(t),h=/tizen/i.test(t),p=/(web|hpw)os/i.test(t),d=/windows phone/i.test(t),v=!d&&/windows/i.test(t),m=!i&&!l&&/macintosh/i.test(t),g=!o&&!c&&!h&&!p&&/linux/i.test(t),y=n(/edge\/(\d+(\.\d+)?)/i),b=n(/version\/(\d+(\.\d+)?)/i),w=/tablet/i.test(t),E=!w&&/[^-]mobi/i.test(t),S;/opera|opr/i.test(t)?S={name:"Opera",opera:e,version:b||n(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?S={name:"Yandex Browser",yandexbrowser:e,version:b||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:d?(S={name:"Windows Phone",windowsphone:e},y?(S.msedge=e,S.version=y):(S.msie=e,S.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?S={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:f?S={name:"Chrome",chromeos:e,chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?S={name:"Microsoft Edge",msedge:e,version:y}:/chrome|crios|crmo/i.test(t)?S={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:i?(S={name:i=="iphone"?"iPhone":i=="ipad"?"iPad":"iPod"},b&&(S.version=b)):c?S={name:"Sailfish",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?S={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(S={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(S.firefoxos=e)):l?S={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:o?S={name:"Android",version:b}:/phantom/i.test(t)?S={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?S={name:"BlackBerry",blackberry:e,version:b||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:p?(S={name:"WebOS",webos:e,version:b||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(S.touchpad=e)):/bada/i.test(t)?S={name:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:h?S={name:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||b}:/safari/i.test(t)?S={name:"Safari",safari:e,version:b}:S={name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!S.msedge&&/(apple)?webkit/i.test(t)?(S.name=S.name||"Webkit",S.webkit=e,!S.version&&b&&(S.version=b)):!S.opera&&/gecko\//i.test(t)&&(S.name=S.name||"Gecko",S.gecko=e,S.version=S.version||n(/gecko\/(\d+(\.\d+)?)/i)),!S.msedge&&(o||S.silk)?S.android=e:i?(S[i]=e,S.ios=e):v?S.windows=e:m?S.mac=e:g&&(S.linux=e);var x="";S.windowsphone?x=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):i?(x=n(/os (\d+([_\s]\d+)*) like mac os x/i),x=x.replace(/[_\s]/g,".")):o?x=n(/android[ \/-](\d+(\.\d+)*)/i):S.webos?x=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):S.blackberry?x=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):S.bada?x=n(/bada\/(\d+(\.\d+)*)/i):S.tizen&&(x=n(/tizen[\/\s](\d+(\.\d+)*)/i)),x&&(S.osversion=x);var T=x.split(".")[0];if(w||a||i=="ipad"||o&&(T==3||T==4&&!E)||S.silk)S.tablet=e;else if(E||i=="iphone"||i=="ipod"||o||S.blackberry||S.webos||S.bada)S.mobile=e;return S.msedge||S.msie&&S.version>=10||S.yandexbrowser&&S.version>=15||S.chrome&&S.version>=20||S.firefox&&S.version>=20||S.safari&&S.version>=6||S.opera&&S.version>=10||S.ios&&S.osversion&&S.osversion.split(".")[0]>=6||S.blackberry&&S.version>=10.1?S.a=e:S.msie&&S.version<10||S.chrome&&S.version<20||S.firefox&&S.version<20||S.safari&&S.version<6||S.opera&&S.version<10||S.ios&&S.osversion&&S.osversion.split(".")[0]<6?S.c=e:S.x=e,S}var e=!0,n=t(typeof navigator!="undefined"?navigator.userAgent:"");return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if(typeof r=="string"&&r in n)return!0}return!1},n._detect=t,n})
|
Loading…
Reference in New Issue
Block a user