// This file is licensed under the MIT License (MIT) available on // https://opensource.org/licenses/MIT. // This file is used for javascript code // necessary for some pages to work properly. "use strict"; function getWidth(a) { // Return the integer value of the computed width of a DOM node. // Ex. getWidth(node); var w = getStyle(a, 'width'); if (w.indexOf('px') !== -1) return parseInt(w.replace('px', '')); var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; for (var i = 0; i < 4; i++) { p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; } return Math.max(0, a.offsetWidth - p[1] - p[3]); } function getHeight(a) { // Return the integer value of the computed height of a DOM node. // Ex. getHeight(node); var h = getStyle(a, 'height'); if (h.indexOf('px') !== -1) return parseInt(h.replace('px', '')); var p = [getStyle(a, 'padding-top'), getStyle(a, 'padding-right'), getStyle(a, 'padding-bottom'), getStyle(a, 'padding-left')]; for (var i = 0; i < 4; i++) { p[i] = (p[i].indexOf('px') !== -1) ? parseInt(p[i]) : 0; } return Math.max(0, a.offsetHeight - p[0] - p[2]); } function getLeft(a) { // Return the integer value of the computed distance between given node and the browser window. // Ex. getLeft(node); var b = a.offsetLeft; while (a.offsetParent) { a = a.offsetParent; b += a.offsetLeft; } return b; } function getTop(a) { // Return the integer value of the computed distance between given node and the browser window. // Ex. getTop(node); var b = a.offsetTop; while (a.offsetParent) { a = a.offsetParent; b += a.offsetTop; } return b; } function getPageYOffset() { // Return the integer value for the vertical position of the scroll bar. return window.pageYOffset || document.documentElement.scrollTop; } function getPageXOffset() { // Return the integer value for the horizontal position of the scroll bar. return window.pageXOffset || document.documentElement.scrollLeft; } function getWindowY() { // Return the integer value for the browser window height. return window.innerHeight || document.documentElement.clientHeight; } function getWindowX() { // Return the integer value for the browser window width. return window.innerWidth || document.documentElement.clientWidth; } function isMobile() { // Return true if the mobile CSS stylesheet is used. if (getStyle(document.getElementById('detectmobile'), 'display') !== 'none') return true; return false; } function scrollToNode(t) { // Scroll to any node on the page. var status = document.body.getAttribute('data-scrollstatus'); if (status !== null && status !== '') { clearInterval(document.body.getAttribute('data-scrollstatus')); document.body.removeAttribute('data-scrollstatus'); } var delay = 800; var py = getPageYOffset(); var fy = getTop(t); var dy = fy - py; var x = getPageXOffset(); var oti = new Date().getTime(); document.body.setAttribute('data-scrollstatus', setInterval(function() { var nti = new Date().getTime() - oti; if (nti >= delay) { window.scrollTo(x, fy); clearInterval(document.body.getAttribute('data-scrollstatus')); document.body.removeAttribute('data-scrollstatus'); return; } var p = nti / delay; p = p * (1 + (0.5 * (1 - p))); window.scrollTo(x, (py + (dy * p)).toFixed(0)); }, 10)); } function supportCSS(id) { // Return true if the browser supports given CSS feature. var domPrefixes = 'Webkit Moz ms O'.split(' '); var nd = document.createElement('DIV'); id = id.toLowerCase(); if (nd.style[id] !== undefined) return true; var idc = id.charAt(0).toUpperCase() + id.substr(1); for (var i = 0, n = domPrefixes.length; i < n; i++) { if (nd.style[domPrefixes[i] + idc] !== undefined) return true; } return false; } function loadYoutubeVideo(e) { var open = document.querySelector(".mainvideo-btn-open"); var close = document.querySelector(".mainvideo-btn-close"); var modal = document.querySelector(".modal"); var video = document.querySelector(".modal-video"); var modalOverlay = document.querySelector(".modal-overlay"); if (e.target === open) { modal.classList.remove("closed"); video.src = open.getAttribute("data-youtubeurl"); modalOverlay.classList.remove("closed"); } else if (e.target === close) { modal.classList.add("closed"); video.src = ""; modalOverlay.classList.add("closed"); } } function expandBox(t) { // Expand or shrink box. t.style.transition = t.style.MozTransition = t.style.WebkitTransition = 'all 0s ease 0s'; if (t.className.indexOf('expanded') === -1) addClass(t, 'expanded'); else removeClass(t, 'expanded'); setTimeout(function() { t.style.transition = t.style.MozTransition = t.style.WebkitTransition = ''; }, 20); } function boxShow(e) { function init(e) { var t = getEvent(e, 'target'); while (t.nodeName !== 'DIV') t = t.parentNode; expandBox(t); cancelEvent(e); } document.querySelectorAll(".boxexpand > h1:first-child").forEach(function(accordionToggle) { return accordionToggle.addEventListener("click", init); }); document.querySelectorAll(".boxexpand > h2:first-child").forEach(function(accordionToggle) { return accordionToggle.addEventListener("click", init); }); document.querySelectorAll(".boxexpand > h3:first-child").forEach(function(accordionToggle) { return accordionToggle.addEventListener("click", init); }); } function faqShow(e) { // Display the content of a question in the FAQ at user request. function init(e) { var t = getEvent(e, 'target'); while (t.nodeType !== 1 || t.nodeName !== 'DIV') t = t.nextSibling; expandBox(t); cancelEvent(e); } onTouchClick(e, init); } function materialShow(e) { // Display more materials on the "Press center" page at user request. function init(e) { var t = getEvent(e, 'target'), p = t; while (p.nodeType !== 1 || p.nodeName !== 'DIV') p = p.parentNode; expandBox(p); cancelEvent(e); } onTouchClick(e, init); } function librariesShow(e) { // Display more open source projects on the "Development" page at user request. function init(e) { var t = getEvent(e, 'target'), p = t; while (p.nodeType !== 1 || p.nodeName !== 'UL') p = p.parentNode; expandBox(p); cancelEvent(e); } onTouchClick(e, init); } function freenodeShow(e) { // Display freenode chat window on the "Development" page at user request. document.getElementById('chatbox').innerHTML = '