From 7647a602191f0a5818204c1000e793b2a42e964d Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 10 Aug 2021 19:48:15 +0530 Subject: [PATCH] guess OS version on checkup page --- www/checkup/app-checkup.less | 5 ++--- www/checkup/checkup-tools.js | 19 +++++++++++++++++++ www/checkup/main.js | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/www/checkup/app-checkup.less b/www/checkup/app-checkup.less index 026d1952c..d5cab9c63 100644 --- a/www/checkup/app-checkup.less +++ b/www/checkup/app-checkup.less @@ -88,11 +88,10 @@ html, body { .cp-notice-browser, .cp-notice-details, .cp-notice-other { font-size: 70%; } - + .underline { text-decoration: underline; } .cp-app-checkup-version, .cp-app-checkup-browser { - text-decoration: underline; + .underline; } - iframe { display: none; } diff --git a/www/checkup/checkup-tools.js b/www/checkup/checkup-tools.js index 79fe1c4b3..f9259ff28 100644 --- a/www/checkup/checkup-tools.js +++ b/www/checkup/checkup-tools.js @@ -14,6 +14,25 @@ define([ return false; }; + var OS_HINTS = { + "Win": "Windows", + "Mac": "MacOS", + "X11": "UNIX", + "Linux": "Linux", + }; + + Tools.guessOS = function () { + var result = "UNKNOWN"; + if (!window.navigator || !window.navigator.appVersion) { return result; } + result = window.navigator.appVersion; + console.log(result); + Object.keys(OS_HINTS).some(function (key) { + if (result.indexOf(key) === -1) { return; } + result = OS_HINTS[key]; // else + return true; + }); + return result; + }; Tools.isSafari = function () { return navigator.vendor.match(/apple/i); diff --git a/www/checkup/main.js b/www/checkup/main.js index a1e458f34..a262d0e4c 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -932,7 +932,9 @@ define([ return h('p.cp-notice-browser', [ "You appear to be using a ", h('span.cp-app-checkup-browser', name), - ' browser to view this page.', + ' browser on ', + h('span.underline', Tools.guessOS()), + ' to view this page.', ]); };