/**
* 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);
});
}
});
Vimperk na Prachaticku | Shutterstock
Vimperk na Prachaticku | Shutterstock
Od renesančního zámku až po panelové sídliště. Mnoho historických vrstev architektury najdeme ve Vimperku na Prachaticku. Funkci městského architekta tam už bezmála šest let zastává René Dlesk, který jednou týdně dojíždí z Prahy.
Matěj Vodička
24:47
22. dubna 2025, 19:05
Dopolední host
Zajímavá témata z různých oborů, moderátor a hosté, kteří musí dát odpověď.
Více z pořadu
Vybíráme z e-shopu Českého rozhlasu