1 /** 2 * @fileOverview ua-extra 3 * @author gonghao@ghsky.com 4 */ 5 KISSY.add('ua/extra', function (S, UA) { 6 var win = S.Env.host, 7 navigator = win.navigator, 8 ua = navigator.userAgent, 9 m, external, shell, 10 o = { }, 11 numberify = UA._numberify; 12 13 /** 14 * 说明: 15 * @子涯总结的各国产浏览器的判断依据: http://spreadsheets0.google.com/ccc?key=tluod2VGe60_ceDrAaMrfMw&hl=zh_CN#gid=0 16 * 根据 CNZZ 2009 年度浏览器占用率报告,优化了判断顺序:http://www.tanmi360.com/post/230.htm 17 * 如果检测出浏览器,但是具体版本号未知用 0.1 作为标识 18 * 世界之窗 & 360 浏览器,在 3.x 以下的版本都无法通过 UA 或者特性检测进行判断,所以目前只要检测到 UA 关键字就认为起版本号为 3 19 */ 20 21 // 360Browser 22 if (m = ua.match(/360SE/)) { 23 o[shell = 'se360'] = 3; // issue: 360Browser 2.x cannot be recognised, so if recognised default set verstion number to 3 24 } 25 // Maxthon 26 else if ((m = ua.match(/Maxthon/)) && (external = win.external)) { 27 // issue: Maxthon 3.x in IE-Core cannot be recognised and it doesn't have exact version number 28 // but other maxthon versions all have exact version number 29 shell = 'maxthon'; 30 try { 31 o[shell] = numberify(external['max_version']); 32 } catch (ex) { 33 o[shell] = 0.1; 34 } 35 } 36 // TT 37 else if (m = ua.match(/TencentTraveler\s([\d.]*)/)) { 38 o[shell = 'tt'] = m[1] ? numberify(m[1]) : 0.1; 39 } 40 // TheWorld 41 else if (m = ua.match(/TheWorld/)) { 42 o[shell = 'theworld'] = 3; // issue: TheWorld 2.x cannot be recognised, so if recognised default set verstion number to 3 43 } 44 // Sougou 45 else if (m = ua.match(/SE\s([\d.]*)/)) { 46 o[shell = 'sougou'] = m[1] ? numberify(m[1]) : 0.1; 47 } 48 49 // If the browser has shell(no matter IE-core or Webkit-core or others), set the shell key 50 shell && (o.shell = shell); 51 52 S.mix(UA, o); 53 return UA; 54 }, { 55 requires:["ua/base"] 56 }); 57