1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

adds windows version detection

This commit is contained in:
rkurbatov
2017-05-18 00:28:51 +03:00
parent 9b87b2f3af
commit 98538362b3
2 changed files with 58 additions and 2 deletions

View File

@@ -336,9 +336,27 @@
result.linux = t
}
function getWindowsVersion (s) {
switch (s) {
case 'NT': return 'NT'
case 'XP': return 'XP'
case 'NT 5.0': return '2000'
case 'NT 5.1': return 'XP'
case 'NT 5.2': return '2003'
case 'NT 6.0': return 'Vista'
case 'NT 6.1': return '7'
case 'NT 6.2': return '8'
case 'NT 6.3': return '8.1'
case 'NT 10.0': return '10'
default: return undefined
}
}
// OS version extraction
var osVersion = '';
if (result.windowsphone) {
if (result.windows) {
osVersion = getWindowsVersion(getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i))
} else if (result.windowsphone) {
osVersion = getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i);
} else if (iosdevice) {
osVersion = getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i);
@@ -359,7 +377,7 @@
}
// device type extraction
var osMajorVersion = osVersion.split('.')[0];
var osMajorVersion = !result.windows && osVersion.split('.')[0];
if (
tablet
|| nexusTablet