Repository with sources and generator of https://larlet.fr/david/ https://larlet.fr/david/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Décompte

Le petit bout de code JavaScript que j’utilise pour compter le nombre de jours travaillés/facturables à partir de mon journal :

;(function displayTotalNumberOfBillableDays() {
    const details = document.querySelectorAll('details')
    Array.from(details).forEach(details => {
        const summary = details.querySelector('summary')
        const articles = details.querySelectorAll('article[data-days]')
        const daysCount = Array.from(articles)
            .map(item => parseFloat(item.getAttribute('data-days')))
            .reduce((a, b) => a + b, 0)
            .toString()
            .replace('.', ',')
        summary.innerHTML = `${summary.innerHTML} (${daysCount} jours)`
    })
})()

Cela présuppose une structure du HTML qui ressemble à :

<details>
    <summary>Janvier 2020</summary>
    <article data-days="1">
        <p>Cher journal,</p>
    </article>
</details>