summaryrefslogtreecommitdiff
path: root/docs/js/util.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-11-25 23:20:01 +0100
committerJules Laplace <julescarbon@gmail.com>2018-11-25 23:20:01 +0100
commit72d70421ac7ec141a8a820c23cec54507b411dee (patch)
tree9ed2ebab1028061fadf4df01c2426b2863130e56 /docs/js/util.js
parentb9426877cfe30b74d03ec756b93bd047c402d7ad (diff)
mobile css
Diffstat (limited to 'docs/js/util.js')
-rw-r--r--docs/js/util.js7
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) }