ménage let/const & console.log

This commit is contained in:
2026-09-05 17:53:40 +02:00
parent 8f6907d5a6
commit 58380ed71e
5 changed files with 43 additions and 119 deletions
+16 -102
View File
@@ -1,129 +1,43 @@
export async function loadEvents(){
let eventList = document.querySelectorAll('#eventSection > article');
const eventList = document.querySelectorAll('#eventSection > article');
//console.log("event list: ", eventList);
for (let event of eventList){
let title = event.querySelector('h4');
let date = event.querySelector('p.date');
let posterLink = event.querySelector('a.iconBtnStyle').href;
let posterHTML = await getPoster(posterLink);
for (const event of eventList){
const title = event.querySelector('h4');
const date = event.querySelector('p.date');
const posterLink = event.querySelector('a.iconBtnStyle').href;
const posterHTML = await getPoster(posterLink);
let poster = posterHTML.querySelector('body > article');
const poster = posterHTML.querySelector('body > article');
let posterStyle = posterHTML.querySelectorAll('head > style:not([data-import="no-import"])')
const posterStyle = posterHTML.querySelectorAll('head > style:not([data-import="no-import"])')
//console.log('entry data :', title, date, poster, posterStyle);
let selectedEntry = createEntry(title, date, poster, posterStyle)
const selectedEntry = createEntry(title, date, poster, posterStyle)
//console.log('created new details :', selectedEntry);
event.replaceChildren(selectedEntry);
}
/* let btnList = document.querySelectorAll('.eventEntry > .iconBtnStyle');
//console.log("source buttons : ", btnList)
let displayWindow = document.querySelector('#posterWindow');
let displayContainer = document.querySelector('#posterContainer');
let closeBtn = document.querySelector('#posterCloseBtn');
closeBtn.addEventListener('mousedown', () => {
displayWindow.style.visibility = 'collapse';
displayContainer.replaceChildren();
})
closeBtn.addEventListener('touchstart', () => {
displayWindow.style.visibility = 'collapse';
displayContainer.replaceChildren();
})
async function getPoster(src){
let res = await fetch(src);
if (res.ok){
let html_text = await res.text()
let html = new DOMParser().parseFromString(html_text, "text/html");
return html
} else{
console.log('error 333');
return
}
}
let eventList = [];
if( btnList.length > 0 ){
for (let btn of btnList ){
let link = btn.children[0];
link.style.pointerEvents = 'none';
//console.log(link.href);
let posterPage = await getPoster(link.href);
//console.log('selected poster: ', posterPage)
let titleData = posterPage.querySelector('title');
//console.log(titleData);
let styleList = Array.from(posterPage.querySelectorAll('head > style'));
//console.log(styleList)
styleList.splice(0,1);
//console.log(styleList)
eventList.push(
{
content: posterPage.querySelector('main'),
title: titleData.innerText,
stylesheet: styleList,
sourceBtn: btn
}
);
}
}
//console.log("event list : ", eventList);
if (eventList.length > 0){
eventList.forEach( (obj) =>{
let btn = obj.sourceBtn;
let content = obj.content;
let title = obj.title;
for (let style of obj.stylesheet){
document.head.append(style);
}
btn.addEventListener( 'click', () => {
//console.log("selection :", content)
displayWindow.style.visibility = 'visible';
let targetTitle = displayWindow.querySelector('h4');
targetTitle.innerText = title;
displayContainer.replaceChildren(content);
})
})
} */
}
async function getPoster(link){
let res = await fetch(link);
const res = await fetch(link);
if (res.ok){
let html_text = await res.text()
let html = new DOMParser().parseFromString(html_text, "text/html");
const html_text = await res.text()
const html = new DOMParser().parseFromString(html_text, "text/html");
return html
} else{
console.log('error 333');
console.log('error 333: something went wrong with this poster...');
return
}
}
function createEntry(title, date, html, style){
let newEntry = document.createElement('details');
let newSummary = document.createElement('summary');
const newEntry = document.createElement('details');
const newSummary = document.createElement('summary');
newSummary.append(title, date);
newEntry.append(newSummary);
@@ -132,7 +46,7 @@ function createEntry(title, date, html, style){
newEntry.name = "eventList"
for(let el of style){
for(const el of style){
document.head.append(el);
}