// This file is licensed under the MIT License (MIT) available on // http://opensource.org/licenses/MIT. function addEvent(a, b, c) { // Attach event to a DOM node. // Ex. addEvent(node,'click',function); return (a.addEventListener) ? a.addEventListener(b, c, false) : (a.attachEvent) ? a.attachEvent('on' + b, c) : false; } function removeEvent(a, b, c) { // Detach event from a DOM node. // Ex. removeEvent(node,'click',function); return (a.removeEventListener) ? a.removeEventListener(b, c, false) : (a.detachEvent) ? a.detachEvent('on' + b, c) : false; } function cancelEvent(e) { // Cancel current event. // Ex. cancelEvent(event); if (!e) var e = window.event; (e.preventDefault) ? e.preventDefault() : e.returnValue = false; } function getEventTarget(e) { // Return target DOM node on which the event is triggered. // Ex. getEventTarget(event); if (!e) var e = window.event; return (e.target && e.target.nodeType == 3) ? e.target.parentNode : (e.target) ? e.target : e.srcElement; } function getStyle(a, b) { // Return the value of the computed style on a DOM node. // Ex. getStyle(node,'padding-bottom'); if (window.getComputedStyle) return document.defaultView.getComputedStyle(a, null).getPropertyValue(b); var n = b.indexOf('-'); if (n !== -1) b = b.substr(0, n) + b.substr(n + 1, 1).toUpperCase() + b.substr(n + 2); return a.currentStyle[b]; } 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 addClass(node, data) { // Add class to node. var cl = node.className.split(' '); for (var i = 0, n = cl.length; i < n; i++) { if (cl[i] == data) return; } cl.push(data); node.className = cl.join(' '); } function removeClass(node, data) { // Remove class from node. var ocl = node.className.split(' '); var ncl = []; for (var i = 0, n = ocl.length; i < n; i++) { if (ocl[i] != data) ncl.push(ocl[i]); } node.className = ncl.join(' '); } function scrollToNode(t) { // Scroll to any node on the page. if (document.body.getAttribute('data-scrollstatus') != null) { 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 x = domPrefixes = 'Webkit Moz ms O'.split(' '); var nd = document.createElement('DIV'); id = id.toLowerCase(); if (nd.style[id] !== undefined) return true; 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 supportsSVG() { // Return true if the browser supports SVG. // Ex. if(!supportsSVG()){..apply png fallback..} // Old FF 3.5 and Safari 3 versions have svg support, but a very poor one // http://www.w3.org/TR/SVG11/feature#Image Defeat FF 3.5 only // http://www.w3.org/TR/SVG11/feature#Animation Defeat Saf 3 but also returns false in IE9 // http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute Defeat Saf 3 but also returns false in Chrome and safari4 // http://www.w3.org/TR/SVG11/feature#Text Defeat Saf 3 but also returns false in FF and safari4 if (!document.createElementNS || !document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect) return false; if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) return false; if (!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicGraphicsAttribute", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation", "1.1") && !document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Text", "1.1")) return false; return true; } function fallbackSVG() { // Replace all images extensions from .svg to .png if browser doesn't support SVG files. if (supportsSVG()) return; for (var i = 0, nd = document.getElementsByTagName('*'), n = nd.length; i < n; i++) { if (nd[i].nodeName == 'IMG' && /.*\.svg$/.test(nd[i].src)) nd[i].src = nd[i].src.slice(0, -3) + 'png'; if (/\.svg/.test(getStyle(nd[i], 'background-image'))) nd[i].style.backgroundImage = getStyle(nd[i], 'background-image').replace('.svg', '.png'); if (/\.svg/.test(getStyle(nd[i], 'background'))) nd[i].style.background = getStyle(nd[i], 'background').replace('.svg', '.png'); } } function mobileMenuShow(e) { // Show the mobile menu when the visitors touch the menu icon. var mm = document.getElementById('menusimple'); var ml = document.getElementById('langselect'); var t = document.getElementById('menumobile'); mm.style.display = ml.style.display = (mm.style.display == 'block') ? '' : 'block'; t.parentNode.removeChild(t); cancelEvent(e); } function mobileMenuHover(e) { // Add a delay before hiding menu for mobiles to prevent accidental clicks. var p = t = getEventTarget(e); if (t.nodeName != 'A') return; while (p.parentNode.nodeName != 'DIV') p = p.parentNode; while (t.nodeName != 'LI' || t.parentNode != p) t = t.parentNode; var ul = null; if (t.getElementsByTagName('UL').length > 0) { var ul = t.getElementsByTagName('UL')[0]; addClass(ul, 'hover'); } setTimeout(function() { for (var i = 0, nd = p.getElementsByTagName('UL'), n = nd.length; i < n; i++) { if (nd[i] == ul) continue; removeClass(nd[i], 'hover'); } }, 1); } function boxShow(e) { // Display the box content when the user click a box on the "Secure your wallet" page. var p = t = getEventTarget(e); while (p.nodeName != 'DIV') p = p.parentNode; var sh = getHeight(p); for (var i = 0, nds = p.childNodes, n = nds.length; i < n; i++) if (nds[i].nodeType == 1) nds[i].style.display = 'block'; t.removeAttribute('href'); t.onclick = ''; var dh = getHeight(p); p.style.height = sh + 'px'; setTimeout(function() { p.style.transition = 'height 400ms ease-out'; p.style.MozTransition = 'height 400ms ease-out'; p.style.WebkitTransition = 'height 400ms ease-out'; setTimeout(function() { p.style.height = dh + 'px'; }, 20); }, 20); cancelEvent(e); } function faqShow(e) { // Display the content of a question in the FAQ at user request. var p = t = getEventTarget(e); while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.nextSibling; var pp = p.cloneNode(true); pp.style.visibility = 'hidden'; pp.style.height = 'auto'; p.parentNode.appendChild(pp); var nhe = getHeight(pp); pp.parentNode.removeChild(pp); p.style.height = (p.style.height != '0px' && p.style.height != '') ? '0px' : nhe + 'px'; cancelEvent(e); } function materialShow(e) { // Display more materials on the "Press center" page at user request. var p = t = getEventTarget(e); while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.previousSibling; var pp = p.cloneNode(true); pp.style.visibility = 'hidden'; pp.style.height = 'auto'; p.parentNode.appendChild(pp); var nhe = getHeight(pp); pp.parentNode.removeChild(pp); p.style.height = (p.style.height != '0px' && p.style.height != '') ? '0px' : nhe + 'px'; t.style.display = 'none'; cancelEvent(e); } function librariesShow(e) { // Display more open source projects on the "Development" page at user request. var p = t = getEventTarget(e); while (p.nodeType != 1 || p.nodeName != 'UL') p = p.parentNode; var sh = getHeight(p); for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) nds[i].style.display = 'list-item'; t.parentNode.parentNode.removeChild(t.parentNode); var dh = getHeight(p); p.style.height = sh + 'px'; setTimeout(function() { p.style.transition = 'height 400ms ease-out'; p.style.MozTransition = 'height 400ms ease-out'; p.style.WebkitTransition = 'height 400ms ease-out'; setTimeout(function() { p.style.height = dh + 'px'; }, 20); }, 20); cancelEvent(e); } function freenodeShow(e) { // Display freenode chat window on the "Development" page at user request. document.getElementById('chatbox').innerHTML = '