Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1018594 // hjs_getOS

JavaX fragment (include)

1  
sS hjs_getOS() {
2  
  ret hjavascript([[
3  
    function getOS() {
4  
      var userAgent = window.navigator.userAgent,
5  
          platform = window.navigator.platform,
6  
          macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
7  
          windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
8  
          iosPlatforms = ['iPhone', 'iPad', 'iPod'],
9  
          os = null;
10  
    
11  
      if (macosPlatforms.indexOf(platform) !== -1) {
12  
        os = 'Mac OS';
13  
      } else if (iosPlatforms.indexOf(platform) !== -1) {
14  
        os = 'iOS';
15  
      } else if (windowsPlatforms.indexOf(platform) !== -1) {
16  
        os = 'Windows';
17  
      } else if (/Android/.test(userAgent)) {
18  
        os = 'Android';
19  
      } else if (!os && /Linux/.test(platform)) {
20  
        os = 'Linux';
21  
      }
22  
    
23  
      return os;
24  
    }
25  
  ]]);
26  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018594
Snippet name: hjs_getOS
Eternal ID of this version: #1018594/1
Text MD5: 0a1f35844eab5dee2c9991a694a5b8f3
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-06 22:09:25
Source code size: 832 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 280 / 311
Referenced in: [show references]