|
1 |
| -/* browser.js v1.0.1 | @ajlkn | MIT licensed */ |
2 |
| -var browser=function(){"use strict";var t={name:null,version:null,os:null,osVersion:null,touch:null,mobile:null,_canUse:null,canUse:function(e){t._canUse||(t._canUse=document.createElement("div"));var n=t._canUse.style,r=e.charAt(0).toUpperCase()+e.slice(1);return e in n||"Moz"+r in n||"Webkit"+r in n||"O"+r in n||"ms"+r in n},init:function(){for(var e=navigator.userAgent,n="other",r=0,i=[["firefox",/Firefox\/([0-9\.]+)/],["bb",/BlackBerry.+Version\/([0-9\.]+)/],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/],["opera",/OPR\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)/],["edge",/Edge\/([0-9\.]+)/],["safari",/Version\/([0-9\.]+).+Safari/],["chrome",/Chrome\/([0-9\.]+)/],["ie",/MSIE ([0-9]+)/],["ie",/Trident\/.+rv:([0-9]+)/]],o=0;o<i.length;o++)if(e.match(i[o][1])){n=i[o][0],r=parseFloat(RegExp.$1);break}for(t.name=n,t.version=r,n="other",i=[["ios",/([0-9_]+) like Mac OS X/,function(e){return e.replace("_",".").replace("_","")}],["ios",/CPU like Mac OS X/,function(e){return 0}],["wp",/Windows Phone ([0-9\.]+)/,null],["android",/Android ([0-9\.]+)/,null],["mac",/Macintosh.+Mac OS X ([0-9_]+)/,function(e){return e.replace("_",".").replace("_","")}],["windows",/Windows NT ([0-9\.]+)/,null],["bb",/BlackBerry.+Version\/([0-9\.]+)/,null],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/,null],["linux",/Linux/,null],["bsd",/BSD/,null],["unix",/X11/,null]],o=r=0;o<i.length;o++)if(e.match(i[o][1])){n=i[o][0],r=parseFloat(i[o][2]?i[o][2](RegExp.$1):RegExp.$1);break}"mac"==n&&"ontouchstart"in window&&(1024==screen.width&&1366==screen.height||834==screen.width&&1112==screen.height||810==screen.width&&1080==screen.height||768==screen.width&&1024==screen.height)&&(n="ios"),t.os=n,t.osVersion=r,t.touch="wp"==t.os?0<navigator.msMaxTouchPoints:!!("ontouchstart"in window),t.mobile="wp"==t.os||"android"==t.os||"ios"==t.os||"bb"==t.os}};return t.init(),t}();!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?module.exports=n():e.browser=n()}(this,function(){return browser}); |
| 1 | +/* browser.js v1.0.1 | @ajlkn | MIT licensed */ |
| 2 | +var browser = (function () { |
| 3 | + "use strict"; |
| 4 | + var t = { |
| 5 | + name: null, |
| 6 | + version: null, |
| 7 | + os: null, |
| 8 | + osVersion: null, |
| 9 | + touch: null, |
| 10 | + mobile: null, |
| 11 | + _canUse: null, |
| 12 | + canUse: function (e) { |
| 13 | + t._canUse || (t._canUse = document.createElement("div")); |
| 14 | + var n = t._canUse.style, |
| 15 | + r = e.charAt(0).toUpperCase() + e.slice(1); |
| 16 | + return e in n || "Moz" + r in n || "Webkit" + r in n || "O" + r in n || "ms" + r in n; |
| 17 | + }, |
| 18 | + init: function () { |
| 19 | + for ( |
| 20 | + var e = navigator.userAgent, |
| 21 | + n = "other", |
| 22 | + r = 0, |
| 23 | + i = [ |
| 24 | + ["firefox", /Firefox\/([0-9\.]+)/], |
| 25 | + ["bb", /BlackBerry.+Version\/([0-9\.]+)/], |
| 26 | + ["bb", /BB[0-9]+.+Version\/([0-9\.]+)/], |
| 27 | + ["opera", /OPR\/([0-9\.]+)/], |
| 28 | + ["opera", /Opera\/([0-9\.]+)/], |
| 29 | + ["edge", /Edge\/([0-9\.]+)/], |
| 30 | + ["safari", /Version\/([0-9\.]+).+Safari/], |
| 31 | + ["chrome", /Chrome\/([0-9\.]+)/], |
| 32 | + ["ie", /MSIE ([0-9]+)/], |
| 33 | + ["ie", /Trident\/.+rv:([0-9]+)/], |
| 34 | + ], |
| 35 | + o = 0; |
| 36 | + o < i.length; |
| 37 | + o++ |
| 38 | + ) |
| 39 | + if (e.match(i[o][1])) { |
| 40 | + (n = i[o][0]), (r = parseFloat(RegExp.$1)); |
| 41 | + break; |
| 42 | + } |
| 43 | + for ( |
| 44 | + t.name = n, |
| 45 | + t.version = r, |
| 46 | + n = "other", |
| 47 | + i = [ |
| 48 | + [ |
| 49 | + "ios", |
| 50 | + /([0-9_]+) like Mac OS X/, |
| 51 | + function (e) { |
| 52 | + return e.replace("_", ".").replace("_", ""); |
| 53 | + }, |
| 54 | + ], |
| 55 | + [ |
| 56 | + "ios", |
| 57 | + /CPU like Mac OS X/, |
| 58 | + function (e) { |
| 59 | + return 0; |
| 60 | + }, |
| 61 | + ], |
| 62 | + ["wp", /Windows Phone ([0-9\.]+)/, null], |
| 63 | + ["android", /Android ([0-9\.]+)/, null], |
| 64 | + [ |
| 65 | + "mac", |
| 66 | + /Macintosh.+Mac OS X ([0-9_]+)/, |
| 67 | + function (e) { |
| 68 | + return e.replace("_", ".").replace("_", ""); |
| 69 | + }, |
| 70 | + ], |
| 71 | + ["windows", /Windows NT ([0-9\.]+)/, null], |
| 72 | + ["bb", /BlackBerry.+Version\/([0-9\.]+)/, null], |
| 73 | + ["bb", /BB[0-9]+.+Version\/([0-9\.]+)/, null], |
| 74 | + ["linux", /Linux/, null], |
| 75 | + ["bsd", /BSD/, null], |
| 76 | + ["unix", /X11/, null], |
| 77 | + ], |
| 78 | + o = r = 0; |
| 79 | + o < i.length; |
| 80 | + o++ |
| 81 | + ) |
| 82 | + if (e.match(i[o][1])) { |
| 83 | + (n = i[o][0]), (r = parseFloat(i[o][2] ? i[o][2](RegExp.$1) : RegExp.$1)); |
| 84 | + break; |
| 85 | + } |
| 86 | + "mac" == n && |
| 87 | + "ontouchstart" in window && |
| 88 | + ((1024 == screen.width && 1366 == screen.height) || |
| 89 | + (834 == screen.width && 1112 == screen.height) || |
| 90 | + (810 == screen.width && 1080 == screen.height) || |
| 91 | + (768 == screen.width && 1024 == screen.height)) && |
| 92 | + (n = "ios"), |
| 93 | + (t.os = n), |
| 94 | + (t.osVersion = r), |
| 95 | + (t.touch = "wp" == t.os ? 0 < navigator.msMaxTouchPoints : !!("ontouchstart" in window)), |
| 96 | + (t.mobile = "wp" == t.os || "android" == t.os || "ios" == t.os || "bb" == t.os); |
| 97 | + }, |
| 98 | + }; |
| 99 | + return t.init(), t; |
| 100 | +})(); |
| 101 | +!(function (e, n) { |
| 102 | + "function" == typeof define && define.amd |
| 103 | + ? define([], n) |
| 104 | + : "object" == typeof exports |
| 105 | + ? (module.exports = n()) |
| 106 | + : (e.browser = n()); |
| 107 | +})(this, function () { |
| 108 | + return browser; |
| 109 | +}); |
0 commit comments