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

Fix for missing version in iOS web apps

Also known as home screened app
This commit is contained in:
Sean Soria 2012-01-24 01:58:00 -08:00
parent 551f639021
commit cf3e634570
3 changed files with 31 additions and 29 deletions

View File

@ -33,6 +33,7 @@
, gecko = /gecko\//i.test(ua) , gecko = /gecko\//i.test(ua)
, seamonkey = /seamonkey\//i.test(ua) , seamonkey = /seamonkey\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i , webkitVersion = /version\/(\d+(\.\d+)?)/i
, o
function detect() { function detect() {
@ -45,19 +46,19 @@
, chrome: t , chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
} }
if (iphone) return { if (iphone || ipad) {
o = {
webkit: t webkit: t
, iphone: t
, mobile: t , mobile: t
, ios: t , ios: t
, version: ua.match(webkitVersion)[1] , iphone: iphone
, ipad: ipad
} }
if (ipad) return { // WTF: version is not part of user agent in web apps
webkit: t if (webkitVersion.test(ua)) {
, ipad: t o.version = ua.match(webkitVersion)[1]
, mobile: t }
, ios: t return o
, version: ua.match(webkitVersion)[1]
} }
if (android) return { if (android) return {
webkit: t webkit: t
@ -75,7 +76,7 @@
, version: ua.match(webkitVersion)[1] , version: ua.match(webkitVersion)[1]
} }
if (gecko) { if (gecko) {
var o = { o = {
gecko: t gecko: t
, mozilla: t , mozilla: t
, version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]

2
bowser.min.js vendored
View File

@ -3,4 +3,4 @@
* https://github.com/ded/bowser * https://github.com/ded/bowser
* MIT License | (c) Dustin Diaz 2011 * MIT License | (c) Dustin Diaz 2011
*/ */
!function(a,b){typeof define=="function"?define(b):typeof module!="undefined"&&module.exports?module.exports.browser=b():this[a]=b()}("bowser",function(){function n(){if(c)return{msie:b,version:a.match(/msie (\d+(\.\d+)?);/i)[1]};if(d)return{webkit:b,chrome:b,version:a.match(/chrome\/(\d+(\.\d+)?)/i)[1]};if(f)return{webkit:b,iphone:b,mobile:b,ios:b,version:a.match(m)[1]};if(g)return{webkit:b,ipad:b,mobile:b,ios:b,version:a.match(m)[1]};if(h)return{webkit:b,android:b,mobile:b,version:a.match(m)[1]};if(e)return{webkit:b,safari:b,version:a.match(m)[1]};if(i)return{opera:b,version:a.match(m)[1]};if(k){var n={gecko:b,mozilla:b,version:a.match(/firefox\/(\d+(\.\d+)?)/i)[1]};return j&&(n.firefox=b),n}if(l)return{seamonkey:b,version:a.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}}var a=navigator.userAgent,b=!0,c=/msie/i.test(a),d=/chrome/i.test(a),e=/safari/i.test(a)&&!d,f=/iphone/i.test(a),g=/ipad/i.test(a),h=/android/i.test(a),i=/opera/i.test(a),j=/firefox/i.test(a),k=/gecko\//i.test(a),l=/seamonkey\//i.test(a),m=/version\/(\d+(\.\d+)?)/i,o=n();return o.msie&&o.version>=6||o.chrome&&o.version>=10||o.firefox&&o.version>=4||o.safari&&o.version>=5||o.opera&&o.version>=10?o.a=b:o.msie&&o.version<6||o.chrome&&o.version<10||o.firefox&&o.version<4||o.safari&&o.version<5||o.opera&&o.version<10?o.c=b:o.x=b,o}) !function(a,b){typeof define=="function"?define(b):typeof module!="undefined"&&module.exports?module.exports.browser=b():this[a]=b()}("bowser",function(){function o(){if(c)return{msie:b,version:a.match(/msie (\d+(\.\d+)?);/i)[1]};if(d)return{webkit:b,chrome:b,version:a.match(/chrome\/(\d+(\.\d+)?)/i)[1]};if(f||g)return n={webkit:b,mobile:b,ios:b,iphone:f,ipad:g},m.test(a)&&(n.version=a.match(m)[1]),n;if(h)return{webkit:b,android:b,mobile:b,version:a.match(m)[1]};if(e)return{webkit:b,safari:b,version:a.match(m)[1]};if(i)return{opera:b,version:a.match(m)[1]};if(k)return n={gecko:b,mozilla:b,version:a.match(/firefox\/(\d+(\.\d+)?)/i)[1]},j&&(n.firefox=b),n;if(l)return{seamonkey:b,version:a.match(/seamonkey\/(\d+(\.\d+)?)/i)[1]}}var a=navigator.userAgent,b=!0,c=/msie/i.test(a),d=/chrome/i.test(a),e=/safari/i.test(a)&&!d,f=/iphone/i.test(a),g=/ipad/i.test(a),h=/android/i.test(a),i=/opera/i.test(a),j=/firefox/i.test(a),k=/gecko\//i.test(a),l=/seamonkey\//i.test(a),m=/version\/(\d+(\.\d+)?)/i,n,p=o();return p.msie&&p.version>=6||p.chrome&&p.version>=10||p.firefox&&p.version>=4||p.safari&&p.version>=5||p.opera&&p.version>=10?p.a=b:p.msie&&p.version<6||p.chrome&&p.version<10||p.firefox&&p.version<4||p.safari&&p.version<5||p.opera&&p.version<10?p.c=b:p.x=b,p})

View File

@ -28,6 +28,7 @@
, gecko = /gecko\//i.test(ua) , gecko = /gecko\//i.test(ua)
, seamonkey = /seamonkey\//i.test(ua) , seamonkey = /seamonkey\//i.test(ua)
, webkitVersion = /version\/(\d+(\.\d+)?)/i , webkitVersion = /version\/(\d+(\.\d+)?)/i
, o
function detect() { function detect() {
@ -40,19 +41,19 @@
, chrome: t , chrome: t
, version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/chrome\/(\d+(\.\d+)?)/i)[1]
} }
if (iphone) return { if (iphone || ipad) {
o = {
webkit: t webkit: t
, iphone: t
, mobile: t , mobile: t
, ios: t , ios: t
, version: ua.match(webkitVersion)[1] , iphone: iphone
, ipad: ipad
} }
if (ipad) return { // WTF: version is not part of user agent in web apps
webkit: t if (webkitVersion.test(ua)) {
, ipad: t o.version = ua.match(webkitVersion)[1]
, mobile: t }
, ios: t return o
, version: ua.match(webkitVersion)[1]
} }
if (android) return { if (android) return {
webkit: t webkit: t
@ -70,7 +71,7 @@
, version: ua.match(webkitVersion)[1] , version: ua.match(webkitVersion)[1]
} }
if (gecko) { if (gecko) {
var o = { o = {
gecko: t gecko: t
, mozilla: t , mozilla: t
, version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1] , version: ua.match(/firefox\/(\d+(\.\d+)?)/i)[1]