chore: Remove own debugLog

This commit is contained in:
Tibo De Peuter 2025-11-11 18:29:33 +01:00
parent 84756043be
commit 2bf10fd199
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
6 changed files with 18 additions and 41 deletions

View file

@ -647,7 +647,7 @@
// Expand details elements
for (const detail of document.querySelectorAll('details.collapsable-card')) {
detail.open = true;
debugLog(`[cv-en.html] Expanded details: ${detail.innerText}`);
console.debug(`[cv-en.html] Expanded details: ${detail.innerText}`);
}
}

View file

@ -7,11 +7,3 @@ import ('./src/i18n/translator.js');
import ('./src/components/navbar.js');
import ('./src/components/languageToggle.js');
let debug = false;
const debugLog = (message) => {
if (debug) {
console.log(message);
}
}

View file

@ -64,14 +64,14 @@ class LanguageToggle extends HTMLElement {
// Change language on selection
languageDropdown.addEventListener('change', () => {
const language = languageDropdown.value;
debugLog(`[navbar] Setting language to: ${language}`);
console.info(`[navbar] Setting language to: ${language}`);
translator.setPreferredLanguage(language);
});
languageIcon.addEventListener('click', () => languageDropdown.showPicker());
window.addEventListener(I18N_LOADED_EVENT, (event) => {
debugLog(`[language-toggle] i18nLoaded event received`);
console.log(`[language-toggle] i18nLoaded event received`);
const translations = event.detail.translations;
translator.translate(translations, shadow);

View file

@ -104,9 +104,7 @@ class MyMarquee extends HTMLElement {
let repetitions = Math.ceil(window.innerWidth / singleWidth) + 1;
this.repetitions = repetitions * 4; // Double the repetitions for a seamless effect
if (debug) {
console.log(`Single content width: ${singleWidth}, Repetitions: ${this.repetitions}`);
}
console.debug(`Single content width: ${singleWidth}, Repetitions: ${this.repetitions}`);
this.content.innerHTML = this.content.innerHTML.repeat(this.repetitions);
this.repeatedWidth = singleWidth * this.repetitions;
@ -126,10 +124,7 @@ class MyMarquee extends HTMLElement {
// Set the animation direction
console.assert(['left', 'right'].includes(this.direction))
this.content.style.animationName = `scroll-${this.direction}`;
if (debug) {
console.log(`Animation updated: Duration ${duration}ms, Direction ${this.direction}`);
}
console.debug(`Animation updated: Duration ${duration}ms, Direction ${this.direction}`);
}
handleScroll() {
@ -139,29 +134,16 @@ class MyMarquee extends HTMLElement {
// Handle scrolling to the right
if (currentScroll >= this.content.scrollWidth * 0.7) {
if (debug) {
console.log(`Jumping back by ${scrollStep}`);
ping();
}
console.debug(`Jumping back by ${scrollStep}`);
this.marquee.scrollLeft -= scrollStep;
}
// Handle scrolling to the left
if (currentScroll <= this.content.scrollWidth * 0.3) {
if (debug) {
console.log(`Jumping forward by ${scrollStep}`);
ping();
}
console.debug(`Jumping forward by ${scrollStep}`);
this.marquee.scrollLeft += scrollStep;
}
}
}
function ping() {
const ping = new Audio('../assets/sounds/cowbell.mp3');
ping.play().catch(error => {
console.error('Error playing sound:', error);
});
}
customElements.define('my-marquee', MyMarquee);

View file

@ -137,17 +137,17 @@ class NavBar extends HTMLElement {
const currentScrollY = window.scrollY;
if (currentScrollY > lastScrollY && currentScrollY > 100) {
navbar.classList.add('hidden');
debugLog('[navbar] Scrolling down - hide nav bar');
console.debug('[navbar] Scrolling down - hide nav bar');
} else {
navbar.classList.remove('hidden');
debugLog('[navbar] Scrolling up - show nav bar');
console.debug('[navbar] Scrolling up - show nav bar');
}
lastScrollY = currentScrollY;
debugLog(`[navbar] Current scrollY: ${currentScrollY}`);
console.debug(`[navbar] Current scrollY: ${currentScrollY}`);
})
window.addEventListener(I18N_LOADED_EVENT, (event) => {
debugLog(`[navbar] i18nLoaded event received`);
console.log(`[navbar] i18nLoaded event received`);
const translations = event.detail.translations;
translator.translate(translations, shadow);

View file

@ -67,9 +67,9 @@ class Translator {
*/
async load(language = null, rootElement = document) {
try {
debugLog(`Loading translations for language '${this.prefferedLanguage}' in '${rootElement}'`);
console.log(`Loading translations for language '${this.prefferedLanguage}' in '${rootElement}'`);
const i18n = await fetch(`/i18n/${this.prefferedLanguage}.json`);
debugLog(`i18n response: ${i18n.status} ${i18n.statusText}`);
console.debug(`i18n response: ${i18n.status} ${i18n.statusText}`);
const translations = await i18n.json();
this.translate(translations, rootElement);
@ -87,16 +87,19 @@ class Translator {
translateElement(element, translations) {
const keys = element.dataset.i18n.split('.');
const elementTranslations = keys.reduce((obj, key) => key in obj ? obj[key] : {}, translations);
debugLog(`Translating '${element.dataset.i18n}': '${JSON.stringify(elementTranslations)}'`);
// No translation found
if (!elementTranslations) {
if (element.innerHTML.trim() === '') {
element.innerHTML = `[i18n:${element.dataset.i18n}]`;
}
console.warn(`No translation found for key '${element.dataset.i18n}'`);
return;
}
console.debug(`Translating '${element.dataset.i18n}': '${JSON.stringify(elementTranslations)}'`);
// Simple string translation
if (typeof elementTranslations === 'string') {
element.innerHTML = elementTranslations;
@ -110,7 +113,7 @@ class Translator {
continue;
}
debugLog(`Translating attribute '${attribute}': '${value}'`);
console.debug(`Translating attribute '${attribute}': '${value}'`);
element.setAttribute(attribute, value);
}
}