Fix trade fair links to use bookmark keyword suffixes
This commit is contained in:
@@ -1021,53 +1021,58 @@
|
|||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTradeFairQueries(row) {
|
function buildTradeFairBaseQuery(row) {
|
||||||
const base = String(row.messe || '').trim();
|
const base = String(row.messe || '').trim();
|
||||||
const city = String(row.stadt || '').trim();
|
if (base) {
|
||||||
const topic = String(row.thema || '').split(',')[0].trim();
|
return base;
|
||||||
|
|
||||||
return [...new Set([
|
|
||||||
base,
|
|
||||||
[base, city].filter(Boolean).join(' '),
|
|
||||||
[base, topic].filter(Boolean).join(' ')
|
|
||||||
].map((entry) => entry.trim()).filter(Boolean))];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openQueryFallback(query) {
|
const fallback = [row.messe, row.stadt].map((value) => String(value || '').trim()).filter(Boolean).join(' ');
|
||||||
const trimmed = String(query || '').trim();
|
return fallback.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openBookmarkLikeFallback(baseQuery) {
|
||||||
|
const trimmed = String(baseQuery || '').trim();
|
||||||
if (!trimmed) {
|
if (!trimmed) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const suffixes = ['Gewinnspiel', 'gewinnen', 'verlosen'];
|
||||||
|
let opened = 0;
|
||||||
|
|
||||||
|
suffixes.forEach((suffix) => {
|
||||||
|
const query = `${trimmed} ${suffix}`.trim();
|
||||||
if (typeof window.buildBookmarkSearchUrl === 'function') {
|
if (typeof window.buildBookmarkSearchUrl === 'function') {
|
||||||
const built = window.buildBookmarkSearchUrl(trimmed);
|
const built = window.buildBookmarkSearchUrl(query);
|
||||||
if (built) {
|
if (built) {
|
||||||
window.open(built, '_blank', 'noopener');
|
window.open(built, '_blank', 'noopener');
|
||||||
return 1;
|
opened += 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL('https://www.facebook.com/search/posts');
|
const url = new URL('https://www.facebook.com/search/posts');
|
||||||
url.searchParams.set('q', trimmed);
|
url.searchParams.set('q', query);
|
||||||
window.open(url.toString(), '_blank', 'noopener');
|
window.open(url.toString(), '_blank', 'noopener');
|
||||||
return 1;
|
opened += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
return opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openTradeFairSearch(row) {
|
function openTradeFairSearch(row) {
|
||||||
const queries = buildTradeFairQueries(row);
|
const baseQuery = buildTradeFairBaseQuery(row);
|
||||||
if (!queries.length) {
|
if (!baseQuery) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let opened = 0;
|
let opened = 0;
|
||||||
if (typeof window.openBookmarkQueries === 'function') {
|
if (typeof window.openBookmarkQueries === 'function') {
|
||||||
opened = window.openBookmarkQueries(queries);
|
opened = window.openBookmarkQueries(baseQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opened === 0) {
|
if (opened === 0) {
|
||||||
queries.forEach((query) => {
|
opened = openBookmarkLikeFallback(baseQuery);
|
||||||
opened += openQueryFallback(query);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opened > 0) {
|
if (opened > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user