blob: 6b1e274e18904f673fbb076eb8e312409ff3fef7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
const isIphone = !! (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))
const isIpad = !! (navigator.userAgent.match(/iPad/i))
const isAndroid = !! (navigator.userAgent.match(/Android/i))
const isMobile = isIphone || isIpad || isAndroid
const isDesktop = ! isMobile
document.body.classList.add(isDesktop ? 'desktop' : 'mobile')
function randint(n){ return (Math.random()*n)|0 }
function randrange(a,b){ return (Math.random()*(b-a)+a)|0 }
function choice(a){ return a[randint(a.length)] }
export {
isIphone, isIpad, isAndroid, isMobile, isDesktop,
randint, randrange, choice,
}
|