Advertisement
Guest User

Untitled

a guest
May 27th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. var matchesOSPrefix = function(prefix) {
  2. var pre = prefix.toLowerCase();
  3. var platform = window.navigator.platform.toLowerCase();
  4. return platform.indexOf(pre) === 0;
  5. };
  6.  
  7. var windows = function() {
  8. return matchesOSPrefix('Win');
  9. };
  10.  
  11. var mac = function() {
  12. return matchesOSPrefix('Mac') || matchesOSPrefix('iP');
  13. };
  14.  
  15. if (windows()) {
  16. // Display PS Command
  17. console.log('Windows');
  18. } else if (mac()) {
  19. // Display OSX Command (curl)
  20. console.log('Mac');
  21. } else {
  22. // Display Linux Command (curl, wget?)
  23. console.log('Linux');
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement