123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- console.log('salut');
- /// fusion cellules dans tableau
- /// va chercher les p avec class .rowspan pour leur attribuer l'attribut rowspan
- var cellRowspans = document.querySelectorAll('p.rowspan');
- for (let cellRowspan of cellRowspans){
- let cellRowSpanParent = cellRowspan.parentElement;
- console.log(cellRowSpanParent);
- cellRowSpanParent.setAttribute('rowspan', '4');
- }
- var displayNones = document.querySelectorAll('p.cell-display-none'); // on va chercher tous les éléments p.cell-display-none
- for (let displayNone of displayNones){ /// on déclare 1 élément dans l'array
- let displayNoneParent = displayNone.parentElement; /// on va chercher le parent de l'élément dans l'array
- displayNoneParent.classList.add('display-none'); /// on ajout la class au parent
- console.log(displayNoneParent);
- }
- /// attribution d'une class en fonction de book-depth-5
- // var depths = document.getElementsByClassName('book-depth-5');
- // console.log(depths);
- // for (let depth of depths){
- // let depthSiblingTitle = depth.previousSibling('.block-page-title-block');
- // depthSiblingTitle.classList.add('book-depth-5');
- // console.log(depthSiblingTitle);
- // }
- // const article = document.querySelector('article[class*="book-depth"]');
- // console.log(article);
- // const div = document.querySelector('#block-pagetitle-2');
- // console.log(div);
- // div.classList.add(article.classList);
- // const article = document.querySelector('article.book-depth-*');
- // console.log(article);
- // const div = document.querySelector('#block-pagetitle-2');
- // div.classList.add(article.classList);
- ///////////////////
- // document.addEventListener('DOMContentLoaded', function () {
- // // Get the depth of the page within the book (You need to replace this logic with your own)
- // var depth = 5; // For example, you can set the depth dynamically based on your criteria
- // // Select the article element
- // var article = document.querySelector('article');
- // // Remove the existing depth class (if any)
- // article.classList.remove('book-depth-4', 'book-depth-5', 'book-depth-6', 'book-depth-7', 'book-depth-8', 'book-depth-9');
- // // Add the new depth class
- // article.classList.add('book-depth-' + depth);
- // // Select the block-pagetitle-2 element
- // var blockPagetitle2 = document.getElementById('block-pagetitle-2');
- // // Remove the existing depth class (if any)
- // blockPagetitle2.classList.remove('book-depth-4', 'book-depth-5', 'book-depth-6', 'book-depth-7', 'book-depth-8', 'book-depth-9');
- // // Add the new depth class to block-pagetitle-2
- // blockPagetitle2.classList.add('book-depth-' + depth);
- // });
- ///////////////////
- document.addEventListener('DOMContentLoaded', function () {
- // Select the article element
- var article = document.querySelector('article');
- console.log(article);
- // Get the current depth class from the article
- var depthClass = getDepthClass(article);
- console.log(depthClass);
- // Apply the depth class to block-pagetitle-2
- var blockPagetitle2 = document.getElementById('block-pagetitle-2');
- blockPagetitle2.classList.add(depthClass);
- // Optional: Remove the depth class from article if needed
- article.classList.remove(depthClass);
- // Function to extract the depth class from the article
- function getDepthClass(element) {
- var classes = element.classList;
- for (var i = 0; i < classes.length; i++) {
- if (classes[i].startsWith('book-depth-')) {
- return classes[i];
- }
- }
- return '';
- }
- });
|