contribution_history.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const contributionPostsTitles = historyData.titles;
  2. const contributionPostsContents = historyData.contents;
  3. const contributionDates = historyData.dates;
  4. document.addEventListener('DOMContentLoaded', function() {
  5. if (document.querySelector('.revision-q') && contributionDates.length > 0) {
  6. let historyBlock = document.createElement('div');
  7. historyBlock.style.marginRight = "20px";
  8. let historyTitle = document.createElement('h1');
  9. historyTitle.style.marginTop = "100px";
  10. historyTitle.style.fontWeight = "lighter";
  11. historyTitle.innerText = "Minutages auxquels vous avez contribué";
  12. historyBlock.append(historyTitle);
  13. let historyTable = document.createElement('table');
  14. historyTable.style.width = "100%";
  15. historyTable.style.padding = "20px";
  16. let historyTableHead = document.createElement('thead');
  17. let tableHeadTr = document.createElement('tr');
  18. let thDate = document.createElement('th');
  19. thDate.style.paddingBottom = "10px";
  20. thDate.style.fontStyle = "italic";
  21. thDate.style.borderRight = "solid 1px white";
  22. thDate.innerText = "Date de la contribution";
  23. let thMinutage = document.createElement('th');
  24. thMinutage.style.paddingBottom = "10px";
  25. thMinutage.style.fontStyle = "italic";
  26. thMinutage.innerText = "Minutage";
  27. let thImage = document.createElement('th');
  28. thImage.style.paddingBottom = "10px";
  29. thImage.style.fontStyle = "italic";
  30. thImage.innerText = "Images";
  31. let thVoix = document.createElement('th');
  32. thVoix.style.paddingBottom = "10px";
  33. thVoix.style.fontStyle = "italic";
  34. thVoix.innerText = "Voix Off et In";
  35. let thBandeSon = document.createElement('th');
  36. thBandeSon.style.paddingBottom = "10px";
  37. thBandeSon.style.fontStyle = "italic";
  38. thBandeSon.innerText = "Bande Son";
  39. let thEcrits = document.createElement('th');
  40. thEcrits.style.paddingBottom = "10px";
  41. thEcrits.style.fontStyle = "italic";
  42. thEcrits.innerText = "Écrits";
  43. tableHeadTr.append(thDate);
  44. tableHeadTr.append(thMinutage);
  45. tableHeadTr.append(thImage);
  46. tableHeadTr.append(thVoix);
  47. tableHeadTr.append(thBandeSon);
  48. tableHeadTr.append(thEcrits);
  49. historyTableHead.append(tableHeadTr);
  50. historyTable.append(historyTableHead);
  51. let tableBody = document.createElement('tbody');
  52. for (let i = 0; i < contributionPostsTitles.length; i++) {
  53. let tableRow = document.createElement('tr');
  54. let caseDate = document.createElement('th');
  55. caseDate.style.borderRight = "solid 1px white";
  56. for (let date of contributionDates) {
  57. if (date[0] === contributionPostsTitles[i]) {
  58. let thisDate = date[1];
  59. let time = thisDate.split(' ')[1];
  60. thisDate = thisDate.split(' ')[0].split('-');
  61. thisDate = `${thisDate[2]}/${thisDate[1]}/${thisDate[0]}`;
  62. caseDate.innerHTML += `<p>${thisDate} ${time}</p>`;
  63. }
  64. }
  65. tableRow.append(caseDate);
  66. let caseMinutage = document.createElement('th');
  67. caseMinutage.innerText = contributionPostsTitles[i];
  68. caseMinutage.style.paddingTop = "10px";
  69. caseMinutage.style.paddingBottom = "10px";
  70. tableRow.append(caseMinutage);
  71. let casesContents = contributionPostsContents[i].split('---');
  72. let imageTh = document.createElement('th');
  73. imageTh.innerHTML = casesContents[1].slice(0, -17);
  74. tableRow.append(imageTh);
  75. let voixTh = document.createElement('th');
  76. voixTh.innerHTML = casesContents[2].slice(0, -11);
  77. tableRow.append(voixTh);
  78. let bandeSonTh = document.createElement('th');
  79. bandeSonTh.innerHTML = casesContents[3].slice(0, -8);
  80. tableRow.append(bandeSonTh);
  81. let ecritsTh = document.createElement('th');
  82. ecritsTh.innerHTML = casesContents[4];
  83. tableRow.append(ecritsTh);
  84. tableBody.append(tableRow);
  85. }
  86. historyTable.append(tableBody);
  87. let allThs = historyTable.querySelectorAll('th');
  88. for (let th of allThs) {
  89. th.style.padding = "10px";
  90. th.style.paddingBottom = "20px";
  91. th.style.paddingTop = "20px";
  92. th.style.borderBottom = "solid 1px white";
  93. }
  94. historyBlock.append(historyTable);
  95. let wpContent = document.querySelector('#wpbody-content');
  96. wpContent.append(historyBlock);
  97. }
  98. });