86 lines
2.6 KiB
JavaScript
86 lines
2.6 KiB
JavaScript
function selectOs( osDiv ) {
|
|
osString = navigator.oscpu + navigator.userAgent;
|
|
osString = osString.toLowerCase();
|
|
|
|
var detectedOs = 'other';
|
|
|
|
if (matches(osString, ['Windows NT 5.1', 'Windows XP'])) {
|
|
detectedOs = 'xp';
|
|
} else if (matches(osString, ['Windows NT 6.0', 'Windows Vista'])) {
|
|
detectedOs = 'vista'
|
|
} else if(matches(osString, ['Windows 7', 'Windows NT 6.1'])) {
|
|
detectedOs = 'win7';
|
|
} else if (matches(osString, ['Windows NT 6.2', 'Windows NT 6.3'])) {
|
|
detectedOs = 'win8';
|
|
} else if (matches(osString, ['Windows NT 6.4', 'Windows NT 10'])) {
|
|
detectedOs = 'win10';
|
|
} else if (matches(osString, ['android'])) {
|
|
detectedOs = 'android';
|
|
} else if (matches(osString, ['linux'])) {
|
|
detectedOs = 'linux';
|
|
} else if (matches(osString, ['mac os x', 'macintosh', 'mac_powerpc'])) {
|
|
detectedOs = 'mac';
|
|
} else {
|
|
detectedOs = 'other';
|
|
}
|
|
|
|
var osSelect = checkOsString(detectedOs);
|
|
|
|
$('#' + detectedOs).addClass('detectedOs');
|
|
$('' + osDiv).load('os/' + detectedOs + '/howto.html');
|
|
$('#osSelector').val(osSelect);
|
|
$('#osSelector').change(function () {
|
|
$('' + osDiv).load('os/' + $(this).val() + '/howto.html');
|
|
})
|
|
}
|
|
|
|
function matches(osString, strings) {
|
|
for (var i=0; i<strings.length; i = i+1) {
|
|
if (osString.indexOf(strings[i].toLowerCase()) > -1)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function checkOsString(osString) {
|
|
var osSelect = osString;
|
|
switch(osString) {
|
|
case 'vista':
|
|
osSelect = 'win7';
|
|
break;
|
|
case 'win8':
|
|
osSelect = 'win10';
|
|
break;
|
|
case 'xp':
|
|
osSelect = 'other';
|
|
break;
|
|
default:
|
|
osSelect = osString;
|
|
}
|
|
return osSelect;
|
|
}
|
|
|
|
/*
|
|
'Windows 3.11' => 'Win16',
|
|
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
|
|
'Windows 98' => '(Windows 98)|(Win98)',
|
|
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
|
|
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
|
|
'Windows Server 2003' => '(Windows NT 5.2)',
|
|
'Windows Vista' => '(Windows NT 6.0)',
|
|
'Windows 7' => '(Windows NT 6.1)',
|
|
'Windows 8' => '(Windows NT 6.2)|(WOW64)|(Windows NT 6.3)',
|
|
'Windows 10' => '(Windows NT 6.4)|(Windows NT 10)'
|
|
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
|
|
'Windows ME' => 'Windows ME',
|
|
'Open BSD' => 'OpenBSD',
|
|
'Sun OS' => 'SunOS',
|
|
'Linux' => '(Linux)|(X11)',
|
|
'Mac OS' => '(Mac_PowerPC)|(Macintosh)|(Mac)',
|
|
'QNX' => 'QNX',
|
|
'BeOS' => 'BeOS',
|
|
'OS/2' => 'OS/2',
|
|
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)'
|
|
*/
|
|
|