diff options
Diffstat (limited to 'docs/js/util.js')
| -rw-r--r-- | docs/js/util.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/js/util.js b/docs/js/util.js index 9455825..e40db4a 100644 --- a/docs/js/util.js +++ b/docs/js/util.js @@ -1,3 +1,10 @@ +const is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +const is_ipad = (navigator.userAgent.match(/iPad/i)) +const is_android = (navigator.userAgent.match(/Android/i)) +const is_mobile = is_iphone || is_ipad || is_android +const is_desktop = !is_mobile; +document.body.parentNode.classList.add(is_desktop ? 'desktop' : 'mobile') + function avg(a,b,n){ return (a*(n-1) + b)/n } function rand(n){ return Math.random()*n } function randint(n) { return ~~(Math.random()*n) } |
