1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

small code simplification

This commit is contained in:
BendingBender 2014-02-26 00:22:58 +01:00
parent 745c38b758
commit 2e5dbd10b3
3 changed files with 5 additions and 5 deletions

View File

@ -167,7 +167,7 @@
}
// OS version extraction
var osVersion;
var osVersion = '';
if (ios) {
osVersion = getVersion(/os (\d+([_\s]\d+)*) like mac os x/i);
osVersion = osVersion.replace(/[_\s]/g, '.');
@ -189,7 +189,7 @@
}
// device type extraction
var osMajorVersion = (osVersion || '').split('.')[0];
var osMajorVersion = osVersion.split('.')[0];
if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) {
result.tablet = t
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) {

2
bowser.min.js vendored
View File

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

View File

@ -161,7 +161,7 @@
}
// OS version extraction
var osVersion;
var osVersion = '';
if (ios) {
osVersion = getVersion(/os (\d+([_\s]\d+)*) like mac os x/i);
osVersion = osVersion.replace(/[_\s]/g, '.');
@ -183,7 +183,7 @@
}
// device type extraction
var osMajorVersion = (osVersion || '').split('.')[0];
var osMajorVersion = osVersion.split('.')[0];
if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) {
result.tablet = t
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || tizen || mobile) {