From fef873996ff7ba49462e2e2ce00399af3bf954ef Mon Sep 17 00:00:00 2001 From: Lucas Cimon Date: Wed, 13 Feb 2019 20:13:31 +0100 Subject: [PATCH] Pleasing eslint & fixing run.sh --- .eslintrc | 1 + run.sh | 2 +- static/js/filter-tags.js | 39 ++++++++++++++++++++++----------------- templates/base.html | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.eslintrc b/.eslintrc index 2c3c0fd..47d4719 100755 --- a/.eslintrc +++ b/.eslintrc @@ -2,6 +2,7 @@ "extends": ["strict"], "globals": { "document": false, + "langs": true, "window": false, "$": false }, diff --git a/run.sh b/run.sh index acf8143..e67cc10 100755 --- a/run.sh +++ b/run.sh @@ -6,7 +6,7 @@ set -o pipefail -o errexit -o nounset -o xtrace install () { pip install pelican markdown beautifulsoup4 pillow - ./gen_statics_bundles.py + ./gen_statics_bundles.py || true } install_dev () { diff --git a/static/js/filter-tags.js b/static/js/filter-tags.js index 67c069b..87fd408 100644 --- a/static/js/filter-tags.js +++ b/static/js/filter-tags.js @@ -10,13 +10,15 @@ window.tagFilters = {}; function parseQuery(queryString) { - let query = {}; - (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&').forEach(pair => { - pair = pair.split('='); - let name = decodeURIComponent(pair[0]); - let values = decodeURIComponent(pair[1] || '').split(','); - if (!query[name]) { query[name] = []; } - Array.prototype.push.apply(query[name], values); + const query = {}; + (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&').forEach((pair) => { + pair = pair.split('='); + const name = decodeURIComponent(pair[0]); + const values = decodeURIComponent(pair[1] || '').split(','); + if (!query[name]) { + query[name] = []; + } + Array.prototype.push.apply(query[name], values); }); return query; } @@ -86,18 +88,21 @@ updateArticlesVisibility(); }; - // This is a bit redundant with /tag/$tag.html pages, but is slightly more powerful as it allow to combine multiple filters - let queryParams = parseQuery(window.location.search); - for (let [qpName, qpValue] of Object.entries(queryParams)) { - if (!qpValue) { continue; } + // This is a bit redundant with /tag/$tag.html pages, + // but is slightly more powerful as it allow to combine multiple filters + const queryParams = parseQuery(window.location.search); + for (const [ qpName, qpValue ] of Object.entries(queryParams)) { + if (!qpValue) { + continue; + } if (qpName === 'lang') { - let buttonElem = document.getElementById('lang-tag-filter'); - window.toggleLangTagFilter.bind(buttonElem)(qpValue[0]); + const buttonElem = document.getElementById('lang-tag-filter'); + window.toggleLangTagFilter.bind(buttonElem)(qpValue[0]); } else if (qpName === 'tags') { - qpValue.forEach(tag => { - let buttonElem = document.getElementById(tag + '-tag-filter'); - window.toggleTagFilter.bind(buttonElem)(tag); - }); + qpValue.forEach((tag) => { + const buttonElem = document.getElementById(`${ tag }-tag-filter`); + window.toggleTagFilter.bind(buttonElem)(tag); + }); } } }()); diff --git a/templates/base.html b/templates/base.html index 13b422e..5158eed 100644 --- a/templates/base.html +++ b/templates/base.html @@ -266,7 +266,7 @@ - + {% include 'disqus_count.html' %} {% include 'analytics.html' %}