/**
* CRo stavka zamestnancu
*/
/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + */
const ENABLED = true; // true = ZAPNUTO, false = VYPNUTO
const PROD = true; // true = PRODUKCE, false = STAGE
/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + */
const COOKIE_PREFIX = 'stavka_closed_';
const COOKIE_MAX_AGE = PROD ? 30 * 60 : 1 * 60; // PROD = 30min, STAGE = 1min
const SITES = [
{
id: 'platito',
bodyClass: 'web-platito',
selector: 'body > header.header',
prodHosts: ['platito.rozhlas.cz'],
stageDomains: ['00000.cz'],
prodCookieDomain: 'platito.rozhlas.cz',
stageCookieDomain: '.00000.cz',
},
{
id: 'irozhlas',
bodyClass: 'web-irozhlas',
selector: 'body > header.header',
prodDomains: ['irozhlas.cz'],
stageHosts: ['irozhlas-stage.algocloud.cz'],
prodCookieDomain: '.irozhlas.cz',
stageCookieDomain: '.algocloud.cz',
},
{
id: 'mujrozhlas',
bodyClass: 'web-mujrozhlas',
selector: 'body .page > .page__main > main.main',
prodDomains: ['mujrozhlas.cz'],
stageDomains: ['mujrozhlas.cz'],
prodCookieDomain: '.mujrozhlas.cz',
stageCookieDomain: '.mujrozhlas.cz',
},
{
id: 'rozhlas',
bodyClass: 'web-rozhlas',
selector: 'body > .page',
prodDomains: ['rozhlas.cz'],
stageDomains: ['algocloud.cz'],
prodCookieDomain: '.rozhlas.cz',
stageCookieDomain: '.algocloud.cz',
},
];
function matchesDomain(hostname, domain) {
return hostname === domain || hostname.endsWith(`.${domain}`);
}
function matchesSite(hostname, site) {
const hosts = PROD ? (site.prodHosts ?? []) : (site.stageHosts ?? []);
const domains = PROD ? (site.prodDomains ?? []) : (site.stageDomains ?? []);
return (
hosts.includes(hostname) ||
domains.some(domain => matchesDomain(hostname, domain))
);
}
function getPageConfig(hostname) {
const site = SITES.find(site => matchesSite(hostname, site));
if (!site) {
return null;
}
return {
selector: site.selector,
bodyClass: site.bodyClass,
cookieId: site.id,
cookieDomain: PROD ? site.prodCookieDomain : site.stageCookieDomain,
};
}
function isClosedByCookie(cookieName) {
return document.cookie
.split('; ')
.some(cookie => cookie === `${cookieName}=1`);
}
function setClosedCookie(cookieName, cookieDomain) {
const domainPart = cookieDomain ? `; domain=${cookieDomain}` : '';
document.cookie = `${cookieName}=1; max-age=${COOKIE_MAX_AGE}; path=/${domainPart}; SameSite=Lax`;
}
document.addEventListener('DOMContentLoaded', () => {
if (!ENABLED) {
return;
}
const config = getPageConfig(window.location.hostname);
if (!config) {
return;
}
const cookieName = `${COOKIE_PREFIX}${config.cookieId}`;
if (isClosedByCookie(cookieName)) {
return;
}
document.body.classList.add(config.bodyClass);
const page = document.querySelector(config.selector);
if (!page) {
return;
}
const template = document.createElement('template');
template.innerHTML = `
`;
page.before(template.content);
const bar = document.querySelector('.b-stavka-bar');
const close = document.querySelector('.b-stavka-bar__close');
const style = document.querySelector('.b-stavka-styles');
if (bar && close) {
close.addEventListener('click', () => {
bar.remove();
style?.remove();
setClosedCookie(cookieName, config.cookieDomain);
});
}
});
Sběrný dvůr v Plzni na Borech | Foto: Julie Suchá
Sběrný dvůr v Plzni na Borech | Foto: Julie Suchá
Na začátku příštího týdne se uzavře sběrný dvůr v Plzni na Borech v ulici Edvarda Beneše. Pro návštěvníky to znamená jediné – nutnost vozit odpad jinam.
Julie Suchá
02:33
16. února 2025, 09:56
Zprávy pro Plzeňský kraj
Nejnovější informace o dění v regionu, doma, ve světě a ve sportu. Součástí jsou i dopravní zprávy.
Více z pořadu
Vybíráme z e-shopu Českého rozhlasu