function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
$(document).ready(function () {
function changeCategoryName($activeCategory) {
var $categoryName = $('.card-tabs .card-header h2');
var activeCategoryText = $activeCategory.text();
$categoryName.text(activeCategoryText);
}
// $('.card-tabs .nav-link').on('click', function(){
// changeCategoryName($(this));
// });
// changeCategoryName($('.card-tabs .nav-link.active'));
$("#navbarCollapse a+ul").each(function () {
var $ul = $(this);
var $a = $ul.prev();
var $button = $('');
$a.after($button);
$button.on("click", function () {
if ($ul.is(':visible')) {
$button.removeClass("dropped");
$ul.fadeOut();
} else {
$button.addClass("dropped");
$ul.fadeIn("slow");
}
return false;
});
})
$(".articles-content .yt-popup").each(function (i, item) {
var $popup = $(this);
var $iframe = $popup.find("iframe");
if (!$iframe.length) {
console.log("Brak iframe");
return true;
}
var id = "player-" + i;
$iframe.attr("id", id);
var src = $iframe.attr("src");
if (src == undefined) {
console.log("Brak src dla", $iframe);
return true;
}
if (src.indexOf("enablejsapi=1") < 0) {
if (src.indexOf("?") > 0) {
src += "&";
} else {
src += "?";
}
src += "enablejsapi=1";
$iframe.attr("src", src);
}
$iframe.wrap('
');
var $wrap = $iframe.parent();
var $close = $('');
$close.off("click").on("click", function () {
if (players[id] && typeof players[id].stopVideo === 'function') {
players[id].stopVideo();
} else {
players[id].g.contentWindow.postMessage(JSON.stringify({
"event": "command",
"func": "stopVideo",
"args": ""
}), "*");
}
return false;
});
$popup.off("click").on("click", function () {
if (players[id] && typeof players[id].stopVideo === 'function') {
players[id].stopVideo();
} else {
players[id].g.contentWindow.postMessage(JSON.stringify({
"event": "command",
"func": "stopVideo",
"args": ""
}), "*");
}
return false;
});
$wrap.append($close);
});
$(".articles-content iframe").each(function () {
$(this).data('yt-events', {
// 'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
});
});
function onPlayerStateChange(event) {
console.log('--------------------onPlayerStateChange');
var $popup = $(event.target.g).parents('.yt-popup');
var playerStatus = event.data;
if (playerStatus == -1) {
$popup.removeClass("active");
} else if (playerStatus == 0) {
} else if (playerStatus == 1) {
$popup.addClass("active");
} else if (playerStatus == 2) {
} else if (playerStatus == 3) {
} else if (playerStatus == 5) {
}
}
// $(".videos-player iframe").data('yt-events', {
// // 'onReady': onPlayerReady,
// 'onStateChange': vp_onPlayerStateChange
// });
if ($(".show-weather").length) {
function callLocalize(isEmpty, lat, long) {
if (isEmpty) {
data = {};
} else {
data = {};
data.lat = lat;
data.long = long;
}
$.ajax({
url: $(".show-weather").data("url"),
method: "POST",
dataType: "json",
async: false,
data: data,
success: function (data) {
var html = '' + data.miasto + '';
$(data.zachmurzenie.split(",")).each(function (i, v) {
html += "
"
});
html += '' + data.temperatura + '℃';
$(".show-weather").html(html);
},
error: function (xhr, status, error) {
console.log(error);
console.log("err");
}
});
}
callLocalize(true, null, null);
var position = null;
if (!navigator.geolocation) {
console.log("Geolocation is not supported by your browser");
}
if (navigator.geolocation && navigator.geolocation.getCurrentPosition) {
navigator.geolocation.getCurrentPosition(function (position_) {
position = position_;
callLocalize(false, position.coords.latitude, position.coords.longitude);
}, function () { console.log("Couldn\'t get your position!"); });
}
}
var mainTabsTimeout;
$(".main-tabs .card-header a").on("click", function () {
clearTimeout(mainTabsTimeout);
mainTabsTimeout = setTimeout(() => {
var $li = $(this).parents('li');
if ($li.next().length) {
$li = $li.next();
} else {
$li = $li.parent().children().first();
}
$li.find('a').click();
}, 30000);
});
$(".main-tabs .card-header a").first().click();
$(".twitter-embed").each(function (i, v) {
let url = $(v).data('url');
$(v).removeClass('mce-object');
$(v).css('display', 'none');
$.ajax({
url: url,
success: function (data) {
$(v).html(data.html);
let intervalHnd = setInterval(() => {
if ($(".twitter-tweet-rendered").length) {
clearInterval(intervalHnd);
$(v).fadeIn(2000);
}
}, 1000);
},
async: false
});
});
});
var tag = document.createElement('script');
tag.id = 'iframe-demo';
tag.src = 'https://www.youtube.com/iframe_api';
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var players = [];
function onYouTubeIframeAPIReady() {
setTimeout(function () {
$("iframe").each(function (i, element) {
if ($(this).data('yt-events')) {
var id;
if (!$(this).is("[id]")) {
id = "__player-" + i;
$(this).attr("id", id);
}
id = $(this).attr("id");
// Tworzymy nową instancję i zapisujemy ją w tablicy players
players[id] = new YT.Player(id, {
events: $(this).data('yt-events')
});
}
});
}, 1000);
}
var scrollTimeout;
$(window).scroll(function () {
if (clearTimeout != undefined) {
clearTimeout(scrollTimeout);
}
scrollTimeout = setTimeout(function () {
var sticky = $('header'),
scroll = $(window).scrollTop();
if (scroll >= 50) sticky.addClass('scrolled');
else sticky.removeClass('scrolled');
}, 10);
});
// TODO!!!!!
scrollTimeout = setTimeout(function () {
var w = 2;
$(".simply-scroll-list").children().each(function () {
$(this).width($(this).width() + 2);
w += $(this).width();
});
$(".simply-scroll-list").width(w);
}, 2000);
/* ---- */
document.addEventListener('DOMContentLoaded', () => {
const anchors = document.querySelectorAll('.js-sticky-widget-anchor');
if (!anchors.length) return;
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
const widget = entry.target.nextElementSibling;
if (!widget || widget.dataset.stickyDisabled === 'true') return;
if (!entry.isIntersecting) {
widget.classList.add('is-fixed');
} else {
widget.classList.remove('is-fixed');
}
});
}, {
root: null,
threshold: 0
});
anchors.forEach(anchor => {
const widget = anchor.nextElementSibling;
if (widget) {
const closeBtn = widget.querySelector('.sticky-widget-close');
if (closeBtn) {
closeBtn.addEventListener('click', (e) => {
e.stopPropagation();
// 1. Usuń przyklejenie
widget.classList.remove('is-fixed');
// 2. Oznacz widget jako trwale wyłączony
widget.dataset.stickyDisabled = 'true';
// 3. Przestań śledzić pozycję w DOM
observer.unobserve(anchor);
});
}
}
observer.observe(anchor);
});
});