-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.supportdetection.min.js
More file actions
20 lines (20 loc) · 4.85 KB
/
jquery.supportdetection.min.js
File metadata and controls
20 lines (20 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
Project Name: Support Detection
URL: https://github.com/keobrien/Support-Detection
Author: Kevin O'Brien
Company: Clockwork Acive Media Systems
Company Site: clockwork.net
License: MIT
Copyright (C) 2012 Clockwork Active Media Systems
Version: .1
**************************************/
(function(b){b.fn.supportdetection=function(a){return new b.supportdetection(b(this),a)};b.supportdetection=function(a,c){this.el=a;this.s=b.extend({cookies:!0,mookie_msg:'<p id="support-cookies">Cookies have to be enabled to view this site. Learn <a href="http://support.google.com/accounts/bin/answer.py?hl=en&answer=61416" target="_blank">how to enable cookies</a>.</p>',safari:531,safari_human:5,chrome:535,chrome_human:19,msie:7,msie_human:7,firefox:12,firefox_human:12,opera:!1,opera_human:null,
browser_msg:'<p id="support-browser">This is site will look and function best using the most updated version of your browser. You can download the latest version of <a href="http://www.google.com/chrome">Google Chrome</a> or <a href="http://www.mozilla.org/en-US/firefox/new/">Firefox</a> to have the best experience.</p>',test_browser:!1,ipad:534,ipod:6533,iphone:6533,android:533,blackberry:!1,windows_phone:!1,test_device:!1,ipad_os:4.3,ipod_os:4.3,iphone_os:4.3,android_os:2.3,blackberry_os:!1,windows_phone_os:!1,
device_msg:'<p id="support-device">This is site may look and function best using the most updated version of your operating system.</p>',test_mobile_os:!1,show_supported:!1},c);this.uagent=navigator.userAgent.toLowerCase();this.mobile=!1;this.found={};this.not_supported=[];this.test_cookies();this.test_devices();this.mobile?(this.get_os_version(),this.s.test_mobile_os&&this.test_os_version()):this.s.test_browser&&this.test_browsers();this.s.show_supported&&0<this.not_supported.length&&this.show_supported();
return this};b.supportdetection.prototype={test_cookies:function(){var a=navigator.cookieEnabled?!0:!1;"undefined"==typeof navigator.cookieEnabled&&!a&&(document.cookie="testcookie",a=-1!=document.cookie.indexOf("testcookie")?!0:!1);!a&&this.s.cookies&&(this.el.append(this.s.mookie_msg).show(),this.not_supported.push("cookies"))},get_os_version:function(){if("blackberry"==this.found.device)if(0<=this.uagent.indexOf("version/")){var a=this.uagent.indexOf("version/")+8;this.found.os=parseInt(this.uagent.substring(a,
a+3))}else this.found.os=parseInt(this.uagent.split("/")[1].substring(0,3));else"android"==this.found.device?this.found.os=parseInt(this.uagent.toString().split(";")[2].replace(/android/g,"").replace(/ /g,"")):"ipad"==this.found.device||"ipod"==this.found.device||"iphone"==this.found.device?this.found.os=parseInt(this.uagent.toString().split(")")[0].split("os ")[1].split(" ")[0].replace("_",".")):"windows_phone"==this.found.device&&(this.found.os=parseInt(this.uagent.toString().split(";")[2].split("os ")[1]));
this.found.os_supported=this.s[this.found.device+"_os"]},test_os_version:function(){this.s[this.found.device+"_os"]&&this.found.os<this.found.os_supported&&this.devive_not_supported(this.found.device.toString()+"_os")},test_devices:function(){for(var a="ipad;ipod;iphone;android;blackberry;windows phone".split(";"),c=0;c<a.length;c++)if(-1<this.uagent.indexOf(a[c])){this.test_device_version(a[c].replace(" ","_"));break}-1<this.uagent.indexOf("iemobile")&&this.test_device_version("windows_phone")},
test_device_version:function(a){this.mobile=!0;this.found.device=a;this.found.browser_version=b.browser.version;this.found.supported_browser_version=this.s[a];!this.s.test_mobile_os&&this.s.test_device&&(!this.s[a]||b.browser.version<this.s[a])&&this.devive_not_supported(a)},test_browsers:function(){var a=-1<this.uagent.indexOf("chrome"),c=-1<this.uagent.indexOf("safari");a&&c&&(c=!1);b.browser.msie?this.test_browser_version("msie"):b.browser.mozilla?this.test_browser_version("mozilla"):b.browser.opera?
this.test_browser_version("opera"):!c&&b.browser.webkit?this.test_browser_version("chrome"):c?this.test_browser_version("safari"):this.browser_not_supported("unknown")},test_browser_version:function(a){this.found.browser=a;this.found.browser_version=b.browser.version;this.found.supported_browser_version=this.s[a];this.s[a]&&b.browser.version<this.s[a]&&this.browser_not_supported(a)},browser_not_supported:function(a){this.el.append(this.s.browser_msg).show();this.not_supported.push(a)},devive_not_supported:function(a){this.el.append(this.s.device_msg).show();
this.not_supported.push(a)},show_supported:function(){for(var a="",c=["safari","chrome","msie","firefox","opera"],b=0;b<c.length;b++){var d=this.s[c[b]];a&&d&&(a+=", ");!a&&d&&(a+="Desktop: ");d&&(a+=c[b]+" "+this.s[c[b]+"_human"]+"+")}this.el.append("<p>"+a+"</p>");a="";c="ipad_os ipod_os iphone_os android_os blackberry_os windows_phone_os".split(" ");for(b=0;b<c.length;b++)d=this.s[c[b]],a&&d&&(a+=", "),!a&&d&&(a+="Mobile: "),d&&(a+=c[b].replace("_os","")+" "+this.s[c[b]]+"+");this.el.append("<p>"+
a+"</p>").show()}}})(jQuery);