platform.js
function cleanupOS(os, pattern, label) {
    // Platform tokens are defined at:
    // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
    // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
    var data = {
      '10.0': '10',
      '6.4':  '10 Technical Preview',
      '6.3':  '8.1',
      '6.2':  '8',
      '6.1':  'Server 2008 R2 / 7',
      '6.0':  'Server 2008 / Vista',
      '5.2':  'Server 2003 / XP 64-bit',
      '5.1':  'XP',
      '5.01': '2000 SP1',
      '5.0':  '2000',
      '4.0':  'NT',
      '4.90': 'ME'
    };
    // Detect Windows version from platform tokens.
    if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
        (data = data[/[\d.]+$/.exec(os)])) {
      os = 'Windows ' + data;
    }
    // Correct character case and cleanup string.
    os = String(os);

    if (pattern && label) {
      os = os.replace(RegExp(pattern, 'i'), label);
    }

    os = format(
      os.replace(/ ce$/i, ' CE')
        .replace(/\bhpw/i, 'web')
        .replace(/\bMacintosh\b/, 'Mac OS')
        .replace(/_PowerPC\b/i, ' OS')
        .replace(/\b(OS X) [^ \d]+/i, '$1')
        .replace(/\bMac (OS X)\b/, '$1')
        .replace(/\/(\d)/, ' $1')
        .replace(/_/g, '.')
        .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
        .replace(/\bx86\.64\b/gi, 'x86_64')
        .replace(/\b(Windows Phone) OS\b/, '$1')
        .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
        .split(' on ')[0]
    );

    return os;
  }
function cleanupOS(os, pattern, label) {
    // Platform tokens are defined at:
    // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
    // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
    var data = {
      '10.0': '10',
      '6.4':  '10 Technical Preview',
      '6.3':  '8.1',
      '6.2':  '8',
      '6.1':  'Server 2008 R2 / 7',
      '6.0':  'Server 2008 / Vista',
      '5.2':  'Server 2003 / XP 64-bit',
      '5.1':  'XP',
      '5.01': '2000 SP1',
      '5.0':  '2000',
      '4.0':  'NT',
      '4.90': 'ME'
    };
    // Detect Windows version from platform tokens.
    if (pattern && label && /^Win/i.test(os) && !/^Windows Phone /i.test(os) &&
        (data = data[/[\d.]+$/.exec(os)])) {
      os = 'Windows ' + data;
    }
    // Correct character case and cleanup string.
    os = String(os);

    if (pattern && label) {
      os = os.replace(RegExp(pattern, 'i'), label);
    }

    os = format(
      os.replace(/ ce$/i, ' CE')
        .replace(/\bhpw/i, 'web')
        .replace(/\bMacintosh\b/, 'Mac OS')
        .replace(/_PowerPC\b/i, ' OS')
        .replace(/\b(OS X) [^ \d]+/i, '$1')
        .replace(/\bMac (OS X)\b/, '$1')
        .replace(/\/(\d)/, ' $1')
        .replace(/_/g, '.')
        .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '')
        .replace(/\bx86\.64\b/gi, 'x86_64')
        .replace(/\b(Windows Phone) OS\b/, '$1')
        .replace(/\b(Chrome OS \w+) [\d.]+\b/, '$1')
        .split(' on ')[0]
    );

    return os;
  }
function cleanupOS ( os , pattern , label ) { // Platform tokens are defined at: // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx var data = { '10.0' : '10' , '6.4' : '10 Technical Preview' , '6.3' : '8.1' , '6.2' : '8' , '6.1' : 'Server 2008 R2 / 7' , '6.0' : 'Server 2008 / Vista' , '5.2' : 'Server 2003 / XP 64-bit' , '5.1' : 'XP' , '5.01' : '2000 SP1' , '5.0' : '2000' , '4.0' : 'NT' , '4.90' : 'ME' } ; // Detect Windows version from platform tokens. if ( pattern && label && / ^Win / i . test ( os ) && ! / ^Windows Phone  / i . test ( os ) && ( data = data [ / [\d.]+$ / . exec ( os ) ] ) ) { os = 'Windows ' + data ; } // Correct character case and cleanup string. os = String ( os ) ; if ( pattern && label ) { os = os . replace ( RegExp ( pattern , 'i' ) , label ) ; } os = format ( os . replace ( /  ce$ / i , ' CE' ) . replace ( / \bhpw / i , 'web' ) . replace ( / \bMacintosh\b / , 'Mac OS' ) . replace ( / _PowerPC\b / i , ' OS' ) . replace ( / \b(OS X) [^ \d]+ / i , '$1' ) . replace ( / \bMac (OS X)\b / , '$1' ) . replace ( / \/(\d) / , ' $1' ) . replace ( / _ / g , '.' ) . replace ( / (?: BePC|[ .]*fc[ \d.]+)$ / i , '' ) . replace ( / \bx86\.64\b / gi , 'x86_64' ) . replace ( / \b(Windows Phone) OS\b / , '$1' ) . replace ( / \b(Chrome OS \w+) [\d.]+\b / , '$1' ) . split ( ' on ' ) [ 0 ] ) ; return os ; }
A utility function to clean up the OS name.

@private
@param {string} os The OS name to clean up.
@param {string} [pattern] A `RegExp` pattern matching the OS name.
@param {string} [label] A label for the OS.
A utility function to clean up the OS name .