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 0c97fd86c7 - Show all commits

View File

@ -2,9 +2,6 @@
* 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() {
// Init variable OS default
var OS = "windows";
function getOSWinVersionSync() { function getOSWinVersionSync() {
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 &&
@ -101,6 +98,9 @@ function getOS() {
*/ */
navigator.userAgentData.getHighEntropyValues(["architecture", "bitness"]) navigator.userAgentData.getHighEntropyValues(["architecture", "bitness"])
.then(ua => { .then(ua => {
// Init variable OS default
var OS = "windows";
// Check if the platform is Windows // Check if the platform is Windows
if (navigator.userAgentData.platform === "Windows") { if (navigator.userAgentData.platform === "Windows") {
if (ua.architecture === 'arm') { if (ua.architecture === 'arm') {
@ -122,6 +122,9 @@ function getOS() {
// Create function initSync for browsers that don't support navigator.userAgentData (e.g. Gecko-based browsers) // Create function initSync for browsers that don't support navigator.userAgentData (e.g. Gecko-based browsers)
function initSync() { function initSync() {
// Init variable OS default
var OS = "windows";
getOSWinVersionSync(); getOSWinVersionSync();
getOSMacVersion(); getOSMacVersion();
getOSLinuxVersion(); getOSLinuxVersion();