Merge branch 'jshint'

This commit is contained in:
Saivann 2015-08-22 08:47:41 -04:00
commit a83ba325f9
No known key found for this signature in database
GPG Key ID: 5780F5D31B5577B0
18 changed files with 226 additions and 95 deletions

100
.jshintrc Normal file
View File

@ -0,0 +1,100 @@
{
// JSHint Configuration File
// See http://jshint.com/docs/ for more details
"maxerr" : 200,
//Enforcing
"bitwise" : true,
"camelcase" : false,
"curly" : false,
"eqeqeq" : true,
"forin" : true,
"freeze" : true,
"immed" : false,
"indent" : 4,
"latedef" : false,
"newcap" : false,
"noarg" : true,
"noempty" : true,
"nonbsp" : true,
"nonew" : false,
"plusplus" : false,
"quotmark" : false,
"undef" : true,
"unused" : false,
"strict" : true,
"maxparams" : false,
"maxdepth" : false,
"maxstatements" : false,
"maxcomplexity" : false,
"maxlen" : false,
//Relaxing
"asi" : false,
"boss" : false,
"debug" : false,
"eqnull" : false,
"es5" : false,
"esnext" : false,
"moz" : false,
"evil" : false,
"expr" : true,
"funcscope" : false,
"globalstrict" : true,
"iterator" : false,
"lastsemic" : false,
"laxbreak" : false,
"laxcomma" : false,
"loopfunc" : false,
"multistr" : false,
"noyield" : false,
"notypeof" : false,
"proto" : false,
"scripturl" : false,
"shadow" : true,
"sub" : false,
"supernew" : false,
"validthis" : false,
// Environments
"browser" : true,
"browserify" : false,
"couch" : false,
"devel" : true,
"dojo" : false,
"jasmine" : false,
"jquery" : true,
"mocha" : true,
"mootools" : false,
"node" : false,
"nonstandard" : false,
"phantom" : false,
"prototypejs" : false,
"qunit" : false,
"rhino" : false,
"shelljs" : false,
"typed" : false,
"worker" : false,
"wsh" : false,
"yui" : false,
// Globals
"predef" : {
"getEvent" : false,
"addClass" : false,
"getStyle" : false,
"addEvent" : false,
"cancelEvent" : false,
"removeClass" : false,
"removeEvent" : false,
"onTouchClick" : false,
"isMobile" : false,
"L" : false // leaflet library
}
}

View File

@ -22,6 +22,7 @@ group :development do
gem 'kramdown', '~>1.6.0'
gem 'RedCloth'
gem 'therubyracer' # required by less
gem 'jshintrb', '~>0.3.0'
end
## Not used on build server. Only used by developers and Travis CI, so

View File

@ -12,6 +12,7 @@ GEM
commonjs (0.2.7)
ethon (0.7.3)
ffi (>= 1.3.0)
execjs (2.6.0)
fast-stemmer (1.0.2)
ffi (1.9.3)
ffi-icu (0.1.2)
@ -35,6 +36,10 @@ GEM
pygments.rb (~> 0.5.0)
redcarpet (~> 2.3.0)
safe_yaml (~> 0.9.7)
jshintrb (0.3.0)
execjs
multi_json (>= 1.3)
rake
json (1.8.1)
kramdown (1.6.0)
less (2.4.0)
@ -49,6 +54,7 @@ GEM
syntax (>= 1.0.0)
mercenary (0.3.5)
mini_portile (0.6.2)
multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
parallel (1.4.1)
@ -56,6 +62,7 @@ GEM
pygments.rb (0.5.4)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (10.4.2)
rb-fsevent (0.9.3)
rb-inotify (0.9.2)
ffi (>= 0.5.0)
@ -81,6 +88,7 @@ DEPENDENCIES
ffi-icu
html-proofer
jekyll (~> 1.3.0)
jshintrb (~> 0.3.0)
json
kramdown (~> 1.6.0)
less

View File

@ -62,7 +62,8 @@ post-build-tests-fast: check-for-build-errors ensure-each-svg-has-a-png check-fo
check-for-missing-anchors check-for-broken-markdown-reference-links \
check-for-broken-kramdown-tables check-for-duplicate-header-ids \
check-for-headers-containing-auto-link check-for-missing-subhead-links \
check-for-subheading-anchors
check-for-subheading-anchors \
check-jshint
## All pre-build tests, including those which might take multiple minutes
pre-build-tests: pre-build-tests-fast
@ -248,6 +249,9 @@ check-for-broken-bitcoin-core-download-links:
check-html-proofer:
$S bundle exec ruby _contrib/bco-htmlproof
check-jshint:
$S bundle exec ruby _contrib/jshint | eval $(ERROR_ON_OUTPUT)
check-bundle:
## Ensure all the dependencies are installed. If you build without this
## check, you'll get confusing error messages when your deps aren't up

20
_contrib/jshint Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env ruby
# This file is licensed under the MIT License (MIT) available on
# http://opensource.org/licenses/MIT.
# Print any warning from JSHint for custom javascript code.
require 'jshintrb'
if ARGV[0].nil?
path_to_check="./_site/js"
else
path_to_check=ARGV[0]
end
Dir.foreach(path_to_check) do |file|
next if !/\.js$/.match(file)
res = Jshintrb.report(File.read(path_to_check + '/' + file), :jshintrc)
print path_to_check + '/' + file + "\n" + res if res.length != 0
end

View File

@ -65,6 +65,6 @@ breadcrumbs:
{% endcapture %}
{{ markdown_content | markdownify }}{% comment %}Why is this hack necessary? I don't get why this template can't be natively rendered as markdown like the releases template.{% endcomment %}
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -96,6 +96,6 @@ breadcrumbs:
<p><a href="https://bitcoinj.github.io/#documentation">Bitcoinj Developer Documentation</a> - bitcoinj.org</p>
<p><a href="https://en.bitcoin.it/wiki/Category:Technical">Technical Pages</a> - Wiki</p>
</div></div>
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -50,6 +50,6 @@ breadcrumbs:
<script>updateToc();</script>
<script>addAnchorLinks();</script>
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -93,6 +93,6 @@ new term][] for the glossary!</span>
{% endcapture %}
{{ markdown_content | markdownify }}
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -63,6 +63,6 @@ of the following file. -->
<script>updateToc();</script>
<script>addAnchorLinks();</script>
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -256,6 +256,6 @@ untrusted source.
<script>updateToc();</script>
<script>addAnchorLinks();</script>
<script src="/js/jquery-1.11.2.min.js"></script>
<script src="/js/jquery-ui.min.js"></script>
<script src="/js/jquery/jquery-1.11.2.min.js"></script>
<script src="/js/jquery/jquery-ui.min.js"></script>
<script src="/js/devsearch.js"></script>

View File

@ -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;

View File

@ -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("<li class='ui-autocomplete-category'>" + item.category + "</li>");
currentCategory = item.category;
}

View File

@ -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,

View File

@ -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 = "<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
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 = "<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;
i = i - 1;
}
}
}
}
//Let other scripts know browser is IE6-7
var legacyIE = true;
//Render all transparent pngs
window.onload = pngfix;

View File

@ -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);