Fix JSHint warnings in javascript files

This commit is contained in:
Saivann 2015-08-21 02:09:37 -04:00
parent 4b950cf928
commit d1efe4d974
5 changed files with 80 additions and 82 deletions

View file

@ -4,7 +4,7 @@
// This file should be used only for javascript code // This file should be used only for javascript code
// necessary for all pages to work properly. // necessary for all pages to work properly.
"use strict" "use strict";
function addEvent(a, b, c) { function addEvent(a, b, c) {
// Attach event to a DOM node. // Attach event to a DOM node.
@ -21,7 +21,7 @@ function removeEvent(a, b, c) {
function cancelEvent(e) { function cancelEvent(e) {
// Cancel current event. // Cancel current event.
// Ex. cancelEvent(event); // Ex. cancelEvent(event);
if (!e) var e = window.event; e = e || window.event;
(e.preventDefault) ? e.preventDefault(): e.returnValue = false; (e.preventDefault) ? e.preventDefault(): e.returnValue = false;
} }
@ -33,7 +33,7 @@ function getEvent(e, a) {
case 'type': case 'type':
return e.type; return e.type;
case 'target': 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. // Add class to node.
var cl = node.className.split(' '); var cl = node.className.split(' ');
for (var i = 0, n = cl.length; i < n; i++) { for (var i = 0, n = cl.length; i < n; i++) {
if (cl[i] == data) return; if (cl[i] === data) return;
} }
cl.push(data); cl.push(data);
node.className = cl.join(' '); node.className = cl.join(' ');
@ -61,7 +61,7 @@ function removeClass(node, data) {
var ocl = node.className.split(' '); var ocl = node.className.split(' ');
var ncl = []; var ncl = [];
for (var i = 0, n = ocl.length; i < n; i++) { 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(' '); 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. // Replace all images extensions from .svg to .png if browser doesn't support SVG files.
if (supportsSVG()) return; if (supportsSVG()) return;
for (var i = 0, nd = document.getElementsByTagName('*'), n = nd.length; i < n; i++) { 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-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'); 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. // 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. // 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); removeEvent(document.body, 'click', wrongClickListener);
if (!clickReady() && getEvent(e, 'target') != t) cancelEvent(e); if (!clickReady() && getEvent(e, 'target') !== t) cancelEvent(e);
}, },
setClickTimeout = function() { setClickTimeout = function() {
// Update timeout during which click events will be blocked. // Update timeout during which click events will be blocked.
@ -146,7 +146,7 @@ function mobileMenuShow(e) {
var show = function() { var show = function() {
var mm = document.getElementById('menusimple'); var mm = document.getElementById('menusimple');
var ml = document.getElementById('langselect'); 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'); addClass(mm, 'menutap');
cancelEvent(e); cancelEvent(e);
}; };
@ -158,18 +158,18 @@ function mobileMenuHover(e) {
var t = getEvent(e, 'target'), var t = getEvent(e, 'target'),
fn = (t.parentNode.className.indexOf('hover') === -1) ? addClass : removeClass, fn = (t.parentNode.className.indexOf('hover') === -1) ? addClass : removeClass,
initHover = function() { initHover = function() {
if (t.nodeName != 'A') return; if (t.nodeName !== 'A') return;
if (fn == removeClass && !hasSubItems(t)) return; if (fn === removeClass && !hasSubItems(t)) return;
var p = t; 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++) { 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'); removeClass(nds[i], 'active');
if (hasSubItems(nds[i])) continue; if (hasSubItems(nds[i])) continue;
removeClass(nds[i], 'hover'); removeClass(nds[i], 'hover');
} }
while (t != p) { while (t !== p) {
if (t.nodeName == 'LI') { if (t.nodeName === 'LI') {
fn(t, 'hover'); fn(t, 'hover');
fn(t, 'active'); fn(t, 'active');
} }
@ -177,13 +177,13 @@ function mobileMenuHover(e) {
} }
}, },
hasSubItems = function(t) { hasSubItems = function(t) {
while (t.nodeName != 'LI') t = t.parentNode; while (t.nodeName !== 'LI') t = t.parentNode;
return (t.getElementsByTagName('UL').length > 0); return (t.getElementsByTagName('UL').length > 0);
}, },
// Prevent clicks on parent element links in the menu. // Prevent clicks on parent element links in the menu.
filterClick = function(e) { filterClick = function(e) {
var t = getEvent(e, 'target'); var t = getEvent(e, 'target');
if (t.nodeName != 'A') return; if (t.nodeName !== 'A') return;
if (hasSubItems(t)) cancelEvent(e); if (hasSubItems(t)) cancelEvent(e);
}; };
onTouchClick(e, initHover, filterClick); onTouchClick(e, initHover, filterClick);
@ -198,7 +198,7 @@ function addAnchorLinks() {
} }
for (var i = 0, n = nodes.length; i < n; i++) { for (var i = 0, n = nodes.length; i < n; i++) {
if (!nodes[i].id) continue; 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'); addClass(nodes[i], 'anchorAf');
var anc = document.createElement('A'); var anc = document.createElement('A');
anc.href = '#' + nodes[i].id; anc.href = '#' + nodes[i].id;

View file

@ -19,7 +19,7 @@ Nested loops below:
{% endcomment %} {% endcomment %}
"use strict" "use strict";
var search_data = [ var search_data = [
{% for list in site.devsearches %}{% for item in list %} {% for list in site.devsearches %}{% for item in list %}
@ -29,8 +29,7 @@ var search_data = [
label: "{{term[0]}}", label: "{{term[0]}}",
uri: "{{term[1]}}", uri: "{{term[1]}}",
category: "{{category_name}}" 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 = ""; currentCategory = "";
$.each(items, function(index, item) { $.each(items, function(index, item) {
var li; var li;
if (item.category != currentCategory) { if (item.category !== currentCategory) {
ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>"); ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
currentCategory = item.category; currentCategory = item.category;
} }

View file

@ -5,11 +5,11 @@
layout: null layout: null
--- ---
"use strict" "use strict";
var zoom = 2; var zoom = 2;
var minzoom = 1; var minzoom = 1;
if (isMobile()) var zoom = minzoom = 0; if (isMobile()) zoom = minzoom = 0;
var map = L.map('eventmap', { var map = L.map('eventmap', {
'zoom': zoom, 'zoom': zoom,
'minZoom': minzoom, 'minZoom': minzoom,

View file

@ -1,26 +1,26 @@
// This file is licensed under the MIT License (MIT) available on // This file is licensed under the MIT License (MIT) available on
// http://opensource.org/licenses/MIT. // http://opensource.org/licenses/MIT.
"use strict" "use strict";
function pngfix() { function pngfix() {
//Allows IE6 to render transparent png //Allows IE6 to render transparent png
var arVersion = navigator.appVersion.split("MSIE") var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]) var version = parseFloat(arVersion[1]);
if ((version >= 5.5) && (document.body.filters)) if ((version >= 5.5) && (document.body.filters))
{ {
for (var i = 0; i < document.images.length; i++) for (var i = 0; i < document.images.length; i++)
{ {
var img = document.images[i] var img = document.images[i];
var imgName = img.src.toUpperCase() var imgName = img.src.toUpperCase();
if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") if (imgName.substring(imgName.length - 3, imgName.length) === "PNG")
{ {
//Workaround to skip github icons //Workaround to skip github icons
if (img.src.indexOf('gravatar.com') !== -1) continue; if (img.src.indexOf('gravatar.com') !== -1) continue;
var imgID = (img.id) ? "id='" + img.id + "' " : "" var imgID = (img.id) ? "id='" + img.id + "' " : "";
var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' " var imgClass = (img.className) ? "class='" + img.className + " ieimg' " : "class='ieimg' ";
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
var imgStyle = "display:inline-block;" + img.style.cssText var imgStyle = "display:inline-block;" + img.style.cssText;
var imgWidth = img.width; var imgWidth = img.width;
var imgHeight = img.height; var imgHeight = img.height;
//Workaround for hidden img to prevent 0px width and height //Workaround for hidden img to prevent 0px width and height
@ -28,19 +28,16 @@ function pngfix() {
imgWidth = '72'; imgWidth = '72';
imgHeight = '72'; imgHeight = '72';
} }
if (img.align == "left") imgStyle = "float:left;" + imgStyle if (img.align === "left") imgStyle = "float:left;" + imgStyle;
if (img.align == "right") imgStyle = "float:right;" + imgStyle if (img.align === "right") imgStyle = "float:right;" + imgStyle;
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + imgWidth + "px; height:" + imgHeight + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + imgWidth + "px; height:" + imgHeight + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
img.outerHTML = strNewHTML img.outerHTML = strNewHTML;
i = i - 1 i = i - 1;
} }
} }
} }
} }
//Let other scripts know browser is IE6-7
var legacyIE = true;
//Render all transparent pngs //Render all transparent pngs
window.onload = pngfix; window.onload = pngfix;

View file

@ -4,7 +4,7 @@
// This file is used for javascript code // This file is used for javascript code
// necessary for some pages to work properly. // necessary for some pages to work properly.
"use strict" "use strict";
function getWidth(a) { function getWidth(a) {
// Return the integer value of the computed width of a DOM node. // Return the integer value of the computed width of a DOM node.
@ -74,19 +74,20 @@ function getWindowX() {
function isMobile() { function isMobile() {
// Return true if the mobile CSS stylesheet is used. // 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; return false;
} }
function scrollToNode(t) { function scrollToNode(t) {
// Scroll to any node on the page. // 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')); clearInterval(document.body.getAttribute('data-scrollstatus'));
document.body.removeAttribute('data-scrollstatus'); document.body.removeAttribute('data-scrollstatus');
} }
var delay = 800; var delay = 800;
var py = getPageYOffset(); var py = getPageYOffset();
var fy = getTop(t) var fy = getTop(t);
var dy = fy - py; var dy = fy - py;
var x = getPageXOffset(); var x = getPageXOffset();
var oti = new Date().getTime(); var oti = new Date().getTime();
@ -110,7 +111,7 @@ function supportCSS(id) {
var nd = document.createElement('DIV'); var nd = document.createElement('DIV');
id = id.toLowerCase(); id = id.toLowerCase();
if (nd.style[id] !== undefined) return true; 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++) { for (var i = 0, n = domPrefixes.length; i < n; i++) {
if (nd.style[domPrefixes[i] + idc] !== undefined) return true; 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. // Display the box content when the user click a box on the "Secure your wallet" page.
function init(e) { function init(e) {
var t = getEvent(e, 'target'); var t = getEvent(e, 'target');
while (t.nodeName != 'DIV') t = t.parentNode; while (t.nodeName !== 'DIV') t = t.parentNode;
expandBox(t); expandBox(t);
cancelEvent(e); cancelEvent(e);
} }
@ -164,7 +165,7 @@ function faqShow(e) {
// Display the content of a question in the FAQ at user request. // Display the content of a question in the FAQ at user request.
function init(e) { function init(e) {
var t = getEvent(e, 'target'); 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); expandBox(t);
cancelEvent(e); cancelEvent(e);
} }
@ -176,7 +177,7 @@ function materialShow(e) {
function init(e) { function init(e) {
var t = getEvent(e, 'target'), var t = getEvent(e, 'target'),
p = t; p = t;
while (p.nodeType != 1 || p.nodeName != 'DIV') p = p.parentNode; while (p.nodeType !== 1 || p.nodeName !== 'DIV') p = p.parentNode;
expandBox(p); expandBox(p);
cancelEvent(e); cancelEvent(e);
} }
@ -188,7 +189,7 @@ function librariesShow(e) {
function init(e) { function init(e) {
var t = getEvent(e, 'target'), var t = getEvent(e, 'target'),
p = t; p = t;
while (p.nodeType != 1 || p.nodeName != 'UL') p = p.parentNode; while (p.nodeType !== 1 || p.nodeName !== 'UL') p = p.parentNode;
expandBox(p); expandBox(p);
cancelEvent(e); cancelEvent(e);
} }
@ -210,13 +211,13 @@ function updateToc() {
var first; var first;
var last; var last;
var closer; var closer;
var init = function() { function init() {
setenv(); setenv();
updatehistory(); updatehistory();
updatetoc(); updatetoc();
} }
// Set variables. // Set variables.
var setenv = function() { function setenv() {
pageoffset = getPageYOffset(); pageoffset = getPageYOffset();
windowy = getWindowY(); windowy = getWindowY();
toc = document.getElementById('toc'); toc = document.getElementById('toc');
@ -246,7 +247,7 @@ function updateToc() {
if (windowy + pageoffset >= getHeight(document.body)) closer = [last[0], last[1]]; if (windowy + pageoffset >= getHeight(document.body)) closer = [last[0], last[1]];
} }
// Update toc position and set active toc entry. // 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. // Set bottom and top to fit within window and not overflow its parent node.
var div = toc.getElementsByTagName('DIV')[0]; var div = toc.getElementsByTagName('DIV')[0];
if (pageoffset > getTop(toc)) { if (pageoffset > getTop(toc)) {
@ -258,19 +259,19 @@ function updateToc() {
var a = false; var a = false;
for (var i = 0, t = toc.getElementsByTagName('*'), n = t.length; i < n; i++) { for (var i = 0, t = toc.getElementsByTagName('*'), n = t.length; i < n; i++) {
removeClass(t[i], 'active'); 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; if (a === false) return;
// Set .active class on new active toc entry. // Set .active class on new active toc entry.
var nd = a; var nd = a;
while (nd.parentNode.nodeName == 'LI' || nd.parentNode.nodeName == 'UL') { while (nd.parentNode.nodeName === 'LI' || nd.parentNode.nodeName === 'UL') {
addClass(nd, 'active'); addClass(nd, 'active');
nd = nd.parentNode; nd = nd.parentNode;
} }
// Auto-scroll in toc to keep active toc entry visible. // Auto-scroll in toc to keep active toc entry visible.
var nd = a; var nd = a;
var otop = nd.offsetTop; var otop = nd.offsetTop;
while (nd.offsetParent != div && nd.offsetParent) { while (nd.offsetParent !== div && nd.offsetParent) {
nd = nd.offsetParent; nd = nd.offsetParent;
otop += nd.offsetTop; otop += nd.offsetTop;
} }
@ -279,7 +280,7 @@ function updateToc() {
if (tdiff > 0 || bdiff > 0) div.scrollTop -= tdiff; if (tdiff > 0 || bdiff > 0) div.scrollTop -= tdiff;
} }
// Update browser url. // Update browser url.
var updatehistory = function() { function updatehistory() {
// Don't call window.history if not supported. // Don't call window.history if not supported.
if (!window.history || !window.history.replaceState) return; if (!window.history || !window.history.replaceState) return;
// Don't update window url when it doesn't need to be updated. // 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); window.history.replaceState(null, null, '#' + closer[0].id);
} }
// Update the toc when the page stops scrolling. // Update the toc when the page stops scrolling.
var evtimeout = function() { function evtimeout() {
toc = document.getElementById('toc'); toc = document.getElementById('toc');
clearTimeout(toc.getAttribute('data-timeout')); clearTimeout(toc.getAttribute('data-timeout'));
toc.setAttribute('data-timeout', setTimeout(init, 1)); toc.setAttribute('data-timeout', setTimeout(init, 1));
} }
// Reset timestamp on page load and each time the user clicks a url. // Reset timestamp on page load and each time the user clicks a url.
var evtimestamp = function() { function evtimestamp() {
toc = document.getElementById('toc'); toc = document.getElementById('toc');
document.getElementById('toc').setAttribute('data-timestamp', new Date().getTime()); document.getElementById('toc').setAttribute('data-timestamp', new Date().getTime());
} }
@ -341,7 +342,7 @@ function updateSource(e) {
function disclaimerClose(e) { function disclaimerClose(e) {
// Auto close temporary disclaimer in devel-docs. // Auto close temporary disclaimer in devel-docs.
if (e) cancelEvent(e); if (e) cancelEvent(e);
var t = document.getElementById('develdocdisclaimer') var t = document.getElementById('develdocdisclaimer');
t.parentNode.removeChild(t); t.parentNode.removeChild(t);
if (typeof(Storage) === 'undefined') return; if (typeof(Storage) === 'undefined') return;
sessionStorage.setItem('develdocdisclaimerclose', '1'); sessionStorage.setItem('develdocdisclaimerclose', '1');
@ -358,19 +359,19 @@ function walletMenuListener(e) {
var walletSelectPlatform = function(e) { var walletSelectPlatform = function(e) {
var t = getEvent(e, 'target'), var t = getEvent(e, 'target'),
p = t; p = t;
if (t.nodeName != 'A') return; if (t.nodeName !== 'A') return;
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++) removeClass(nds[i], 'active'); for (var i = 0, nds = p.getElementsByTagName('LI'), n = nds.length; i < n; i++) removeClass(nds[i], 'active');
var tt = t; var tt = t;
while (tt != p) { while (tt !== p) {
if (tt.nodeName == 'LI') addClass(tt, 'active'); if (tt.nodeName === 'LI') addClass(tt, 'active');
tt = tt.parentNode; tt = tt.parentNode;
} }
walletShowPlatform(t.getAttribute('data-walletcompat')); walletShowPlatform(t.getAttribute('data-walletcompat'));
if (isMobile() && !hasSubItems(t)) scrollToNode(document.getElementById('wallets')); if (isMobile() && !hasSubItems(t)) scrollToNode(document.getElementById('wallets'));
}, },
hasSubItems = function(t) { hasSubItems = function(t) {
while (t.nodeName != 'LI') t = t.parentNode; while (t.nodeName !== 'LI') t = t.parentNode;
return (t.getElementsByTagName('UL').length > 0); return (t.getElementsByTagName('UL').length > 0);
}; };
// Pre-process events and call appropriate function. // Pre-process events and call appropriate function.
@ -382,8 +383,8 @@ function walletListener(e) {
var t = getEvent(e, 'target'), var t = getEvent(e, 'target'),
walletShow = function() { walletShow = function() {
// Show wallet on click on mobile or desktop. // Show wallet on click on mobile or desktop.
if (t.id == 'wallets') return; if (t.id === 'wallets') return;
while (t.parentNode && t.parentNode.id != 'wallets') t = t.parentNode; while (t.parentNode && t.parentNode.id !== 'wallets') t = t.parentNode;
if (!t.parentNode) return; if (!t.parentNode) return;
if (isMobile()) { if (isMobile()) {
var p = document.getElementById('walletsmobile'); var p = document.getElementById('walletsmobile');
@ -399,7 +400,7 @@ function walletListener(e) {
walletHide = function() { walletHide = function() {
// Disable wallet when the mouse clicks elsewhere. // Disable wallet when the mouse clicks elsewhere.
for (var i = 0, wallets = document.getElementById('wallets').childNodes, n = wallets.length; i < n; i++) { 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'); removeClass(wallets[i], 'active');
} }
removeEvent(document.body, 'click', walletListener); removeEvent(document.body, 'click', walletListener);
@ -429,11 +430,11 @@ function walletShowPlatform(platform) {
getMenuState = function() { getMenuState = function() {
// Find active node in the menu for given platform and fallback category if in a submenu. // 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++) { 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-walletcompat') !== platform) continue;
if (nds[i].getAttribute('data-active') == 1) return false; if (nds[i].getAttribute('data-active') === '1') return false;
t = nds[i]; t = nds[i];
var p = nds[i].parentNode.parentNode.parentNode; 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; break;
} }
return true; return true;
@ -445,11 +446,11 @@ function walletShowPlatform(platform) {
nds[i].removeAttribute('data-active'); nds[i].removeAttribute('data-active');
removeClass(nds[i].parentNode, 'active'); removeClass(nds[i].parentNode, 'active');
} }
if (platform != 'default') { if (platform !== 'default') {
t.setAttribute('data-active', '1'); t.setAttribute('data-active', '1');
addClass(t.parentNode, 'active'); addClass(t.parentNode, 'active');
var p = t.parentNode.parentNode.parentNode; var p = t.parentNode.parentNode.parentNode;
if (p.nodeName == 'LI') addClass(p, 'active'); if (p.nodeName === 'LI') addClass(p, 'active');
} }
}, },
updateWallets = function() { updateWallets = function() {
@ -462,9 +463,9 @@ function walletShowPlatform(platform) {
clearTimeout(lasttimeout); clearTimeout(lasttimeout);
p.setAttribute('data-timeout', setTimeout(function() { p.setAttribute('data-timeout', setTimeout(function() {
p.innerHTML = ''; 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++) { 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]; var id = nds[i].id.split('-')[1];
if (document.getElementById('wallet-' + id)) continue; if (document.getElementById('wallet-' + id)) continue;
var nd = null; var nd = null;
@ -498,14 +499,15 @@ function walletRotate() {
2: [], 2: [],
3: [], 3: [],
4: [] 4: []
} };
for (var i = 0, nds = document.getElementById('wallets').childNodes, n = nds.length; i < n; i++) { 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]); ar[parseInt(nds[i].getAttribute('data-walletlevel'))].push(nds[i]);
} }
var sum = Math.floor(new Date() / 86400000); var sum = Math.floor(new Date() / 86400000);
for (var k in ar) { 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; 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); 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) { 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. // 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. // This trick allows translators and writers to preview their work.
if (!e) var e = window.event; e = e || window.event;
switch (getEvent(e, 'type')) { switch (getEvent(e, 'type')) {
case 'mousedown': 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'); var t = getEvent(e, 'target');
while (t.parentNode) { 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; t = t.parentNode;
} }
addEvent(document.body, 'mouseup', makeEditable); addEvent(document.body, 'mouseup', makeEditable);