Pleasing eslint & fixing run.sh

This commit is contained in:
Lucas Cimon 2019-02-13 20:13:31 +01:00
parent 4c24a01c60
commit fef873996f
No known key found for this signature in database
GPG Key ID: 08DA831E717571EE
4 changed files with 25 additions and 19 deletions

View File

@ -2,6 +2,7 @@
"extends": ["strict"],
"globals": {
"document": false,
"langs": true,
"window": false,
"$": false
},

2
run.sh
View File

@ -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 () {

View File

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

View File

@ -266,7 +266,7 @@
</div>
</aside>
<script src="{{SITEURL}}/theme/bundle-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-efddc02.js"></script>
<script src="{{SITEURL}}/theme/bundle-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-12d0265.js"></script>
{% include 'disqus_count.html' %}
{% include 'analytics.html' %}