From 5d76f8ce4fe6027ed92e3f05471193f1f595906d Mon Sep 17 00:00:00 2001 From: Chris Broadfoot Date: Tue, 10 Jan 2017 14:20:17 -0800 Subject: [PATCH] static: detect platform to hide/show unix/windows instructions Currently both "testUnix" and "testWindows" elements are shown simultaneously. This change detects the correct platform to hide/show the appropriate elements based on the viewer's browser. Change-Id: I3afee7507d61b2d756127166caede85adcd531b8 Reviewed-on: https://go-review.googlesource.com/35103 Reviewed-by: Brad Fitzpatrick --- godoc/static/godocs.js | 9 ++++++++- godoc/static/static.go | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/godoc/static/godocs.js b/godoc/static/godocs.js index 1fb8b91e..3ce27ea6 100644 --- a/godoc/static/godocs.js +++ b/godoc/static/godocs.js @@ -263,7 +263,14 @@ function personalizeInstallInstructions() { var prefix = '?download='; var s = window.location.search; if (s.indexOf(prefix) != 0) { - // No 'download' query string; bail. + // No 'download' query string; detect "test" instructions from User Agent. + if (navigator.platform.indexOf('Win') != -1) { + $('.testUnix').hide(); + $('.testWindows').show(); + } else { + $('.testUnix').show(); + $('.testWindows').hide(); + } return; } diff --git a/godoc/static/static.go b/godoc/static/static.go index a47a7fd0..6fab8da3 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -833,7 +833,14 @@ function personalizeInstallInstructions() { var prefix = '?download='; var s = window.location.search; if (s.indexOf(prefix) != 0) { - // No 'download' query string; bail. + // No 'download' query string; detect "test" instructions from User Agent. + if (navigator.platform.indexOf('Win') != -1) { + $('.testUnix').hide(); + $('.testWindows').show(); + } else { + $('.testUnix').show(); + $('.testWindows').hide(); + } return; }