Changeset 3948 in subversion


Ignore:
Timestamp:
Sep 8, 2010 1:57:35 PM (3 years ago)
Author:
alec
Message:
  • Small improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/js/common.js

    r3942 r3948  
    2626function roundcube_browser() 
    2727{ 
    28   this.ver = parseFloat(navigator.appVersion); 
    29   this.appver = navigator.appVersion; 
    30   this.agent = navigator.userAgent; 
    31   this.agent_lc = navigator.userAgent.toLowerCase(); 
    32   this.name = navigator.appName; 
    33   this.vendor = navigator.vendor ? navigator.vendor : ''; 
    34   this.vendver = navigator.vendorSub ? parseFloat(navigator.vendorSub) : 0; 
    35   this.product = navigator.product ? navigator.product : ''; 
    36   this.platform = String(navigator.platform).toLowerCase(); 
    37   this.lang = (navigator.language) ? navigator.language.substring(0,2) : 
    38               (navigator.browserLanguage) ? navigator.browserLanguage.substring(0,2) : 
    39               (navigator.systemLanguage) ? navigator.systemLanguage.substring(0,2) : 'en'; 
     28  var n = navigator; 
     29 
     30  this.ver = parseFloat(n.appVersion); 
     31  this.appver = n.appVersion; 
     32  this.agent = n.userAgent; 
     33  this.agent_lc = n.userAgent.toLowerCase(); 
     34  this.name = n.appName; 
     35  this.vendor = n.vendor ? n.vendor : ''; 
     36  this.vendver = n.vendorSub ? parseFloat(n.vendorSub) : 0; 
     37  this.product = n.product ? n.product : ''; 
     38  this.platform = String(n.platform).toLowerCase(); 
     39  this.lang = (n.language) ? n.language.substring(0,2) : 
     40              (n.browserLanguage) ? n.browserLanguage.substring(0,2) : 
     41              (n.systemLanguage) ? n.systemLanguage.substring(0,2) : 'en'; 
    4042 
    4143  this.win = (this.platform.indexOf('win') >= 0); 
     
    5961  this.ns7 = (this.ns && parseInt(this.vendver) == 7);  // this.agent.indexOf('Netscape/7')>0); 
    6062  this.chrome = (this.agent_lc.indexOf('chrome') > 0); 
    61   this.safari = (!this.chrome && (this.agent_lc.indexOf('safari') > 0 || this.agent.toLowerCase().indexOf('applewebkit') > 0)); 
     63  this.safari = (!this.chrome && (this.agent_lc.indexOf('safari') > 0 || this.agent_lc.indexOf('applewebkit') > 0)); 
    6264  this.konq   = (this.agent_lc.indexOf('konqueror') > 0); 
    6365  this.iphone = (this.safari && this.agent_lc.indexOf('iphone') > 0); 
     
    6769 
    6870  if (this.opera && window.RegExp) 
    69     this.vendver = (/opera(\s|\/)([0-9\.]+)/i.test(navigator.userAgent)) ? parseFloat(RegExp.$2) : -1; 
     71    this.vendver = (/opera(\s|\/)([0-9\.]+)/.test(this.agent_lc)) ? parseFloat(RegExp.$2) : -1; 
    7072  else if (this.chrome && window.RegExp) 
    71     this.vendver = (/chrome\/([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0; 
     73    this.vendver = (/chrome\/([0-9\.]+)/.test(this.agent_lc)) ? parseFloat(RegExp.$1) : 0; 
    7274  else if (!this.vendver && this.safari) 
    73     this.vendver = (/(safari|applewebkit)\/([0-9]+)/i.test(this.agent)) ? parseInt(RegExp.$2) : 0; 
     75    this.vendver = (/(safari|applewebkit)\/([0-9]+)/.test(this.agent_lc)) ? parseInt(RegExp.$2) : 0; 
    7476  else if ((!this.vendver && this.mz) || this.agent.indexOf('Camino')>0) 
    7577    this.vendver = (/rv:([0-9\.]+)/.test(this.agent)) ? parseFloat(RegExp.$1) : 0; 
    7678  else if (this.ie && window.RegExp) 
    77     this.vendver = (/msie\s+([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0; 
     79    this.vendver = (/msie\s+([0-9\.]+)/.test(this.agent_lc)) ? parseFloat(RegExp.$1) : 0; 
    7880  else if (this.konq && window.RegExp) 
    79     this.vendver = (/khtml\/([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0; 
     81    this.vendver = (/khtml\/([0-9\.]+)/.test(this.agent_lc)) ? parseFloat(RegExp.$1) : 0; 
    8082 
    8183  // get real language out of safari's user agent 
    82   if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/i.test(this.agent))) 
     84  if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/.test(this.agent_lc))) 
    8385    this.lang = RegExp.$1; 
    8486 
     
    8890                   (this.ie && this.win && this.vendver >= 5.5) || this.safari); 
    8991  this.opacity = (this.mz || (this.ie && this.vendver >= 5.5 && !this.opera) || (this.safari && this.vendver >= 100)); 
    90   this.cookies = navigator.cookieEnabled; 
     92  this.cookies = n.cookieEnabled; 
    9193 
    9294  // test for XMLHTTP support 
Note: See TracChangeset for help on using the changeset viewer.