Commits

Stephen McKamey committed 5f44a35

JSDocs cleanup & improved Silk support

Comments (0)

Files changed (6)

 	User-agent specific CSS support
 
 	Created: 2006-06-10-1635
-	Modified: 2012-09-09-2120
+	Modified: 2012-09-27-2335
 
 	Copyright (c)2006-2012 Stephen M. McKamey
 	Distributed under The MIT License.
 */
 
-var cssua = (function(html, userAgent) {
+/**
+ * @type {Object}
+ */
+var cssua = (
+
+/**
+ * @param html {Object} root DOM element
+ * @param userAgent {string} browser userAgent string
+ * @return {Object}
+ */
+function(html, userAgent) {
 	'use strict';
 
-	/*const string*/ var PREFIX = ' ua-';
-
 	/*jslint regexp: false, browser: true */
 
-	var R_Top = /^([^(]+)\((.+)\)(.*)$/,
-		R_Platform = /\s*([\-\w ]+)[\s\/]([\d_]+\b([\-\._\/]\w+)*)/,
-		R_Version = /([\w\-\.]+[\s\/][v]?[\d_]+\b([\-\._\/]\w+)*)/g,
+	/**
+	 * @const
+	 * @type {string}
+	 */
+	var PREFIX = ' ua-';
 
-		R_FluidApp = /\bfluidapp\b/,
-		R_Gecko = /rv[:](\d+(\.\w+)*).*?\bgecko[\/]\w+/,
-		R_BlackBerry = /\bblackberry\w*[\s\/]+(\d+(\.\w+)*)/,
-		R_desktop = /(\bwindows\b|\bmacintosh\b|\blinux\b|\bunix\b)/,
-		R_mobile = /(\bandroid\b|\bipad\b|\bipod\b|\bblackberry|\brim tablet os\b|\bwebos\b|\bwindows ce\b|\bwindows phone os\b|\bwindows ce\b|\bpalm|\bsymbian|\bj2me\b|\bdocomo\b|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|\w*?mobile\w*?|\w*?phone\w*?)/,
-		R_game = /(\bxbox\b|\bplaystation\b|\bnintendo\s+\w+)/;
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_Platform = /\s*([\-\w ]+)[\s\/]([\d_]+\b([\-\._\/]\w+)*)/;
 
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_Version = /([\w\-\.]+[\s\/][v]?[\d_]+\b([\-\._\/]\w+)*)/g;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_Gecko = /rv[:](\d+(\.\w+)*).*?\bgecko[\/]\w+/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_BlackBerry = /\bblackberry\w*[\s\/]+(\d+(\.\w+)*)/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_Silk = /\bsilk-accelerated=true\b/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_FluidApp = /\bfluidapp\b/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_desktop = /(\bwindows\b|\bmacintosh\b|\blinux\b|\bunix\b)/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_mobile = /(\bandroid\b|\bipad\b|\bipod\b|\bblackberry|\brim tablet os\b|\bwebos\b|\bwindows ce\b|\bwindows phone os\b|\bwindows ce\b|\bpalm|\bsymbian|\bj2me\b|\bdocomo\b|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|\w*?mobile\w*?|\w*?phone\w*?)/;
+
+	/**
+	 * @const
+	 * @type {RegExp}
+	 */
+	var R_game = /(\bxbox\b|\bplaystation\b|\bnintendo\s+\w+)/;
+
+	/**
+	 * The root CssUserAgent
+	 * @type {Object}
+	 */
 	var cssua = {
 
-		/*Map<string,string>*/ parse : function(/*string*/ uaStr) {
-			/*Map<string,string>*/ var ua = {};
+		parse:
+			/**
+			 * @param uaStr {string}
+			 * @return {Object}
+			 */
+			function(uaStr) {
 
-			uaStr = (''+uaStr).toLowerCase();
-			if (!uaStr) {
-				return ua;
-			}
+				/**
+				 * @type {Object}
+				 */
+				var ua = {};
 
-			var i, count, raw = uaStr.split(/[()]/);
-			for (var j=0, rawCount=raw.length; j<rawCount; j++) {
-				if (j%2) {
-					// inside parens covers platform identifiers
-					var platforms = raw[j].split(';');
-					for (i=0, count=platforms.length; i<count; i++) {
-						if (R_Platform.exec(platforms[i])) {
-							var key = RegExp.$1.split(' ').join('_'),
-								val = RegExp.$2;
+				uaStr = (''+uaStr).toLowerCase();
+				if (!uaStr) {
+					return ua;
+				}
 
-							// if duplicate entries favor highest version
-							if ((!ua[key] || parseFloat(ua[key]) < parseFloat(val))) {
-								ua[key] = val;
+				var i, count, raw = uaStr.split(/[()]/);
+				for (var j=0, rawCount=raw.length; j<rawCount; j++) {
+					if (j%2) {
+						// inside parens covers platform identifiers
+						var platforms = raw[j].split(';');
+						for (i=0, count=platforms.length; i<count; i++) {
+							if (R_Platform.exec(platforms[i])) {
+								var key = RegExp.$1.split(' ').join('_'),
+									val = RegExp.$2;
+
+								// if duplicate entries favor highest version
+								if ((!ua[key] || parseFloat(ua[key]) < parseFloat(val))) {
+									ua[key] = val;
+								}
 							}
 						}
-					}
 
-				} else {
-					// outside parens covers most version identifiers
-					var uas = raw[j].match(R_Version);
-					if (uas) {
-						for (i=0, count=uas.length; i<count; i++) {
-							var parts = uas[i].split(/[\/\s]+/);
-							if (parts.length && parts[0] !== 'mozilla') {
-								ua[parts[0].split(' ').join('_')] = parts.slice(1).join('-');
+					} else {
+						// outside parens covers most version identifiers
+						var uas = raw[j].match(R_Version);
+						if (uas) {
+							for (i=0, count=uas.length; i<count; i++) {
+								var parts = uas[i].split(/[\/\s]+/);
+								if (parts.length && parts[0] !== 'mozilla') {
+									ua[parts[0].split(' ').join('_')] = parts.slice(1).join('-');
+								}
 							}
 						}
 					}
 				}
-			}
 
-			if (R_mobile.exec(uaStr)) {
-				// mobile device indicators
-				ua.mobile = RegExp.$1;
-				if (R_BlackBerry.exec(uaStr)) {
-					ua.blackberry = RegExp.$1;
-				}
+				if (R_mobile.exec(uaStr)) {
+					// mobile device indicators
+					ua.mobile = RegExp.$1;
+					if (R_BlackBerry.exec(uaStr)) {
+						ua.blackberry = RegExp.$1;
+					}
 
-			} else if (R_desktop.exec(uaStr)) {
-				// desktop OS indicators
-				ua.desktop = RegExp.$1;
+				} else if (R_desktop.exec(uaStr)) {
+					// desktop OS indicators
+					ua.desktop = RegExp.$1;
 
-			} else if (R_game.exec(uaStr)) {
-				// game console indicators
-				ua.game = RegExp.$1;
-				var game = ua.game.split(' ').join('_');
+				} else if (R_game.exec(uaStr)) {
+					// game console indicators
+					ua.game = RegExp.$1;
+					var game = ua.game.split(' ').join('_');
 
-				if (ua.version && !ua[game]) {
-					ua[game] = ua.version;
-				}
-			}
-
-			// platform naming standardizations
-			if (ua.intel_mac_os_x) {
-				ua.mac_os_x = ua.intel_mac_os_x.split('_').join('.');
-				delete ua.intel_mac_os_x;
-
-			} else if (ua.cpu_iphone_os) {
-				ua.ios = ua.cpu_iphone_os.split('_').join('.');
-				delete ua.cpu_iphone_os;
-
-			} else if (ua.cpu_os) {
-				ua.ios = ua.cpu_os.split('_').join('.');
-				delete ua.cpu_os;
-
-			} else if (ua.mobile === 'iphone' && !ua.ios) {
-				ua.ios = '1';
-			}
-
-			// UA naming standardizations
-			if (ua.opera && ua.version) {
-				ua.opera = ua.version;
-
-			} else if (R_FluidApp.exec(uaStr)) {
-				ua.fluidapp = ua.version;
-			}
-
-			if (ua.applewebkit) {
-				ua.webkit = ua.applewebkit;
-				delete ua.applewebkit;
-
-				if (ua.safari) {
-					if (ua.chrome || ua.crios || ua.fluidapp || ua.phantomjs || (ua.mobile && !ua.ios)) {
-						delete ua.safari;
-
-					} else if (ua.version && !ua.rim_tablet_os) {
-						ua.safari = ua.version;
-	
-					} else {
-						ua.safari = ({
-							'419': '2.0.4',
-							'417': '2.0.3',
-							'416': '2.0.2',
-							'412': '2.0',
-							'312': '1.3',
-							'125': '1.2',
-							'85': '1.0'
-						})[parseInt(ua.safari, 10)] || ua.safari;
+					if (ua.version && !ua[game]) {
+						ua[game] = ua.version;
 					}
 				}
 
-			} else if (ua.msie) {
-				if (!ua.opera) {
-					ua.ie = ua.msie;
+				// platform naming standardizations
+				if (ua.intel_mac_os_x) {
+					ua.mac_os_x = ua.intel_mac_os_x.split('_').join('.');
+					delete ua.intel_mac_os_x;
+
+				} else if (ua.cpu_iphone_os) {
+					ua.ios = ua.cpu_iphone_os.split('_').join('.');
+					delete ua.cpu_iphone_os;
+
+				} else if (ua.cpu_os) {
+					ua.ios = ua.cpu_os.split('_').join('.');
+					delete ua.cpu_os;
+
+				} else if (ua.mobile === 'iphone' && !ua.ios) {
+					ua.ios = '1';
 				}
-				delete ua.msie;
 
-			} else if (R_Gecko.exec(uaStr)) {
-				ua.gecko = RegExp.$1;
+				// UA naming standardizations
+				if (ua.opera && ua.version) {
+					ua.opera = ua.version;
+
+				} else if (R_Silk.exec(uaStr)) {
+					ua.silk_accelerated = true;
+
+				} else if (R_FluidApp.exec(uaStr)) {
+					ua.fluidapp = ua.version;
+				}
+
+				if (ua.applewebkit) {
+					ua.webkit = ua.applewebkit;
+					delete ua.applewebkit;
+
+					if (ua.safari) {
+						if (ua.chrome || ua.crios || ua.silk || ua.fluidapp || ua.phantomjs || (ua.mobile && !ua.ios)) {
+							delete ua.safari;
+
+						} else if (ua.version && !ua.rim_tablet_os) {
+							ua.safari = ua.version;
+
+						} else {
+							ua.safari = ({
+								'419': '2.0.4',
+								'417': '2.0.3',
+								'416': '2.0.2',
+								'412': '2.0',
+								'312': '1.3',
+								'125': '1.2',
+								'85': '1.0'
+							})[parseInt(ua.safari, 10)] || ua.safari;
+						}
+					}
+
+				} else if (ua.msie) {
+					if (!ua.opera) {
+						ua.ie = ua.msie;
+					}
+					delete ua.msie;
+
+				} else if (R_Gecko.exec(uaStr)) {
+					ua.gecko = RegExp.$1;
+				}
+
+				if (ua.version) {
+					delete ua.version;
+				}
+
+				return ua;
+			},
+
+		format:
+			/**
+			 * @param ua {Object}
+			 * @return {string}
+			 */
+			function (ua) {
+				/**
+				 * @param b {string} browser key
+				 * @param v {string} browser value
+				 * @return {string} formatted CSS classes
+				 */
+				function format(b, v) {
+					b = b.split('.').join('-');
+
+					/**
+					 * @type {string}
+					 */
+					var css = PREFIX+b;
+					if (typeof v === 'string') {
+						v = v.split(' ').join('_').split('.').join('-');
+						var i = v.indexOf('-');
+						while (i > 0) {
+							// loop through chopping last '-' to end off
+							// concat result onto return string
+							css += PREFIX+b+'-'+v.substring(0, i);
+							i = v.indexOf('-', i+1);
+						}
+						css += PREFIX+b+'-'+v;
+					}
+					return css;
+				}
+	
+				/**
+				 * @type {string}
+				 */
+				var	uaCss = '';
+				for (var b in ua) {
+					if (b && ua.hasOwnProperty(b)) {
+						uaCss += format(b, ua[b]);
+					}
+				}
+	
+				// user-agent classNames
+				return uaCss;
+			},
+
+		encode:
+			/**
+			 * Encodes parsed userAgent object as a compact URI-Encoded key-value collection
+			 * @param ua {Object}
+			 * @return {string}
+			 */
+			function(ua) {
+				var query = '';
+				for (var b in ua) {
+					if (b && ua.hasOwnProperty(b)) {
+						if (query) {
+							query += '&';
+						}
+						query += encodeURIComponent(b)+'='+encodeURIComponent(ua[b]);
+					}
+				}
+				return query;
 			}
-
-			if (ua.version) {
-				delete ua.version;
-			}
-
-			return ua;
-		},
-
-		/*string*/ format : function (/*Map<string,string>*/ ua) {
-			/*string*/ function format(/*string*/ b, /*string*/ v) {
-				b = b.split('.').join('-');
-				/*string*/ var css = PREFIX+b;
-				if (v) {
-					v = v.split(' ').join('_').split('.').join('-');
-					var i = v.indexOf('-');
-					while (i > 0) {
-						// loop through chopping last '-' to end off
-						// concat result onto return string
-						css += PREFIX+b+'-'+v.substring(0, i);
-						i = v.indexOf('-', i+1);
-					}
-					css += PREFIX+b+'-'+v;
-				}
-				return css;
-			}
-
-			var	uaCss = '';
-			for (var b in ua) {
-				if (b && ua.hasOwnProperty(b)) {
-					uaCss += format(b, ua[b]);
-				}
-			}
-
-			// user-agent classNames
-			return uaCss;
-		},
-
-		/* Encodes parsed userAgent object as a compact URI-Encoded key-value collection */
-		/*string*/ encode : function(/*Map<string,string>*/ ua) {
-			var query = '';
-			for (var b in ua) {
-				if (b && ua.hasOwnProperty(b)) {
-					if (query) {
-						query += '&';
-					}
-					query += encodeURIComponent(b)+'='+encodeURIComponent(ua[b]);
-				}
-			}
-			return query;
-		}
 	};
 
-	// calculate userAgent
+	/**
+	 * @const
+	 * @type {Object}
+	 */
 	cssua.userAgent = cssua.ua = cssua.parse(userAgent);
 
+	/**
+	 * @const
+	 * @type {string}
+	 */
+	var ua = cssua.format(cssua.ua)+' js';
+
 	// append CSS classes to HTML node
-	var ua = cssua.format(cssua.ua)+' js';
 	if (html.className) {
 		html.className = html.className.replace(/\bno-js\b/g, '') + ua;
 		
 	}
 
 	return cssua;
+
 })(document.documentElement, navigator.userAgent);
-var cssua=function(i,l){var m=/\s*([\-\w ]+)[\s\/]([\d_]+\b([\-\._\/]\w+)*)/,n=/([\w\-\.]+[\s\/][v]?[\d_]+\b([\-\._\/]\w+)*)/g,o=/\bfluidapp\b/,p=/rv[:](\d+(\.\w+)*).*?\bgecko[\/]\w+/,q=/\bblackberry\w*[\s\/]+(\d+(\.\w+)*)/,r=/(\bwindows\b|\bmacintosh\b|\blinux\b|\bunix\b)/,s=/(\bandroid\b|\bipad\b|\bipod\b|\bblackberry|\brim tablet os\b|\bwebos\b|\bwindows ce\b|\bwindows phone os\b|\bwindows ce\b|\bpalm|\bsymbian|\bj2me\b|\bdocomo\b|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|\w*?mobile\w*?|\w*?phone\w*?)/,
-t=/(\bxbox\b|\bplaystation\b|\bnintendo\s+\w+)/,d={parse:function(c){var a={},c=(""+c).toLowerCase();if(!c)return a;for(var b,g,e=c.split(/[()]/),f=0,d=e.length;f<d;f++)if(f%2){var j=e[f].split(";");for(b=0,g=j.length;b<g;b++)if(m.exec(j[b])){var h=RegExp.$1.split(" ").join("_"),i=RegExp.$2;if(!a[h]||parseFloat(a[h])<parseFloat(i))a[h]=i}}else if(j=e[f].match(n))for(b=0,g=j.length;b<g;b++)h=j[b].split(/[\/\s]+/),h.length&&"mozilla"!==h[0]&&(a[h[0].split(" ").join("_")]=h.slice(1).join("-"));if(s.exec(c)){if(a.mobile=
-RegExp.$1,q.exec(c))a.blackberry=RegExp.$1}else if(r.exec(c))a.desktop=RegExp.$1;else if(t.exec(c)&&(a.game=RegExp.$1,b=a.game.split(" ").join("_"),a.version&&!a[b]))a[b]=a.version;if(a.intel_mac_os_x)a.mac_os_x=a.intel_mac_os_x.split("_").join("."),delete a.intel_mac_os_x;else if(a.cpu_iphone_os)a.ios=a.cpu_iphone_os.split("_").join("."),delete a.cpu_iphone_os;else if(a.cpu_os)a.ios=a.cpu_os.split("_").join("."),delete a.cpu_os;else if("iphone"===a.mobile&&!a.ios)a.ios="1";if(a.opera&&a.version)a.opera=
-a.version;else if(o.exec(c))a.fluidapp=a.version;if(a.applewebkit){if(a.webkit=a.applewebkit,delete a.applewebkit,a.safari)a.chrome||a.crios||a.fluidapp||a.phantomjs||a.mobile&&!a.ios?delete a.safari:a.safari=a.version&&!a.rim_tablet_os?a.version:{419:"2.0.4",417:"2.0.3",416:"2.0.2",412:"2.0",312:"1.3",125:"1.2",85:"1.0"}[parseInt(a.safari,10)]||a.safari}else if(a.msie){if(!a.opera)a.ie=a.msie;delete a.msie}else if(p.exec(c))a.gecko=RegExp.$1;a.version&&delete a.version;return a},format:function(c){var a=
-"",b;for(b in c)if(b&&c.hasOwnProperty(b)){var g=b,e=c[b],g=g.split(".").join("-"),f=" ua-"+g;if(e){for(var e=e.split(" ").join("_").split(".").join("-"),d=e.indexOf("-");0<d;)f+=" ua-"+g+"-"+e.substring(0,d),d=e.indexOf("-",d+1);f+=" ua-"+g+"-"+e}a+=f}return a},encode:function(c){var a="",b;for(b in c)b&&c.hasOwnProperty(b)&&(a&&(a+="&"),a+=encodeURIComponent(b)+"="+encodeURIComponent(c[b]));return a}};d.userAgent=d.ua=d.parse(l);var k=d.format(d.ua)+" js";i.className=i.className?i.className.replace(/\bno-js\b/g,
-"")+k:k.substr(1);return d}(document.documentElement,navigator.userAgent);
+var cssua=function(i,l){var m=/\s*([\-\w ]+)[\s\/]([\d_]+\b([\-\._\/]\w+)*)/,n=/([\w\-\.]+[\s\/][v]?[\d_]+\b([\-\._\/]\w+)*)/g,o=/rv[:](\d+(\.\w+)*).*?\bgecko[\/]\w+/,p=/\bblackberry\w*[\s\/]+(\d+(\.\w+)*)/,q=/\bsilk-accelerated=true\b/,r=/\bfluidapp\b/,s=/(\bwindows\b|\bmacintosh\b|\blinux\b|\bunix\b)/,t=/(\bandroid\b|\bipad\b|\bipod\b|\bblackberry|\brim tablet os\b|\bwebos\b|\bwindows ce\b|\bwindows phone os\b|\bwindows ce\b|\bpalm|\bsymbian|\bj2me\b|\bdocomo\b|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|\w*?mobile\w*?|\w*?phone\w*?)/,
+u=/(\bxbox\b|\bplaystation\b|\bnintendo\s+\w+)/,d={parse:function(c){var a={},c=(""+c).toLowerCase();if(!c)return a;for(var b,g,e=c.split(/[()]/),f=0,d=e.length;f<d;f++)if(f%2){var j=e[f].split(";");for(b=0,g=j.length;b<g;b++)if(m.exec(j[b])){var h=RegExp.$1.split(" ").join("_"),i=RegExp.$2;if(!a[h]||parseFloat(a[h])<parseFloat(i))a[h]=i}}else if(j=e[f].match(n))for(b=0,g=j.length;b<g;b++)h=j[b].split(/[\/\s]+/),h.length&&"mozilla"!==h[0]&&(a[h[0].split(" ").join("_")]=h.slice(1).join("-"));if(t.exec(c)){if(a.mobile=
+RegExp.$1,p.exec(c))a.blackberry=RegExp.$1}else if(s.exec(c))a.desktop=RegExp.$1;else if(u.exec(c)&&(a.game=RegExp.$1,b=a.game.split(" ").join("_"),a.version&&!a[b]))a[b]=a.version;if(a.intel_mac_os_x)a.mac_os_x=a.intel_mac_os_x.split("_").join("."),delete a.intel_mac_os_x;else if(a.cpu_iphone_os)a.ios=a.cpu_iphone_os.split("_").join("."),delete a.cpu_iphone_os;else if(a.cpu_os)a.ios=a.cpu_os.split("_").join("."),delete a.cpu_os;else if("iphone"===a.mobile&&!a.ios)a.ios="1";if(a.opera&&a.version)a.opera=
+a.version;else if(q.exec(c))a.silk_accelerated=!0;else if(r.exec(c))a.fluidapp=a.version;if(a.applewebkit){if(a.webkit=a.applewebkit,delete a.applewebkit,a.safari)a.chrome||a.crios||a.silk||a.fluidapp||a.phantomjs||a.mobile&&!a.ios?delete a.safari:a.safari=a.version&&!a.rim_tablet_os?a.version:{419:"2.0.4",417:"2.0.3",416:"2.0.2",412:"2.0",312:"1.3",125:"1.2",85:"1.0"}[parseInt(a.safari,10)]||a.safari}else if(a.msie){if(!a.opera)a.ie=a.msie;delete a.msie}else if(o.exec(c))a.gecko=RegExp.$1;a.version&&
+delete a.version;return a},format:function(c){var a="",b;for(b in c)if(b&&c.hasOwnProperty(b)){var g=b,e=c[b],g=g.split(".").join("-"),f=" ua-"+g;if("string"===typeof e){for(var e=e.split(" ").join("_").split(".").join("-"),d=e.indexOf("-");0<d;)f+=" ua-"+g+"-"+e.substring(0,d),d=e.indexOf("-",d+1);f+=" ua-"+g+"-"+e}a+=f}return a},encode:function(c){var a="",b;for(b in c)b&&c.hasOwnProperty(b)&&(a&&(a+="&"),a+=encodeURIComponent(b)+"="+encodeURIComponent(c[b]));return a}};d.userAgent=d.ua=d.parse(l);
+var k=d.format(d.ua)+" js";i.className=i.className?i.className.replace(/\bno-js\b/g,"")+k:k.substr(1);return d}(document.documentElement,navigator.userAgent);
 	<meta charset="UTF-8">
 	<title>CssUserAgent (cssua.js) Demo</title>
 
+	<meta name="viewport" content="user-scalable=yes" />
 	<meta name="apple-mobile-web-app-capable" content="yes" />
+
 	<link href="styles/main.css" rel="stylesheet" type="text/css" />
 	<link href="styles/zebra.css" rel="stylesheet" type="text/css" />
 	<link href="styles/syntax.css" rel="stylesheet" type="text/css" />

test/parseTests.js

 	same(actual, expected, input);
 });
 
+test('Silk 1.1.0, Kindle Fire 1 (desktop, accelerated)', function() {
+
+	var input = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true';
+
+	var expected =
+		{
+			silk: '1.1.0-80',
+			desktop: 'macintosh',
+			mac_os_x: '10.6.3',
+			silk_accelerated: true,
+			webkit: '533.16'
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, input);
+});
+
+test('Silk 1.1.0, Kindle Fire 1 (mobile, not accelerated)', function() {
+
+	var input = 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.1.0-80) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=false';
+
+	var expected =
+		{
+			android: '2.3.4',
+			silk: '1.1.0-80',
+			mobile: 'android',
+			webkit: '533.1'
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, input);
+});
+
+test('Silk 2.1, Kindle Fire 2 (mobile, accelerated)', function() {
+
+	var input = 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFOT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.1 Mobile Safari/535.19 Silk-Accelerated=true';
+
+	var expected =
+		{
+			android: '4.0.3',
+			silk: '2.1',
+			mobile: 'android',
+			silk_accelerated: true,
+			webkit: '535.19'
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, input);
+});
+
+test('Silk 2.1, Kindle Fire 2 (desktop, not accelerated)', function() {
+
+	var input = 'Mozilla/5.0 (Linux; U; en-us; KFOT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.1 Safari/535.19 Silk-Accelerated=false';
+
+	var expected =
+		{
+			silk: '2.1',
+			desktop: 'linux',
+			webkit: '535.19'
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, input);
+});
+
 test('FluidApp 1.4, Mac OS X', function() {
 
 	var input = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.56.5 (KHTML, like Gecko) FluidApp Version/1.4 Safari/534.56.5';

test/styles/browsers.css

 {
 	background-image: url(browsers/Chrome_128.png);
 }
+.ua-silk .browser-info
+{
+	border-color: #0176E0;
+	border-top-color: #F78013;
+	border-left-color: #F78013;
+	background-image: url(browsers/Silk_128.png);
+}
 .ua-fluidapp .browser-info
 {
 	border-color: #0E4EB7;
Add a comment to this file

test/styles/browsers/Silk_128.png

Added
New image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.