Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Auto merge of rust-lang#1354 - steffengy:master, r=alexcrichton
Browse files Browse the repository at this point in the history
windows: detect architecture on website, update to matching arch (rust-lang#1353)

Updates on windows will now switch over to host appropriate versions,
ensuring the best user experience (e.g. x86_64 builds on x64).

The website can distinguish between Win64/Win32 builds now and
a new platform can be introduced more easily.

r? @alexcrichton
  • Loading branch information
bors authored and AJ-Ianozi committed Feb 13, 2018
1 parent 0de3369 commit 3ce050c
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions www/rustup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var platforms = ["default", "unknown", "win32", "win64", "unix"];
var platform_override = null;

function detect_platform() {
"use strict";

if (platform_override) {
return platform_override;
if (platform_override !== null) {
return platforms[platform_override];
}

var os = "unknown";
Expand All @@ -20,15 +21,18 @@ function detect_platform() {
if (navigator.platform == "Linux mips") {os = "unix";}
if (navigator.platform == "Linux mips64") {os = "unix";}
if (navigator.platform == "Mac") {os = "unix";}
if (navigator.platform == "Win32") {os = "win";}
if (navigator.platform == "Win32") {os = "win32";}
if (navigator.platform == "Win64" ||
navigator.userAgent.indexOf("WOW64") != -1 ||
navigator.userAgent.indexOf("Win64") != -1) { os = "win64"; }
if (navigator.platform == "FreeBSD x86_64") {os = "unix";}
if (navigator.platform == "FreeBSD amd64") {os = "unix";}
if (navigator.platform == "NetBSD x86_64") {os = "unix";}
if (navigator.platform == "NetBSD amd64") {os = "unix";}

// I wish I knew by now, but I don't. Try harder.
if (os == "unknown") {
if (navigator.appVersion.indexOf("Win")!=-1) {os = "win";}
if (navigator.appVersion.indexOf("Win")!=-1) {os = "win32";}
if (navigator.appVersion.indexOf("Mac")!=-1) {os = "unix";}
// rust-www/#692 - FreeBSD epiphany!
if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";}
Expand All @@ -42,39 +46,17 @@ function adjust_for_platform() {

var platform = detect_platform();

var unix_div = document.getElementById("platform-instructions-unix");
var win_div = document.getElementById("platform-instructions-win");
var unknown_div = document.getElementById("platform-instructions-unknown");
var default_div = document.getElementById("platform-instructions-default");

unix_div.style.display = "none";
win_div.style.display = "none";
unknown_div.style.display = "none";
default_div.style.display = "none";

if (platform == "unix") {
unix_div.style.display = "block";
} else if (platform == "win") {
win_div.style.display = "block";
} else if (platform == "unknown") {
unknown_div.style.display = "block";
} else {
default_div.style.display = "block";
}
platforms.forEach(function (platform_elem) {
var platform_div = document.getElementById("platform-instructions-" + platform_elem);
platform_div.style.display = "none";
if (platform == platform_elem) {
platform_div.style.display = "block";
}
});
}

function cycle_platform() {
if (platform_override == null) {
platform_override = "default";
} else if (platform_override == "default") {
platform_override = "unknown";
} else if (platform_override == "unknown") {
platform_override = "win";
} else if (platform_override == "win") {
platform_override = "unix";
} else if (platform_override == "unix") {
platform_override = "default";
}
platform_override = (platform_override + 1) % platforms.length;
adjust_for_platform();
}

Expand Down

0 comments on commit 3ce050c

Please sign in to comment.