diff --git a/js/base.js b/js/base.js index e165902a..fc778401 100644 --- a/js/base.js +++ b/js/base.js @@ -4,7 +4,7 @@ // This file should be used only for javascript code // necessary for all pages to work properly. -"use strict" +"use strict"; function addEvent(a, b, c) { // Attach event to a DOM node. @@ -21,7 +21,7 @@ function removeEvent(a, b, c) { function cancelEvent(e) { // Cancel current event. // Ex. cancelEvent(event); - if (!e) var e = window.event; + e = e || window.event; (e.preventDefault) ? e.preventDefault(): e.returnValue = false; } @@ -33,7 +33,7 @@ function getEvent(e, a) { case 'type': return e.type; case 'target': - return (e.target && e.target.nodeType == 3) ? e.target.parentNode : (e.target) ? e.target : e.srcElement; + return (e.target && e.target.nodeType === 3) ? e.target.parentNode : (e.target) ? e.target : e.srcElement; } } @@ -50,7 +50,7 @@ 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; + if (cl[i] === data) return; } cl.push(data); node.className = cl.join(' '); @@ -61,7 +61,7 @@ function removeClass(node, data) { 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]); + if (ocl[i] !== data) ncl.push(ocl[i]); } node.className = ncl.join(' '); } @@ -84,7 +84,7 @@ 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 (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'); } @@ -105,7 +105,7 @@ function onTouchClick(e, callback, callbackClick) { // Cancel click events on different targets within timeframe. // This avoids accidental clicks when the page is scrolled or updated due to the 300ms click event delay on mobiles. removeEvent(document.body, 'click', wrongClickListener); - if (!clickReady() && getEvent(e, 'target') != t) cancelEvent(e); + if (!clickReady() && getEvent(e, 'target') !== t) cancelEvent(e); }, setClickTimeout = function() { // Update timeout during which click events will be blocked. @@ -146,7 +146,7 @@ function mobileMenuShow(e) { var show = function() { var mm = document.getElementById('menusimple'); var ml = document.getElementById('langselect'); - mm.style.display = ml.style.display = (mm.style.display == 'block') ? '' : 'block'; + mm.style.display = ml.style.display = (mm.style.display === 'block') ? '' : 'block'; addClass(mm, 'menutap'); cancelEvent(e); }; @@ -158,18 +158,18 @@ function mobileMenuHover(e) { var t = getEvent(e, 'target'), fn = (t.parentNode.className.indexOf('hover') === -1) ? addClass : removeClass, initHover = function() { - if (t.nodeName != 'A') return; - if (fn == removeClass && !hasSubItems(t)) return; + if (t.nodeName !== 'A') return; + if (fn === removeClass && !hasSubItems(t)) return; var p = t; - while (p.parentNode.nodeName == 'UL' || p.parentNode.nodeName == 'LI') p = p.parentNode; + while (p.parentNode.nodeName === 'UL' || p.parentNode.nodeName === 'LI') p = p.parentNode; for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) { - if (nds[i] == t.parentNode) continue; + if (nds[i] === t.parentNode) continue; removeClass(nds[i], 'active'); if (hasSubItems(nds[i])) continue; removeClass(nds[i], 'hover'); } - while (t != p) { - if (t.nodeName == 'LI') { + while (t !== p) { + if (t.nodeName === 'LI') { fn(t, 'hover'); fn(t, 'active'); } @@ -177,13 +177,13 @@ function mobileMenuHover(e) { } }, hasSubItems = function(t) { - while (t.nodeName != 'LI') t = t.parentNode; + while (t.nodeName !== 'LI') t = t.parentNode; return (t.getElementsByTagName('UL').length > 0); }, // Prevent clicks on parent element links in the menu. filterClick = function(e) { var t = getEvent(e, 'target'); - if (t.nodeName != 'A') return; + if (t.nodeName !== 'A') return; if (hasSubItems(t)) cancelEvent(e); }; onTouchClick(e, initHover, filterClick); @@ -198,7 +198,7 @@ function addAnchorLinks() { } for (var i = 0, n = nodes.length; i < n; i++) { if (!nodes[i].id) continue; - if (nodes[i].getElementsByTagName('A').length > 0 && nodes[i].getElementsByTagName('A')[0].innerHTML == '') return; + if (nodes[i].getElementsByTagName('A').length > 0 && nodes[i].getElementsByTagName('A')[0].innerHTML === '') return; addClass(nodes[i], 'anchorAf'); var anc = document.createElement('A'); anc.href = '#' + nodes[i].id; diff --git a/js/devsearch.js b/js/devsearch.js index 2d3490a9..51bab4fb 100644 --- a/js/devsearch.js +++ b/js/devsearch.js @@ -19,7 +19,7 @@ Nested loops below: {% endcomment %} -"use strict" +"use strict"; var search_data = [ {% for list in site.devsearches %}{% for item in list %} @@ -29,8 +29,7 @@ var search_data = [ label: "{{term[0]}}", uri: "{{term[1]}}", category: "{{category_name}}" -} -{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %}{% endif %}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %} +}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %}{% endif %}{% endfor %}{% unless forloop.last %},{% endunless %}{% endfor %} ]; @@ -48,7 +47,7 @@ $.widget("custom.catcomplete", $.ui.autocomplete, { currentCategory = ""; $.each(items, function(index, item) { var li; - if (item.category != currentCategory) { + if (item.category !== currentCategory) { ul.append("
  • " + item.category + "
  • "); currentCategory = item.category; } diff --git a/js/events.js b/js/events.js index ce8d6837..6da7de45 100644 --- a/js/events.js +++ b/js/events.js @@ -5,11 +5,11 @@ layout: null --- -"use strict" +"use strict"; var zoom = 2; var minzoom = 1; -if (isMobile()) var zoom = minzoom = 0; +if (isMobile()) zoom = minzoom = 0; var map = L.map('eventmap', { 'zoom': zoom, 'minZoom': minzoom, diff --git a/js/ie.js b/js/ie.js index 209a1a66..861c4842 100644 --- a/js/ie.js +++ b/js/ie.js @@ -1,26 +1,26 @@ // This file is licensed under the MIT License (MIT) available on // http://opensource.org/licenses/MIT. -"use strict" +"use strict"; function pngfix() { //Allows IE6 to render transparent png - var arVersion = navigator.appVersion.split("MSIE") - var version = parseFloat(arVersion[1]) + var arVersion = navigator.appVersion.split("MSIE"); + var version = parseFloat(arVersion[1]); if ((version >= 5.5) && (document.body.filters)) { for (var i = 0; i < document.images.length; i++) { - var img = document.images[i] - var imgName = img.src.toUpperCase() - if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") + var img = document.images[i]; + var imgName = img.src.toUpperCase(); + if (imgName.substring(imgName.length - 3, imgName.length) === "PNG") { //Workaround to skip github icons if (img.src.indexOf('gravatar.com') !== -1) continue; - var imgID = (img.id) ? "id='" + img.id + "' " : "" - var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' " - var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " - var imgStyle = "display:inline-block;" + img.style.cssText + var imgID = (img.id) ? "id='" + img.id + "' " : ""; + var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' "; + var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "; + var imgStyle = "display:inline-block;" + img.style.cssText; var imgWidth = img.width; var imgHeight = img.height; //Workaround for hidden img to prevent 0px width and height @@ -28,19 +28,16 @@ function pngfix() { imgWidth = '72'; imgHeight = '72'; } - if (img.align == "left") imgStyle = "float:left;" + imgStyle - if (img.align == "right") imgStyle = "float:right;" + imgStyle - if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle - var strNewHTML = "" - img.outerHTML = strNewHTML - i = i - 1 + if (img.align === "left") imgStyle = "float:left;" + imgStyle; + if (img.align === "right") imgStyle = "float:right;" + imgStyle; + if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle; + var strNewHTML = ""; + img.outerHTML = strNewHTML; + i = i - 1; } } } } -//Let other scripts know browser is IE6-7 -var legacyIE = true; - //Render all transparent pngs window.onload = pngfix; diff --git a/js/main.js b/js/main.js index d84bccd2..7e189bca 100644 --- a/js/main.js +++ b/js/main.js @@ -4,7 +4,7 @@ // This file is used for javascript code // necessary for some pages to work properly. -"use strict" +"use strict"; function getWidth(a) { // Return the integer value of the computed width of a DOM node. @@ -74,19 +74,20 @@ function getWindowX() { function isMobile() { // Return true if the mobile CSS stylesheet is used. - if (getStyle(document.getElementById('detectmobile'), 'display') != 'none') return true; + if (getStyle(document.getElementById('detectmobile'), 'display') !== 'none') return true; return false; } function scrollToNode(t) { // Scroll to any node on the page. - if (document.body.getAttribute('data-scrollstatus') != null) { + 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 fy = getTop(t); var dy = fy - py; var x = getPageXOffset(); var oti = new Date().getTime(); @@ -110,7 +111,7 @@ function supportCSS(id) { var nd = document.createElement('DIV'); id = id.toLowerCase(); if (nd.style[id] !== undefined) return true; - idc = id.charAt(0).toUpperCase() + id.substr(1); + 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; } @@ -153,7 +154,7 @@ function boxShow(e) { // Display the box content when the user click a box on the "Secure your wallet" page. function init(e) { var t = getEvent(e, 'target'); - while (t.nodeName != 'DIV') t = t.parentNode; + while (t.nodeName !== 'DIV') t = t.parentNode; expandBox(t); cancelEvent(e); } @@ -164,7 +165,7 @@ 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; + while (t.nodeType !== 1 || t.nodeName !== 'DIV') t = t.nextSibling; expandBox(t); cancelEvent(e); } @@ -176,7 +177,7 @@ function materialShow(e) { function init(e) { var t = getEvent(e, 'target'), p = t; - while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.parentNode; + while (p.nodeType !== 1 || p.nodeName !== 'DIV') p = p.parentNode; expandBox(p); cancelEvent(e); } @@ -188,7 +189,7 @@ function librariesShow(e) { function init(e) { var t = getEvent(e, 'target'), p = t; - while (p.nodeType != 1 || p.nodeName != 'UL') p = p.parentNode; + while (p.nodeType !== 1 || p.nodeName !== 'UL') p = p.parentNode; expandBox(p); cancelEvent(e); } @@ -210,13 +211,13 @@ function updateToc() { var first; var last; var closer; - var init = function() { + function init() { setenv(); updatehistory(); updatetoc(); } // Set variables. - var setenv = function() { + function setenv() { pageoffset = getPageYOffset(); windowy = getWindowY(); toc = document.getElementById('toc'); @@ -246,7 +247,7 @@ function updateToc() { if (windowy + pageoffset >= getHeight(document.body)) closer = [last[0], last[1]]; } // Update toc position and set active toc entry. - var updatetoc = function() { + function updatetoc() { // Set bottom and top to fit within window and not overflow its parent node. var div = toc.getElementsByTagName('DIV')[0]; if (pageoffset > getTop(toc)) { @@ -258,19 +259,19 @@ function updateToc() { var a = false; for (var i = 0, t = toc.getElementsByTagName('*'), n = t.length; i < n; i++) { removeClass(t[i], 'active'); - if (t[i].nodeName == 'A' && t[i].getAttribute('href') == '#' + closer[0].id) a = t[i]; + if (t[i].nodeName === 'A' && t[i].getAttribute('href') === '#' + closer[0].id) a = t[i]; } if (a === false) return; // Set .active class on new active toc entry. var nd = a; - while (nd.parentNode.nodeName == 'LI' || nd.parentNode.nodeName == 'UL') { + while (nd.parentNode.nodeName === 'LI' || nd.parentNode.nodeName === 'UL') { addClass(nd, 'active'); nd = nd.parentNode; } // Auto-scroll in toc to keep active toc entry visible. var nd = a; var otop = nd.offsetTop; - while (nd.offsetParent != div && nd.offsetParent) { + while (nd.offsetParent !== div && nd.offsetParent) { nd = nd.offsetParent; otop += nd.offsetTop; } @@ -279,7 +280,7 @@ function updateToc() { if (tdiff > 0 || bdiff > 0) div.scrollTop -= tdiff; } // Update browser url. - var updatehistory = function() { + function updatehistory() { // Don't call window.history if not supported. if (!window.history || !window.history.replaceState) return; // Don't update window url when it doesn't need to be updated. @@ -291,13 +292,13 @@ function updateToc() { window.history.replaceState(null, null, '#' + closer[0].id); } // Update the toc when the page stops scrolling. - var evtimeout = function() { + function evtimeout() { toc = document.getElementById('toc'); clearTimeout(toc.getAttribute('data-timeout')); toc.setAttribute('data-timeout', setTimeout(init, 1)); } // Reset timestamp on page load and each time the user clicks a url. - var evtimestamp = function() { + function evtimestamp() { toc = document.getElementById('toc'); document.getElementById('toc').setAttribute('data-timestamp', new Date().getTime()); } @@ -341,7 +342,7 @@ function updateSource(e) { function disclaimerClose(e) { // Auto close temporary disclaimer in devel-docs. if (e) cancelEvent(e); - var t = document.getElementById('develdocdisclaimer') + var t = document.getElementById('develdocdisclaimer'); t.parentNode.removeChild(t); if (typeof(Storage) === 'undefined') return; sessionStorage.setItem('develdocdisclaimerclose', '1'); @@ -358,19 +359,19 @@ function walletMenuListener(e) { var walletSelectPlatform = function(e) { var t = getEvent(e, 'target'), p = t; - if (t.nodeName != 'A') return; - while (p.parentNode.nodeName == 'UL' || p.parentNode.nodeName == 'LI') p = p.parentNode; + if (t.nodeName !== 'A') return; + while (p.parentNode.nodeName === 'UL' || p.parentNode.nodeName === 'LI') p = p.parentNode; for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) removeClass(nds[i], 'active'); var tt = t; - while (tt != p) { - if (tt.nodeName == 'LI') addClass(tt, 'active'); + while (tt !== p) { + if (tt.nodeName === 'LI') addClass(tt, 'active'); tt = tt.parentNode; } walletShowPlatform(t.getAttribute('data-walletcompat')); if (isMobile() && !hasSubItems(t)) scrollToNode(document.getElementById('wallets')); }, hasSubItems = function(t) { - while (t.nodeName != 'LI') t = t.parentNode; + while (t.nodeName !== 'LI') t = t.parentNode; return (t.getElementsByTagName('UL').length > 0); }; // Pre-process events and call appropriate function. @@ -382,8 +383,8 @@ function walletListener(e) { var t = getEvent(e, 'target'), walletShow = function() { // Show wallet on click on mobile or desktop. - if (t.id == 'wallets') return; - while (t.parentNode && t.parentNode.id != 'wallets') t = t.parentNode; + if (t.id === 'wallets') return; + while (t.parentNode && t.parentNode.id !== 'wallets') t = t.parentNode; if (!t.parentNode) return; if (isMobile()) { var p = document.getElementById('walletsmobile'); @@ -399,7 +400,7 @@ function walletListener(e) { walletHide = function() { // Disable wallet when the mouse clicks elsewhere. for (var i = 0, wallets = document.getElementById('wallets').childNodes, n = wallets.length; i < n; i++) { - if (wallets[i].nodeType != 1) continue; + if (wallets[i].nodeType !== 1) continue; removeClass(wallets[i], 'active'); } removeEvent(document.body, 'click', walletListener); @@ -429,11 +430,11 @@ function walletShowPlatform(platform) { getMenuState = function() { // Find active node in the menu for given platform and fallback category if in a submenu. for (var i = 0, nds = walletMenu.getElementsByTagName('A'), n = nds.length; i < n; i++) { - if (nds[i].getAttribute('data-walletcompat') != platform) continue; - if (nds[i].getAttribute('data-active') == 1) return false; + if (nds[i].getAttribute('data-walletcompat') !== platform) continue; + if (nds[i].getAttribute('data-active') === '1') return false; t = nds[i]; var p = nds[i].parentNode.parentNode.parentNode; - if (p.nodeName == 'LI') fallback = p.getElementsByTagName('A')[0].getAttribute('data-walletcompat'); + if (p.nodeName === 'LI') fallback = p.getElementsByTagName('A')[0].getAttribute('data-walletcompat'); break; } return true; @@ -445,11 +446,11 @@ function walletShowPlatform(platform) { nds[i].removeAttribute('data-active'); removeClass(nds[i].parentNode, 'active'); } - if (platform != 'default') { + if (platform !== 'default') { t.setAttribute('data-active', '1'); addClass(t.parentNode, 'active'); var p = t.parentNode.parentNode.parentNode; - if (p.nodeName == 'LI') addClass(p, 'active'); + if (p.nodeName === 'LI') addClass(p, 'active'); } }, updateWallets = function() { @@ -462,9 +463,9 @@ function walletShowPlatform(platform) { clearTimeout(lasttimeout); p.setAttribute('data-timeout', setTimeout(function() { p.innerHTML = ''; - var platforms = (platform == 'default') ? ['desktop', 'mobile'] : [platform]; + var platforms = (platform === 'default') ? ['desktop', 'mobile'] : [platform]; for (var i = 0, nds = document.getElementById('walletsswitch').childNodes, n = nds.length; i < n; i++) { - if (nds[i].nodeType != 1) continue; + if (nds[i].nodeType !== 1) continue; var id = nds[i].id.split('-')[1]; if (document.getElementById('wallet-' + id)) continue; var nd = null; @@ -498,14 +499,15 @@ function walletRotate() { 2: [], 3: [], 4: [] - } + }; for (var i = 0, nds = document.getElementById('wallets').childNodes, n = nds.length; i < n; i++) { - if (nds[i].nodeType != 1) continue; + if (nds[i].nodeType !== 1) continue; ar[parseInt(nds[i].getAttribute('data-walletlevel'))].push(nds[i]); } var sum = Math.floor(new Date() / 86400000); for (var k in ar) { - if (ar[k].length == 0) continue; + if (!ar.hasOwnProperty(k)) continue; + if (ar[k].length === 0) continue; var pre = ar[k][ar[k].length - 1].nextSibling; for (i = 0, n = sum % ar[k].length; i < n; i++) ar[k][i].parentNode.insertBefore(ar[k][i], pre); } @@ -514,13 +516,13 @@ function walletRotate() { function makeEditable(e) { // An easter egg that makes the page editable when user click on the page and hold their mouse button for one second. // This trick allows translators and writers to preview their work. - if (!e) var e = window.event; + e = e || window.event; switch (getEvent(e, 'type')) { case 'mousedown': - if ((e.which && e.which == 3) || (e.button && e.button == 2)) return; + if ((e.which && e.which === 3) || (e.button && e.button === 2)) return; var t = getEvent(e, 'target'); while (t.parentNode) { - if (getStyle(t, 'overflow') == 'auto' || getStyle(t, 'overflow-y') == 'auto' || getStyle(t, 'overflow-x') == 'auto') return; + if (getStyle(t, 'overflow') === 'auto' || getStyle(t, 'overflow-y') === 'auto' || getStyle(t, 'overflow-x') === 'auto') return; t = t.parentNode; } addEvent(document.body, 'mouseup', makeEditable);