window.addEventListener("load", function () {
if (no_header == "1") {
if (!document.getElementsByTagName) return;
var linkler = document.getElementsByTagName("a");
var linklerAdet = linkler.length;
for (var i = 0; i < linklerAdet; i++) {
var tekLink = linkler[i];
if (tekLink.getAttribute("href")) {
if (tekLink.href.indexOf("haberler.com") > -1) {
if (tekLink.href.indexOf("?") > -1)
tekLink.href += "&no_header=1";
else
tekLink.href += "?no_header=1";
}
}
}
}
getScript("/mstatic/assets/js/lazyload.js", "", function () { lazyload(); });
});
function slideSetToEnd(contenId) {
if (contenId > 0) {
var slide = document.querySelector('[data-imp-haberid="' + contenId + '"]');
if (slide != null) {
var currentPos = Array.prototype.indexOf.call(slide.parentNode.children, slide);
if (currentPos > 3) {
slide.remove();
var slidesDiv = document.getElementById("slides");
slidesDiv.insertBefore(slide, slidesDiv.lastChild);
var bullet = document.querySelector('[data-sid="' + currentPos + '"]');
var bullets = document.querySelectorAll('[class="bullet"]');
for (i = 0; i < bullets.length; i++) {
if (i + 1 >= currentPos)
bullets[i].setAttribute('data-sid', parseInt(bullets[i].getAttribute('data-sid')) - 1);
}
bullet.remove();
bullet.setAttribute('data-sid', 25);
var bulletsDiv = document.getElementsByClassName("bullets")[0];
bulletsDiv.appendChild(bullet);
}
}
}
}
function cookiePolicyWarning(text, linkText, linkUrl) {
var cwh = document.createElement('div');
cwh.setAttribute('style', 'font-size:12px;z-index:999999;width:100%;padding: 15px 100px 15px 15px;box-sizing:border-box;color: #000000;background-color:#FFFBD0;position: fixed;bottom: 0px;left: 0px;box-shadow:0 -5px 30px -15px rgba(152, 191, 248, 0.5);font-weight:400;');
cwh.setAttribute('id', 'cookiePolicyw');
cwh.innerHTML = text;
/*var cwh_a = document.createElement('a');
cwh_a.setAttribute('style', 'color:#404040;font-size:inherit;font-weight:800;');
cwh_a.setAttribute('href', linkUrl);
cwh_a.innerHTML = linkText;*/
var cwh_cl = document.createElement('div');
cwh_cl.setAttribute('style', 'position:absolute;right: 20px;top:50%;width:26px;height:26px;margin-top:-13px;box-sizing:border-box;border-radius:13px;cursor:pointer;font-size:14px;background-color:#ff0000;line-height:26px;text-align:center;font-family:monospace;color:#fff;');
cwh_cl.setAttribute('onclick', 'document.getElementById("cookiePolicyw").style.display = \'none\';document.cookie = \'cookiePolicy=closed; expires=Sun, 14 Mar 2027 23:59:59 GMT; path=/; domain=haberler.com\';');
cwh_cl.innerHTML = 'X';
//cwh.appendChild(cwh_a);
cwh.appendChild(cwh_cl);
document.body.appendChild(cwh);
}
var cookiePolicyGetCookie = function (name) {
var pair = document.cookie.match(new RegExp(name + '=([^;]+)'));
return !!pair ? pair[1] : null;
};
if (cookiePolicyGetCookie('cookiePolicy') !== "closed") {
//cookiePolicyWarning('Sizlere daha iyi hizmet sunabilmek adına sitemizde çerez konumlandırmaktayız. Kişisel verileriniz, KVKK ve GDPR kapsamında toplanıp işlenir. Detaylı bilgi almak için Veri Politikamızı / Aydınlatma Metnimizi inceleyebilirsiniz. Sitemizi kullanarak, çerezleri kullanmamızı kabul etmiş olacaksınız.', '
Daha fazla bilgi için tıklayın', '/haberler/cerez-politikasi/');
}
$(document).on("click", ".hb-click-acc", function () {
var subMenu = $(this).next(".hbmLiSubScope");
subMenu.toggle();
});
$(document).on("click", ".dropScope .dropMenu", function () {
parentClick = $(this).closest(".dropScope");
$(".dropDownOpenBox", parentClick).toggleClass("active");
})
$(document).on("click", ".dropScope .menuOpen", function () {
parentClick = $(this).closest(".dropScope");
if (!$(this).hasClass("disabled")) {
$(".menuOpen", parentClick).removeClass("active");
$("option", parentClick).removeAttr("selected");
$(this).addClass("active");
thisText = $(this).text();
$("option[value=" + thisText + "]", parentClick).attr("selected", "selected");
$(".dropMenu span", parentClick).html(thisText);
$(".dropDownOpenBox", parentClick).removeClass("active");
}
})
$(document).on("keyup", ".dropScope .dropDownSearchBoxInput", function () {
thisParent = $(this).closest(".dropScope");
value = $(this).val().toLowerCase();
$(".menuOpen", thisParent).filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
$(document).on("mouseleave", ".dropScope", function () {
$(".dropDownOpenBox", this).removeClass("active");
});
$(".hbToggleScope").each(function () {
thisToggle = $(this);
checkedSwitchToggle(thisToggle);
})
$(document).on("touchstart click", ".hbToggleScope", function () {
thisToggle = $(this);
checkedSwitchToggle(thisToggle);
});
function checkedSwitchToggle(thisElement) {
if ($(".onoffswitch-checkbox", thisElement).is(":checked")) {
$(".onoffswitch-switch", thisElement).removeClass("open");
$(".onoffswitch-switch", thisElement).addClass("close");
$(".hbTVSlider, .openCloseText").removeClass("open");
$(".hbOpened").removeClass("redColor");
$(".hbClosed").addClass("redColor");
} else {
$(".onoffswitch-switch", thisElement).removeClass("close");
$(".onoffswitch-switch", thisElement).addClass("open");
$(".hbTVSlider, .openCloseText").addClass("open");
$(".hbClosed").removeClass("redColor");
$(".hbOpened").addClass("redColor");
}
}
$(document).ready(function () {
$(document).on("click", ".hbhdNavIcon", function () {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(".hbNavMenuScope").removeClass("active");
//$("body").css({ "touch-action": "auto" });
} else {
$(this).addClass("active");
$(".hbNavMenuScope").addClass("active");
//$("body").css({ "touch-action": "none" });
}
})
$(document).on("click", ".hbnmBg", function () {
$(".hbhdNavIcon").removeClass("active");
$(".hbNavMenuScope").removeClass("active");
})
$(document).on("click", ".ftClick", function () {
ftThisParent = $(this).closest(".footerAccordion");
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(ftThisParent).removeClass("active");
} else {
$(this).addClass("active");
$(ftThisParent).addClass("active");
}
})
$(document).on("click", ".hbhdSearch", function () {
if (cihaz_mobilmi || $(window).innerWidth() <= 1024) {
if ($(this).hasClass("active")) {
$(this).removeClass("active");
$(".hbGeneralSearch").removeClass("active");
} else {
$(this).addClass("active");
$(".hbGeneralSearch").addClass("active");
}
}
})
$(".hbssTexts").on("click", function () {
clickFootballResult($(this), "hbssTexts", "hbssMainTab");
})
$(".hbssLeague").on("click", function () {
clickFootballResult($(this), "hbssLeague", "hbssSlider");
})
$(".hbcftTabs").on("click", function () {
clickFinanceTabs($(this), "hbcftTabs", "hbcftChartSectionOpen");
})
function clickFinanceTabs(thisElement, clickClass, dataClass) {
dataOpen = $(thisElement).attr("dataOpen");
$("." + clickClass).removeClass("active");
$(thisElement).addClass("active");
$("." + dataClass).removeClass("active");
$("." + dataClass + "." + dataOpen).addClass("active");
}
$(".hbsftTab").on("click", function () {
clickFinanceTopTabs($(this), "hbsftTab", "hbsftTabOpen");
})
function clickFinanceTopTabs(thisElement, clickClass, dataClass) {
dataOpen = $(thisElement).attr("dataOpen");
$("." + clickClass).removeClass("active");
$(thisElement).addClass("active");
$("." + dataClass).removeClass("active");
$("." + dataClass + "." + dataOpen).addClass("active");
}
function clickFootballResult(thisElement, clickClass, dataClass) {
dataOpen = $(thisElement).attr("dataOpen");
$("." + clickClass).removeClass("active");
$(thisElement).addClass("active");
$("." + dataClass).removeClass("active");
$("." + dataClass + "." + dataOpen).addClass("active");
}
})
$(window).on("load", function () {
videoSliderRatio();
videoPageRatio();
$(".dropDownGhost").each(function () {
dropDownCreate(this);
thisParent = $(this).closest(".dropScope");
$("option", this).each(function () {
if ($(this).attr("selected")) {
$(".dropMenu span", thisParent).html($(this).text());
}
});
})
if ($(".colPage").hasClass("scrollSlide")) {
scrollPosition = ($(".scrollSlide").offset().top) - ($(window).height() / 2);
var body = $("html, body");
body.stop().animate({ scrollTop: scrollPosition }, 300, 'swing');
}
})
$(window).on("resize", function () {
videoSliderRatio();
videoPageRatio();
})
function videoSliderRatio() {
vsrWidth = parseInt($(".hbtvsSlider .swiper-slide").width());
vsrRatio = 210.6 / 375;
/*console.log(vsrWidth + "-" + vsrRatio);*/
vsrHeight = vsrWidth * vsrRatio;
/*console.log(vsrHeight);*/
$(".hbtvsSlider video").css("height", vsrHeight + "px");
}
function videoPageRatio() {
vsrWidth = parseInt($(".hbptMainImage").width());
vsrRatio = 199 / 365;
/*console.log(vsrWidth + "-" + vsrRatio);*/
vsrHeight = vsrWidth * vsrRatio;
/*console.log(vsrHeight);*/
$(".hbptMainImage video").css("height", vsrHeight + "px");
}
$(window).on("load", function () {
if (typeof Swiper != 'undefined') {
$(".vsldYzr").each(function (index, value) {
$(this).parent().addClass("vsldYzr" + index);
new Swiper(this, {
direction: 'horizontal',
slidesPerColumn: 2,
touchStartPreventDefault: false,
pagination: {
el: '.vsldYzr' + index + ' .swiper-pagination',
},
navigation: {
nextEl: '.vsldYzr' + index + ' .swiper-button-next',
prevEl: '.vsldYzr' + index + ' .swiper-button-prev',
}
});
});
$(".hbglqz").each(function (index, value) {
$(this).parent().parent().addClass("hbglqz" + index);
new Swiper(this, {
loop: true,
touchStartPreventDefault: false,
pagination: {
el: '.hbglqz' + index + ' .swiper-pagination',
clickable: true,
renderBullet: function (index, className) {
return '' + (index + 1) + '';
}
},
navigation: {
nextEl: '.hbglqz' + index + ' .swiper-button-next',
prevEl: '.hbglqz' + index + ' .swiper-button-prev',
}
});
});
}
$(".generalHeader:not(.gamegarhd)").addClass("active");
});
$(window).on("scroll", function () {
var scrollpx = (location.pathname == '/' || location.pathname.substring(location.pathname.length - 8) == '-haberi/' ? 0 : 18);
scrollTop = $(this).scrollTop();
if (scrollTop >= scrollpx) {
$(".generalHeader:not(.gamegarhd)").addClass("active");
} else {
$(".generalHeader:not(.gamegarhd)").removeClass("active");
}
if (scrollTop >= 95) {
$(".otherHeader").addClass("active");
$(".hbMain:not(.gamegarmain)").addClass("stickypadding");
} else {
$(".otherHeader").removeClass("active");
$(".hbMain:not(.gamegarmain)").removeClass("stickypadding");
}
if (scrollTop >= 148) {
$(".generalHeader.gamegarhd").addClass("active");
$(".gamegarmain").addClass("stickypadding");
} else {
$(".generalHeader.gamegarhd").removeClass("active");
$(".gamegarmain").removeClass("stickypadding");
}
});
/* anasayfa manşet slider */
//var imp_adv_list = "0";
//function manset_adv_aktivite(id, tur) {
// var req = new XMLHttpRequest();
// if (req) {
// req.open('GET', 'https://widget.yenimedya.com.tr/Service/SaveAdvImpression?advId=' + id + '&isClick=' + tur, true);
// req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-9');
// req.send();
// }
//}
//$(document).ready(function () {
// $(document).on("mousedown", "#slides a[class*='rekkklam']", function (e) {
// if (e.which === 2) {
// const adv_id = $(this).data('adv-id');
// if (adv_id) {
// manset_adv_aktivite(adv_id, true);
// }
// e.preventDefault();
// }
// });
//});
// function transitionEndEventNew() {
// const el = document.createElement('div');
// const transitions = {
// 'transition': 'transitionend',
// 'OTransition': 'otransitionend',
// 'MozTransition': 'transitionend',
// 'WebkitTransition': 'webkitTransitionEnd'
// };
// for (let i in transitions) {
// if (el.style[i] !== undefined) {
// return transitions[i];
// }
// }
// return null;
// }
// const onTransitionEnd = transitionEndEventNew();
//const slider = document.getElementById('slider'),
// sliderItems = document.getElementById('slides'),
// prev = document.getElementById('prev'),
// next = document.getElementById('next'),
// bullets = document.querySelectorAll(".bullet");
//function slide(wrapper, items, prev, next) {
// let sliIndex = 0;
// let allowShift = true;
// const threshold = 50;
// const slides = items.querySelectorAll('.slide');
// const slidesLength = slides.length;
// function lazyLoadSlide(index) {
// const slide = slides[index];
// const img = slide.querySelector('img');
// if (img && img.dataset.src) {
// img.src = img.dataset.src;
// img.removeAttribute('data-src');
// }
// }
// lazyLoadSlide(sliIndex);
// function updateBullets(index) {
// bullets.forEach((bullet, idx) => bullet.classList.toggle("active", idx === index));
// }
// function shiftSlide(direction) {
// if (allowShift) {
// allowShift = false;
// sliIndex += direction;
// // Sınır kontrolleri: İlk ve son slayt geçişlerinde bullets güncellemesi
// if (sliIndex < 0) {
// sliIndex = slidesLength - 1;
// items.style.transition = "none";
// items.style.transform = `translateX(-${sliIndex * 100}%)`;
// updateBullets(sliIndex);
// setTimeout(() => {
// items.style.transition = "transform 0.3s ease";
// allowShift = true;
// }, 20);
// } else if (sliIndex >= slidesLength) {
// sliIndex = 0;
// items.style.transition = "none";
// items.style.transform = `translateX(0)`;
// updateBullets(sliIndex);
// setTimeout(() => {
// items.style.transition = "transform 0.3s ease";
// allowShift = true;
// }, 20);
// } else {
// items.style.transition = "transform 0.3s ease";
// items.style.transform = `translateX(-${sliIndex * 100}%)`;
// updateBullets(sliIndex);
// }
// items.addEventListener('transitionend', checkIndex, { once: true });
// lazyLoadSlide(sliIndex);
// }
// }
// function checkIndex() {
// allowShift = true;
// updateBullets(sliIndex);
// lazyLoadSlide(sliIndex);
// }
// // Throttle fonksiyonu, belirli bir süre içinde yalnızca bir kez tetiklemeye izin verir
// function throttle(func, limit) {
// let lastFunc;
// let lastRan;
// return function (...args) {
// const context = this;
// if (!lastRan) {
// func.apply(context, args);
// lastRan = Date.now();
// } else {
// clearTimeout(lastFunc);
// lastFunc = setTimeout(function () {
// if (Date.now() - lastRan >= limit) {
// func.apply(context, args);
// lastRan = Date.now();
// }
// }, limit - (Date.now() - lastRan));
// }
// };
// }
// const throttledHover = throttle((idx) => {
// if (idx !== sliIndex && allowShift) {
// sliIndex = idx;
// shiftSlide(0);
// }
// }, 500); // 200ms throttle süresi
// bullets.forEach((bullet, idx) => {
// bullet.addEventListener('click', () => {
// if (idx !== sliIndex) {
// sliIndex = idx;
// shiftSlide(0);
// }
// });
// bullet.addEventListener('mouseover', () => {
// throttledHover(idx);
// });
// });
// prev.addEventListener('click', () => shiftSlide(-1));
// next.addEventListener('click', () => shiftSlide(1));
// let startPosX;
// let isDragging = false;
// function dragStart(e) {
// startPosX = e.type === "touchstart" ? e.touches[0].clientX : e.clientX;
// isDragging = true;
// }
// function dragMove(e) {
// if (!isDragging) return;
// let posX = e.type === "touchmove" ? e.touches[0].clientX : e.clientX;
// const diff = startPosX - posX;
// if (Math.abs(diff) > threshold) {
// shiftSlide(diff > 0 ? 1 : -1);
// isDragging = false;
// }
// }
// function dragEnd() {
// isDragging = false;
// }
// items.addEventListener('touchstart', dragStart);
// items.addEventListener('mousedown', dragStart);
// items.addEventListener('touchmove', dragMove);
// items.addEventListener('mousemove', dragMove);
// items.addEventListener('touchend', dragEnd);
// items.addEventListener('mouseup', dragEnd);
// items.addEventListener('mouseleave', dragEnd);
//}
//slide(slider, sliderItems, prev, next);
// NEW SLIDER //
// Reklam izlenim kaydı fonksiyonu
function manset_adv_aktivite(id, tur) {
var req = new XMLHttpRequest();
if (req) {
req.open('GET', 'https://worker.haberler.com/SaveAdvImpression?advId=' + id + '&isClick=' + tur, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=iso-8859-9');
req.send();
}
}
const sliderContainer = document.querySelector('.new3slider-container');
const slider = document.querySelector('.new3slider');
let slides = Array.from(document.querySelectorAll('.new3slide'));
let currentIndex = 1;
const visibleBullets = 25;
let isSwiping = false, startX = 0, startY = 0;
let isTransitioning = false;
slider.addEventListener('transitionend', () => {
isTransitioning = false;
if (currentIndex === slides.length - 1) {
slider.style.transition = 'none';
currentIndex = 1;
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
requestAnimationFrame(() => {
slider.offsetHeight;
slider.style.transition = 'transform 0.2s ease-out';
});
} else if (currentIndex === 0) {
slider.style.transition = 'none';
currentIndex = slides.length - 2;
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
requestAnimationFrame(() => {
slider.offsetHeight;
slider.style.transition = 'transform 0.2s ease-out';
});
}
// Transition bittiğinde veya anlık geçiş yapıldığında aktif bullet'ı güncelle
updateActiveBullet();
});
function setupSlider() {
const existingClones = slider.querySelectorAll('.new3slide.cloned');
existingClones.forEach(clone => clone.remove());
slides = Array.from(document.querySelectorAll('.new3slider > .new3slide:not(.cloned)'));
const firstSlide = slides[0].cloneNode(true);
firstSlide.classList.add('cloned');
const lastSlide = slides[slides.length - 1].cloneNode(true);
lastSlide.classList.add('cloned');
slider.appendChild(firstSlide);
slider.insertBefore(lastSlide, slides[0]);
slides = Array.from(document.querySelectorAll('.new3slide'));
slider.style.transition = 'none';
if (currentIndex === 0) {
currentIndex = slides.length - 2;
} else if (currentIndex === slides.length - 1) {
currentIndex = 1;
}
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
requestAnimationFrame(() => {
updateBullets();
updateActiveBullet();
});
const images = slider.querySelectorAll('img');
const promises = Array.from(images).map(image => new Promise(resolve => {
if (image.complete) {
resolve();
} else {
image.onload = resolve;
image.onerror = resolve;
}
}));
// promise.all başarılı olsa da olmasa da setupSlider çağrıldığında
// updateBullets ve updateActiveBullet zaten requestAnimationFrame içinde çağrıldığı için
// burada tekrar çağırmaya gerek yok.
// Promise.all(promises).then(() => { });
}
function updateBullets() {
let bulletsContainer = document.querySelector('.new3bullets');
if (!bulletsContainer) {
bulletsContainer = document.createElement('div');
bulletsContainer.className = 'new3bullets';
sliderContainer.appendChild(bulletsContainer);
}
bulletsContainer.innerHTML = '';
const realSlideCount = slides.length - 2;
const bulletCount = Math.min(visibleBullets, realSlideCount);
if (realSlideCount <= 0) {
bulletsContainer.style.display = 'none';
return;
} else {
bulletsContainer.style.display = '';
}
for (let i = 0; i < bulletCount; i++) {
const bullet = document.createElement('span');
bullet.className = 'new3bullet';
bullet.dataset.slide = i + 1;
bullet.textContent = window.innerWidth >= 768 ? i + 1 : '';
bulletsContainer.appendChild(bullet);
}
// Olay dinleyicilerini kaldırıp tekrar ekleyerek çiftlemeyi önle
bulletsContainer.removeEventListener('click', handleBulletClick);
bulletsContainer.addEventListener('click', handleBulletClick);
bulletsContainer.removeEventListener('mouseover', handleBulletMouseover);
bulletsContainer.addEventListener('mouseover', handleBulletMouseover);
bulletsContainer.removeEventListener('touchstart', handleBulletTouchstart); // Touchstart için de aynı işlemi yapalım
bulletsContainer.addEventListener('touchstart', handleBulletTouchstart, { passive: false });
updateActiveBullet();
}
function handleBulletClick(e) {
const bullet = e.target.closest('.new3bullet');
if (bullet) {
const index = parseInt(bullet.dataset.slide, 10);
moveToSlide(index);
const slideLink = slides[index]?.querySelector('a');
if (slideLink?.href) {
window.open(slideLink.href, '_blank');
}
}
}
const handleBulletMouseover = debounce((e) => {
if (window.innerWidth >= 768) {
const bullet = e.target.closest('.new3bullet');
if (bullet) {
moveToSlide(parseInt(bullet.dataset.slide, 10));
}
}
}, 100);
function handleBulletTouchstart(e) {
const bullet = e.target.closest('.new3bullet');
if (bullet) {
e.preventDefault();
e.stopPropagation();
const index = parseInt(bullet.dataset.slide, 10);
moveToSlide(index);
const slideLink = slides[index]?.querySelector('a');
if (slideLink?.href) {
window.open(slideLink.href, '_blank');
}
}
}
function updateActiveBullet() {
const bullets = document.querySelectorAll('.new3bullet');
const realSlideCount = slides.length - 2; // Gerçek slayt sayısı
let activeBulletIndex;
if (currentIndex === 0) { // Klonlanmış son slayttaysa (en sol)
activeBulletIndex = realSlideCount - 1; // Gerçek son slayt (0-indexed)
} else if (currentIndex === slides.length - 1) { // Klonlanmış ilk slayttaysa (en sağ)
activeBulletIndex = 0; // Gerçek ilk slayt (0-indexed)
} else { // Gerçek slaytlar arasındaysa
activeBulletIndex = currentIndex - 1; // currentIndex - 1 zaten 0-indexed bullet indeksi
}
bullets.forEach((bullet, index) => {
if (index === activeBulletIndex) {
bullet.classList.add('active');
} else {
bullet.classList.remove('active');
}
});
}
function updateSliderPosition() {
if (isTransitioning) return;
isTransitioning = true;
sessionStorage.setItem('currentSlideIndex', currentIndex);
requestAnimationFrame(() => {
slider.style.transition = 'transform 0.2s ease-out';
slider.style.transform = `translateX(-${currentIndex * 100}%)`;
slides.forEach(slide => slide.classList.remove('active'));
if (slides[currentIndex]) slides[currentIndex].classList.add('active');
// Bu noktada updateActiveBullet'i tekrar çağırmaya gerek yok,
// çünkü transitionend içinde veya doğrudan moveToNext/Prev/Slide'dan sonra çağrılıyor.
// updateActiveBullet();
});
}
function moveToNextSlide() {
if (isTransitioning) return;
currentIndex++;
updateSliderPosition();
}
function moveToPrevSlide() {
if (isTransitioning) return;
currentIndex--;
updateSliderPosition();
}
function moveToSlide(slideIndex) {
if (isTransitioning || currentIndex === slideIndex) return;
currentIndex = slideIndex;
updateSliderPosition();
}
sliderContainer.addEventListener('touchstart', e => {
startX = e.touches[0].clientX;
startY = e.touches[0].clientY;
isSwiping = false;
}, { passive: true });
sliderContainer.addEventListener('touchmove', e => {
const diffX = startX - e.touches[0].clientX;
const diffY = startY - e.touches[0].clientY;
if (Math.abs(diffX) > Math.abs(diffY) && Math.abs(diffX) > 50) {
if (!isSwiping) {
isSwiping = true;
if (diffX > 0) {
moveToNextSlide();
} else {
moveToPrevSlide();
}
}
e.preventDefault();
}
}, { passive: false });
sliderContainer.addEventListener('touchend', () => {
isSwiping = false;
});
window.addEventListener('DOMContentLoaded', () => {
removeNew3Container();
const navType = performance.getEntriesByType("navigation")[0]?.type;
if (navType === 'back_forward') {
const savedIndex = parseInt(sessionStorage.getItem('currentSlideIndex'), 10);
if (!isNaN(savedIndex)) {
currentIndex = savedIndex;
} else {
currentIndex = 1;
}
} else {
currentIndex = 1;
sessionStorage.removeItem('currentSlideIndex');
}
setupSlider();
});
window.addEventListener('popstate', (event) => {
if (event.state && typeof event.state.slideIndex === 'number') {
currentIndex = event.state.slideIndex;
updateSliderPosition();
}
});
function removeNew3Container() {
const rekkklamLinks = document.querySelectorAll(".new3slide a[class*='rekkklam']");
rekkklamLinks.forEach(link => {
const new3container = link.querySelector(".new3container");
if (new3container) {
new3container.remove();
}
});
}
function debounce(func, delay) {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), delay);
};
}
window.addEventListener('resize', debounce(updateBullets, 200));
document.querySelector('.next').addEventListener('click', moveToNextSlide);
document.querySelector('.prev').addEventListener('click', moveToPrevSlide);
/* anasayfa manşet slider */
const loadAdJsText = function (ur, ps, ce = {}) {
var xexport = {
elm: '',
addatt: function (elm, ky) {
if (0 !== Object.keys(ky).length) for (const [k, v] of Object.entries(ky)) elm.setAttribute(k, v);
return elm;
},
capp: function (c) {
var dv = document.createElement('div');
dv.innerHTML = c;
dv = dv.firstChild;
const attrs = Object.values(dv.attributes).reduce((acc, b) => {
return { ...acc, [b.name]: b.value };
}, {});
var nv = document.createElement(dv.nodeName);
nv = xexport.addatt(nv, attrs);
nv.innerHTML = dv.innerHTML;
xexport.elm.insertAdjacentElement('afterbegin', nv);
}
}
var req = new XMLHttpRequest(); req.open('GET', ur, true);
req.onload = () => {
var cwh = document.createElement('div');
cwh = xexport.addatt(cwh, ce);
xexport.elm = cwh;
var reqText = req.responseText;
reqText = reqText.replace(/document.write/g, 'ldadMastHead.capp');
var adScript = document.createElement('script');
adScript.type = 'text/javascript';
adScript.text = reqText;
cwh.insertAdjacentElement('afterbegin', adScript);
document.getElementById(ps).insertAdjacentElement('afterbegin', cwh);
};
req.send();
return xexport;
};