Skip to content

Commit

Permalink
/apps/: Detect the user OS and show the appropriate app by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerkid authored and timabbott committed Aug 21, 2017
1 parent e1cc045 commit 517d9b7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions static/js/portico/landing-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ var apps_events = function () {

var version;

function get_user_os() {
if (/Android/i.test(navigator.userAgent)) {
return "android";
}
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
return "ios";
}
if (/Mac/i.test(navigator.userAgent)) {
return "mac";
}
if (/Win/i.test(navigator.userAgent)) {
return "windows";
}
if (/Linux/i.test(navigator.userAgent)) {
return "linux";
}
return "mac"; // if unable to determine OS return Mac by default
}

function get_version_from_path() {
var result;
var parts = path_parts();
Expand All @@ -85,8 +104,7 @@ var apps_events = function () {
}
});

// display Mac app by default
result = result || 'mac';
result = result || get_user_os();
return result;
}

Expand Down

0 comments on commit 517d9b7

Please sign in to comment.