|
@@ -67,7 +67,7 @@ if (debug) console.log('start footnotes');
|
|
let partie = 0;
|
|
let partie = 0;
|
|
let notes = document.querySelectorAll('.note');
|
|
let notes = document.querySelectorAll('.note');
|
|
let noteTitleNextEl;
|
|
let noteTitleNextEl;
|
|
- let prevNoteContent;
|
|
|
|
|
|
+ let notesContent = [];
|
|
|
|
|
|
for (let note of notes) {
|
|
for (let note of notes) {
|
|
let currentPartie = findH3InAncestorsAndSiblings(note, false);
|
|
let currentPartie = findH3InAncestorsAndSiblings(note, false);
|
|
@@ -82,31 +82,35 @@ if (debug) console.log('start footnotes');
|
|
// insert before the next partie page
|
|
// insert before the next partie page
|
|
findH3InAncestorsAndSiblings(note, true).parentNode.insertBefore(notePageTitle, findH3InAncestorsAndSiblings(note, true));
|
|
findH3InAncestorsAndSiblings(note, true).parentNode.insertBefore(notePageTitle, findH3InAncestorsAndSiblings(note, true));
|
|
noteNumber = 1;
|
|
noteNumber = 1;
|
|
|
|
+ notesContent = [];
|
|
partie++;
|
|
partie++;
|
|
notePageTitle.setAttribute('id', 'note_page_title_' + partie);
|
|
notePageTitle.setAttribute('id', 'note_page_title_' + partie);
|
|
noteTitleNextEl = document.getElementById(`note_page_title_${partie}`).nextElementSibling;
|
|
noteTitleNextEl = document.getElementById(`note_page_title_${partie}`).nextElementSibling;
|
|
let notesContentEl = document.createElement('div');
|
|
let notesContentEl = document.createElement('div');
|
|
notesContentEl.setAttribute('id', `notes_content_${partie}`);
|
|
notesContentEl.setAttribute('id', `notes_content_${partie}`);
|
|
|
|
+ notesContentEl.classList.add('note_text');
|
|
noteTitleNextEl.parentNode.insertBefore(notesContentEl, noteTitleNextEl);
|
|
noteTitleNextEl.parentNode.insertBefore(notesContentEl, noteTitleNextEl);
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (noteContent != prevNoteContent) {
|
|
|
|
|
|
+
|
|
|
|
+ if (!notesContent.includes(noteContent)) {
|
|
|
|
+ notesContent.push(noteContent);
|
|
let noteTextEl = document.createElement('p');
|
|
let noteTextEl = document.createElement('p');
|
|
noteTextEl.setAttribute('class', 'note_text');
|
|
noteTextEl.setAttribute('class', 'note_text');
|
|
- noteTextEl.innerHTML = '<span class="note_texte_number">' + noteNumber + '</span><span> ' + noteContent + '</span>';
|
|
|
|
|
|
+ noteTextEl.innerHTML = `<p class="note_content_${ notesContent.length }"><span class="note_texte_number">` + noteNumber + '</span><span> ' + noteContent + '</span></p>';
|
|
let notesContentEl = document.getElementById(`notes_content_${partie}`);
|
|
let notesContentEl = document.getElementById(`notes_content_${partie}`);
|
|
notesContentEl.append(noteTextEl);
|
|
notesContentEl.append(noteTextEl);
|
|
} else {
|
|
} else {
|
|
- // si les notes qui se suivent ont le même contenu
|
|
|
|
- let notesContentEl = document.getElementById(`notes_content_${partie}`);
|
|
|
|
- let lastSpan = notesContentEl.querySelector('p:last-of-type span:last-of-type');
|
|
|
|
- let numberToAdd = document.createElement('span');
|
|
|
|
- numberToAdd.setAttribute('class', 'note_texte_number');
|
|
|
|
- numberToAdd.innerText = `, ${noteNumber}`;
|
|
|
|
- notesContentEl.querySelector('p:last-of-type').insertBefore(numberToAdd, lastSpan);
|
|
|
|
|
|
+ let notesPageEl = document.querySelector(`#notes_content_${partie}`);
|
|
|
|
+ let noteContentEl = notesPageEl.querySelector(`.note_content_${notesContent.indexOf(noteContent) + 1}`);
|
|
|
|
+ console.log(noteContentEl);
|
|
|
|
+ let spanToAdd = document.createElement('span');
|
|
|
|
+ spanToAdd.classList.add('note_texte_number');
|
|
|
|
+ spanToAdd.innerText = `, ${ noteNumber }`;
|
|
|
|
+ let lastSpan = noteContentEl.lastElementChild.previousElementSibling;
|
|
|
|
+ console.log(lastSpan, spanToAdd, noteContent);
|
|
|
|
+ lastSpan.append(spanToAdd);
|
|
}
|
|
}
|
|
-
|
|
|
|
- prevNoteContent = noteContent;
|
|
|
|
|
|
+
|
|
prevPartie = currentPartie;
|
|
prevPartie = currentPartie;
|
|
|
|
|
|
if (isImgNote(note)) {
|
|
if (isImgNote(note)) {
|