JAVASCRIPT   24

detect.js

Guest on 4th August 2021 02:31:15 PM

  1. function Detect(){playerVersion=[0,0,0];this.ua=navigator.userAgent.toLowerCase();var j=navigator.platform.toLowerCase(),b=this.ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0];if("undefined"!=typeof navigator.plugins&&"object"==typeof navigator.plugins["Shockwave Flash"]){if((d=navigator.plugins["Shockwave Flash"].description)&&!("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&
  2. !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin))plugin=!0,ie=!1,d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),playerVersion[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10),playerVersion[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10),playerVersion[2]=/[a-zA-Z]/.test(d)?parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}else if("undefined"!=typeof window.ActiveXObject)try{var g=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(g&&(d=g.GetVariable("$version")))ie=!0,d=d.split(" ")[1].split(","),
  3. playerVersion=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)]}catch(r){}this.flash=0===playerVersion[0]&&0===playerVersion[1]&&0===playerVersion[2]?!1:!0;this.flashVer=playerVersion[0]+"."+playerVersion[1]+"."+playerVersion[2];this.browser={};this.platform={};this.device={};this.features={};this.browser.name="version"==b[1]?b[3]:b[1];this.browser.name="unknown"==this.browser.name?"safari":this.browser.name;this.browser[this.browser.name]=!0;mode="ie"==b[1]&&document.documentMode;this.browser.version=
  4. mode||parseFloat("opera"==b[1]&&b[4]?b[4]:b[2]);this.platform.name=this.ua.match(/ip(?:ad|od|hone)/)?"ios":this.ua.match(/(?:msie 9)/)?"wphone":(this.ua.match(/(?:webos|android|bada|symbian|palm|blackberry)/)||j.match(/mac|win|linux/)||["other"])[0];this.platform[this.platform.name]=!0;this.platform.version=0;if(this.platform.mac)b=this.ua.match(/os\sx\s(\d+[\._]*\d*[\._]*\d*)/),this.platform.version=fbUtils.isArray(b)&&1<b.length?b[1].split(/[\._]/):0;else if(this.platform.ios)b=this.ua.match(/os\s(\d+_*\d*_*\d*)/),
  5. this.platform.version=fbUtils.isArray(b)&&1<b.length?b[1].split("_"):0;else if(this.platform.android)b=this.ua.match(/android\s(\d+\.*\d*\.*\d*)/),this.platform.version=fbUtils.isArray(b)&&1<b.length?b[1].split("."):0;this.platform.verCheck=function(b){return 1*this.platform.version==1*b?0:1*b>1*this.platform.version?-1:1};this.device.name=this.ua.match(/ipad/)?"ipad":this.ua.match(/ipad/)?"ipad":this.ua.match(/iphone/)?"iphone":this.ua.match(/android/)?"android":j.match(/mac|win|linux/)?"pc":"other";
  6. this.device[this.device.name]=!0;this.device.version=this.platform.version[0];this.device.type=this.ua.match(/(mobile\ssafari)|iphone|ipod/)?"mobile":"tablet";this.device.vendor=this.ua.match(/sony/)?"sony":this.ua.match(/htc/)?"htc":this.ua.match(/samsung/)?"samsung":this.ua.match(/lg/)?"lg":this.ua.match(/apple/)?"apple":"other";try{this.platform.name="android"==preview.get_Type()?"android":"ios",this.platform[this.platform.name]=!0,this.device.name=preview.get_Type(),this.device[this.device.name]=
  7. !0,this.device.type="android"==this.platform.name?"mobile":this.device.ipad?"tablet":"mobile"}catch(k){}this.isBasic=this.isFlash=this.isMobile=!1;this.platform.ios||this.platform.blackberry?this.isMobile=!0:(this.platform.ios||this.platform.android)&&(this.browser.safari||this.browser.chrome)?this.isMobile=!0:this.platform.android?this.isBasic=!0:(this.device.pc||this.device.other)&&!this.flash?this.isBasic=!0:this.isFlash=!0;this.isTablet="ipad"==this.device.name||3==this.device.version?!0:!1;var a=
  8. this;this.init=function(){a.device.width=window.innerWidth;a.device.height=window.innerHeight;customEvents.addListener(ROTATE_DEVICE,function(){a.device.width=window.innerWidth;a.device.height=window.innerHeight});if(a.platform.android){if(window.innerWidth>window.innerHeight)a.device.orientation="landscape";if(window.innerWidth<window.innerHeight)a.device.orientation="portrait"}else if(a.platform.ios){if(window.innerWidth>window.innerHeight)a.device.orientation="landscape";if(window.innerWidth<window.innerHeight)a.device.orientation=
  9. "portrait"}else a.device.orientation=!1;a.isInit=!0}}
  10. window.Modernizr=function(j,b,g){function r(i,c){for(var b in i){var a=i[b];if(!~(""+a).indexOf("-")&&w[a]!==g)return"pfx"==c?a:!0}return!1}function k(i,c,b){var a=i.charAt(0).toUpperCase()+i.slice(1),h=(i+" "+x.join(a+" ")+a).split(" ");if("string"===typeof c||"undefined"===typeof c)c=r(h,c);else{h=(i+" "+y.join(a+" ")+a).split(" ");a:{var i=h,e;for(e in i)if(a=c[i[e]],a!==g){c=!1===b?i[e]:"function"===typeof a?a.bind(b||c):a;break a}c=!1}}return c}var a={},n=b.documentElement,e=b.createElement("modernizr"),
  11. w=e.style,z=" -webkit- -moz- -o- -ms- ".split(" "),x="Webkit Moz O ms".split(" "),y="webkit moz o ms".split(" "),e={},A=[],s=A.slice,p,t=function(a,c,f,e){var h,g,j,k,l=b.createElement("div"),o=b.body,m=o||b.createElement("body");if(parseInt(f,10))for(;f--;)j=b.createElement("div"),j.id=e?e[f]:"modernizr"+(f+1),l.appendChild(j);return h=['&#173;<style id="smodernizr">',a,"</style>"].join(""),l.id="modernizr",(o?l:m).innerHTML+=h,m.appendChild(l),o||(m.style.background="",m.style.overflow="hidden",
  12. k=n.style.overflow,n.style.overflow="hidden",n.appendChild(m)),g=c(l,a),o?l.parentNode.removeChild(l):(m.parentNode.removeChild(m),n.style.overflow=k),!!g},B=function(){var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return function(c,f){f=f||b.createElement(a[c]||"div");c="on"+c;var e=c in f;return e||(f.setAttribute||(f=b.createElement("div")),f.setAttribute&&f.removeAttribute&&(f.setAttribute(c,""),e="function"===typeof f[c],"undefined"===typeof f[c]||
  13. (f[c]=g),f.removeAttribute(c))),e}}(),u={}.hasOwnProperty,q;"undefined"!==typeof u&&"undefined"!==typeof u.call?q=function(a,c){return u.call(a,c)}:q=function(a,c){return c in a&&"undefined"===typeof a.constructor.prototype[c]};Function.prototype.bind||(Function.prototype.bind=function(a){var c=this;if("function"!=typeof c)throw new TypeError;var b=s.call(arguments,1),e=function(){if(this instanceof e){var h=function(){};h.prototype=c.prototype;var h=new h,g=c.apply(h,b.concat(s.call(arguments)));
  14. return Object(g)===g?g:h}return c.apply(a,b.concat(s.call(arguments)))};return e});e.touch=function(){var a;return"ontouchstart"in j||j.DocumentTouch&&b instanceof DocumentTouch?a=!0:t(["@media (",z.join("touch-enabled),("),"modernizr){#modernizr{top:9px;position:absolute}}"].join(""),function(c){a=9===c.offsetTop}),a};e.hashchange=function(){return B("hashchange",j)&&(b.documentMode===g||7<b.documentMode)};e.csstransforms=function(){return!!k("transform")};e.csstransforms3d=function(){var a=!!k("perspective");
  15. return a&&"webkitPerspective"in n.style&&t("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(c){a=9===c.offsetLeft&&3===c.offsetHeight}),a};e.csstransitions=function(){return k("transition")};for(var v in e)q(e,v)&&(p=v.toLowerCase(),a[p]=e[v](),A.push((a[p]?"":"no-")+p));a.addTest=function(b,c){if("object"==typeof b)for(var e in b)q(b,e)&&a.addTest(e,b[e]);else{b=b.toLowerCase();if(a[b]!==g)return a;c="function"==typeof c?c():c;"undefined"!=
  16. typeof enableClasses&&enableClasses&&(n.className+=" "+(c?"":"no-")+b);a[b]=c}return a};w.cssText="";return e=null,a._version="2.6.2",a._prefixes=z,a._domPrefixes=y,a._cssomPrefixes=x,a.hasEvent=B,a.testProp=function(a){return r([a])},a.testAllProps=k,a.testStyles=t,a}(this,this.document);

Raw Paste


Login or Register to edit or fork this paste. It's free.