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.

Decompte.md 928B

hace 4 años
123456789101112131415161718192021222324252627282930
  1. ## Décompte
  2. Le petit bout de code JavaScript que j’utilise pour compter le nombre de jours travaillés/facturables à partir de mon journal :
  3. ```
  4. ;(function displayTotalNumberOfBillableDays() {
  5. const details = document.querySelectorAll('details')
  6. Array.from(details).forEach(details => {
  7. const summary = details.querySelector('summary')
  8. const articles = details.querySelectorAll('article[data-days]')
  9. const daysCount = Array.from(articles)
  10. .map(item => parseFloat(item.getAttribute('data-days')))
  11. .reduce((a, b) => a + b, 0)
  12. .toString()
  13. .replace('.', ',')
  14. summary.innerHTML = `${summary.innerHTML} (${daysCount} jours)`
  15. })
  16. })()
  17. ```
  18. Cela présuppose une structure du HTML qui ressemble à :
  19. ```
  20. <details>
  21. <summary>Janvier 2020</summary>
  22. <article data-days="1">
  23. <p>Cher journal,</p>
  24. </article>
  25. </details>
  26. ```