Renommage bundle JS

This commit is contained in:
Lucas Cimon
2019-02-13 21:02:26 +01:00
parent fef873996f
commit 8e23860b4f
5 changed files with 54 additions and 46 deletions

View File

@@ -21,13 +21,15 @@ if(e=u.split("-"),h=d[u]?d[u]:d["bottom-left"],this.justified&&this.justified.le
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;
}
@@ -97,18 +99,21 @@ if(e=u.split("-"),h=d[u]?d[u]:d["bottom-left"],this.justified&&this.justified.le
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

@@ -267,13 +267,15 @@ $(document).ready(() => {
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;
}
@@ -343,18 +345,21 @@ $(document).ready(() => {
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);
});
}
}
}());