diff options
| author | adamhrv <adam@ahprojects.com> | 2018-12-15 19:57:49 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2018-12-15 19:57:49 +0100 |
| commit | 82b2c0b5d6d7baccbe4d574d96e18fe2078047d7 (patch) | |
| tree | a8784b7ec2bc5a0451c252f66a6b786f3a2504f5 /site/assets/js/app/site.js | |
| parent | 8e978af21c2b29f678a09701afb3ec7d65d0a6ab (diff) | |
| parent | c5b02ffab8d388e8a2925e51736b902a48a95e71 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'site/assets/js/app/site.js')
| -rw-r--r-- | site/assets/js/app/site.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/site/assets/js/app/site.js b/site/assets/js/app/site.js new file mode 100644 index 00000000..eb6886c2 --- /dev/null +++ b/site/assets/js/app/site.js @@ -0,0 +1,30 @@ +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 + +const htmlClassList = document.body.parentNode.classList +htmlClassList.add(isDesktop ? 'desktop' : 'mobile') + +function toArray(a) { return Array.prototype.slice.apply(a) } +function choice(a) { return a[Math.floor(Math.random()*a.length)]} + +var site = (function(){ + var site = {} + site.init = function(){ + site.build() + } + site.build = function(){ + const paras = document.querySelectorAll("section p") + if (paras.length) { + paras[0].classList.add('first_paragraph') + } + toArray(document.querySelectorAll('header .links a')).forEach(tag => { + if (window.location.href.match(tag.href)) { + tag.classList.add('active') + } + }) + } + site.init() +})()
\ No newline at end of file |
