UI: Implement JavaScript getOS function Windows platform architecture detection #104136

Merged
Márton Lente merged 15 commits from get-os-win-arm into main 2024-11-08 12:03:41 +01:00
Showing only changes of commit 14110f48a6 - Show all commits

View File

@ -2,8 +2,10 @@
* https://code.videolan.org/VideoLAN.org/websites/-/blob/master/www.videolan.org/include/os-specific.php * https://code.videolan.org/VideoLAN.org/websites/-/blob/master/www.videolan.org/include/os-specific.php
*/ */
function getOS() { function getOS() {
var OS = "windows"; //Default // Init variable OS default
var OS = "windows";
function getOSWinVersion() {
if (navigator.appVersion.indexOf("Win") != -1) { if (navigator.appVersion.indexOf("Win") != -1) {
if (navigator.userAgent.indexOf('Windows NT 5.0') == -1 && if (navigator.userAgent.indexOf('Windows NT 5.0') == -1 &&
navigator.userAgent.indexOf('Windows NT 5.1') == -1 && navigator.userAgent.indexOf('Windows NT 5.1') == -1 &&
@ -32,7 +34,9 @@ function getOS() {
} }
} }
} }
}
function getOSMacVersion() {
//MacOS, MacOS X, macOS //MacOS, MacOS X, macOS
if (navigator.appVersion.indexOf("Mac") != -1) { if (navigator.appVersion.indexOf("Mac") != -1) {
if (navigator.platform.indexOf("MacPPC") != -1 || navigator.platform.indexOf("PowerPC") != -1) { if (navigator.platform.indexOf("MacPPC") != -1 || navigator.platform.indexOf("PowerPC") != -1) {
@ -52,6 +56,9 @@ function getOS() {
} catch (e) {} } catch (e) {}
} }
} }
}
function getOSLinuxVersion() {
if (navigator.platform.indexOf("Linux") != -1) { if (navigator.platform.indexOf("Linux") != -1) {
if ((navigator.userAgent.indexOf("Ubuntu") != -1) || if ((navigator.userAgent.indexOf("Ubuntu") != -1) ||
(navigator.userAgent.indexOf("ubuntu") != -1)) OS = "linux-ubuntu"; (navigator.userAgent.indexOf("ubuntu") != -1)) OS = "linux-ubuntu";
@ -64,12 +71,28 @@ function getOS() {
else if (navigator.userAgent.indexOf("Gentoo") != -1) OS = "linux-gentoo"; else if (navigator.userAgent.indexOf("Gentoo") != -1) OS = "linux-gentoo";
else OS = "linux"; else OS = "linux";
} }
}
function getOSiPadVersion() {
if (navigator.userAgent.indexOf("iPad") != -1 || navigator.userAgent.indexOf("iPhone") != -1 || navigator.userAgent.indexOf("iPod") != -1) { if (navigator.userAgent.indexOf("iPad") != -1 || navigator.userAgent.indexOf("iPhone") != -1 || navigator.userAgent.indexOf("iPod") != -1) {
OS = "ios"; OS = "ios";
} }
}
function getOSFreeBSDVersion() {
if (navigator.platform.indexOf("freebsd") != -1) OS = "freebsd"; if (navigator.platform.indexOf("freebsd") != -1) OS = "freebsd";
if (navigator.platform.indexOf("FreeBSD") != -1) OS = "freebsd"; if (navigator.platform.indexOf("FreeBSD") != -1) OS = "freebsd";
}
function init() {
getOSWinVersion();
getOSMacVersion();
getOSLinuxVersion();
getOSiPadVersion();
getOSFreeBSDVersion();
}
init();
return OS; return OS;
} }