diff options
Diffstat (limited to 'site/assets/js/app')
| -rw-r--r-- | site/assets/js/app/site.js | 29 |
1 files changed, 29 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..12bee3ec --- /dev/null +++ b/site/assets/js/app/site.js @@ -0,0 +1,29 @@ +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) } + +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 |
