index.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <!doctype html>
  2. <html <?php language_attributes(); ?>>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <?php wp_head(); ?>
  7. </head>
  8. <body <?php body_class(); ?>>
  9. <?php wp_body_open(); ?>
  10. <?php do_action('get_header'); ?>
  11. <div id="app" class="banner bg-jlg-dark-blue text-jlg-white font-authentic flex w-full flex-col justify-center items-center">
  12. <?php echo view(app('sage.view'), app('sage.data'))->render(); ?>
  13. </div>
  14. <script>
  15. document.addEventListener('DOMContentLoaded', function () {
  16. // CLEANER LE TABLEAU
  17. let minHeadTh = document.querySelector("#main table thead tr th:first-of-type");
  18. minHeadTh.style.width = `${100 / 8}%`;
  19. let otherHeadThs = document.querySelectorAll("#main table thead tr th:not(:first-of-type)");
  20. for (let otherHeadTh of otherHeadThs) {
  21. otherHeadTh.style.width = `${100 / 8 * 1.75}%`;
  22. }
  23. let minTableTds = document.querySelectorAll("#main table tbody tr td:first-of-type");
  24. for (let minTableTd of minTableTds) {
  25. if (minTableTd.parentNode.childElementCount != 1) {
  26. minTableTd.style.width = `${100 / 8}%`;
  27. }
  28. }
  29. let otherTableTds = document.querySelectorAll("#main table tbody tr td:not(:first-of-type)");
  30. for (let otherTableTd of otherTableTds) {
  31. otherTableTd.style.width = `${100 / 8 * 1.75}%`;
  32. }
  33. // HEADER AU SCROLL
  34. let tableHead = document.querySelector("thead tr");
  35. let tHeadHeight = tableHead.offsetHeight;
  36. window.onscroll = () => {
  37. tableHead.style.minHeight = `${document.querySelector("header").offsetHeight + 72}px`;
  38. let scroll = window.pageYOffset;
  39. let headerNewHeight = tHeadHeight - scroll;
  40. tableHead.style.height = `${headerNewHeight}px`;
  41. }
  42. // italiques -> A FAIRE SUR LE CSV AVANT D'IMPORTER CA RALENTIT DE OUF LE CHARGEMENT
  43. let tbody = document.querySelectorAll('tbody');
  44. let tbodyContent = tbody[0].innerHTML;
  45. let asteriskCounter = 0;
  46. for (let i = 0; i < tbodyContent.length; i++) {
  47. if (tbodyContent[i] == "*") {
  48. if (asteriskCounter % 2 == 0) {
  49. tbodyContent = tbodyContent.substring(0, i) + '<span class="font-caslon italic">' + tbodyContent.substring(i + 1);
  50. } else {
  51. tbodyContent = tbodyContent.substring(0, i) + '</span>' + tbodyContent.substring(i + 1);
  52. }
  53. asteriskCounter++;
  54. }
  55. }
  56. tbody[0].innerHTML = tbodyContent;
  57. // titres de parties
  58. let mainpartTitless = document.querySelectorAll('.isMainPart');
  59. for (let mainpartTitles of mainpartTitless) {
  60. if (mainpartTitles.nextElementSibling.classList.contains('isSubPart')) {
  61. mainpartTitles.firstElementChild.firstElementChild.style.height = "1.5rem";
  62. mainpartTitles.firstElementChild.style.marginBottom = "-0.25rem";
  63. mainpartTitles.style.borderBottom = "0";
  64. mainpartTitles.style.paddingBottom = "0";
  65. mainpartTitles.nextElementSibling.style.paddingTop = "0";
  66. }
  67. }
  68. // couleurs titres
  69. let colors = [
  70. {'red' : 'e4000c'},
  71. {'blue1': '5dfffd'},
  72. {'blue2': '0fe5f9'},
  73. {'blue3': '11c1f8'},
  74. {'blue4': '0779f1'},
  75. {'blue5': '040bcb'},
  76. {'yellow1': 'ffe113'},
  77. {'yellow2': 'f4ff1b'},
  78. {'yellow3': 'e2ff0c'},
  79. {'yellow4': '93fe0b'},
  80. {'yellow5': '17fe0b'},
  81. {'pink1': 'e70060'},
  82. {'pink2': 'f03cf3'}
  83. ];
  84. let titles = document.querySelectorAll('.isMainPart, .isSubPart');
  85. let partTitles = [];
  86. for (let title of titles) {
  87. if (!title.nextElementSibling.classList.contains('isSubPart')) {
  88. partTitles.push(title);
  89. }
  90. }
  91. for (let i = 0; i < partTitles.length; i++) {
  92. if (partTitles[i].previousElementSibling?.classList.contains('isMainPart')) {
  93. partTitles[i].previousElementSibling.firstElementChild.firstElementChild.style.backgroundColor = "#" + Object.values(colors[i])[0];
  94. }
  95. partTitles[i].firstElementChild.firstElementChild.style.backgroundColor = "#" + Object.values(colors[i])[0];
  96. }
  97. // scroll with cursor
  98. // display parts rectangle on timeline
  99. let tlContainer, tlContainerHeight, bodyHeight;
  100. let partsHeight = [];
  101. let prevHeight = 0;
  102. let partBlockHeights = [];
  103. function getAllHeights() {
  104. tlContainer = document.querySelector('#timeline_container');
  105. tlContainerHeight = tlContainer.offsetHeight;
  106. bodyHeight = document.querySelector('tbody').offsetHeight;
  107. let lastTitle = document.querySelectorAll('.isMainPart');
  108. lastTitle = lastTitle[lastTitle.length - 1];
  109. for (let i = 0; i < partTitles.length; i++) {
  110. let elTopFromParentTop = partTitles[i].offsetTop - document.querySelector('tbody').offsetTop;
  111. let partSize = elTopFromParentTop - prevHeight;
  112. prevHeight = elTopFromParentTop;
  113. if (i != 0) {
  114. partsHeight.push(partSize);
  115. }
  116. }
  117. partsHeight.push(bodyHeight - lastTitle.offsetTop);
  118. const partsHeightSum = partsHeight.reduce((partialSum, a) => partialSum + a, 0);
  119. for (let partHeight of partsHeight) {
  120. partBlockHeights.push(partHeight / bodyHeight * tlContainerHeight);
  121. }
  122. }
  123. getAllHeights();
  124. window.addEventListener("resize", (event) => {
  125. getAllHeights();
  126. });
  127. for (let i = 0; i < partBlockHeights.length; i++) {
  128. let partDiv = document.createElement('div');
  129. partDiv.style.width = "32px";
  130. partDiv.style.height = partBlockHeights[i] + "px";
  131. partDiv.style.backgroundColor = "#" + Object.values(colors[i])[0];
  132. partDiv.style.borderBottom = "solid 1.5px #010d19";
  133. partDiv.style.opacity = "0.7";
  134. partDiv.style.transition = "opacity 0.3s ease-out";
  135. partDiv.style.cursor = "pointer";
  136. tlContainer.prepend(partDiv);
  137. console.log(tlContainer.children[0].style.opacity)
  138. tlContainer.children[0].addEventListener("mouseenter", function() {
  139. tlContainer.children[tlContainer.children.length - 1 - i].style.opacity = "1";
  140. });
  141. tlContainer.children[0].addEventListener("mouseleave", function() {
  142. tlContainer.children[tlContainer.children.length - 1 - i].style.opacity = "0.7";
  143. });
  144. }
  145. // make the cursor move on scroll
  146. let scrollValue, cursorTop;
  147. document.addEventListener("scroll", (event) => {
  148. scrollValue = window.scrollY;
  149. let diffSize = scrollValue / bodyHeight * tlContainerHeight;
  150. document.querySelector('#cursor').style.transform = `translateY(${diffSize}px)`;
  151. cursorTop = cursorTop + diffSize;
  152. });
  153. // TODO
  154. // ajouter le titre collé au curseur et le temps total en bas
  155. // drag and drop curseur
  156. // smoothscroll au clic sur une partie
  157. // détection partie à allumer
  158. }, false);
  159. </script>
  160. <?php do_action('get_footer'); ?>
  161. <?php wp_footer(); ?>
  162. </body>
  163. </html>