MediaWiki:Gadget-GrAnnotations.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 544: | Line 544: | ||
Array.prototype.forEach.call(items, function (li) { | Array.prototype.forEach.call(items, function (li) { | ||
var numEl = li.querySelector('.gra-qe-footnote-num'); | var numEl = li.querySelector('.gra-qe-footnote-num'); | ||
var textEl = li.querySelector(' | var quoteEl = li.querySelector('.gra-qe-footnote-quote'); | ||
var textEl = li.querySelector('.gra-qe-footnote-text'); | |||
var num = numEl ? numEl.textContent.trim() : ''; | var num = numEl ? numEl.textContent.trim() : ''; | ||
// CHANGED: was showing the NUMBER as the card's primary line and the | |||
// | // footnote's own note text as secondary — nowhere did it show WHICH | ||
// | // text in the document the footnote actually belongs to, which was | ||
// | // the whole point of being able to identify one footnote from | ||
// | // another. Now shows the referenced quote as primary (matching how | ||
// | // Notes/Bookmarks already identify themselves by quote, not by an | ||
// | // arbitrary id), with the number as a small prefix and the | ||
// | // footnote's own note text as secondary. Falls back to the note | ||
// text alone if a footnote predates this change and has no quote | |||
// span at all, rather than showing nothing. | |||
var quote = quoteEl ? quoteEl.textContent : ''; | |||
var text = textEl ? textEl.textContent : (quoteEl ? '' : li.textContent); | |||
var primary = quote ? (num + ' ' + quote) : (num + ' ' + text); | |||
var id = li.getAttribute('data-gra-id') || ''; | var id = li.getAttribute('data-gra-id') || ''; | ||
html += '<div class="gra-bookmark-card gra-footnote-card" data-gra-id="'+esc(id)+'">' | html += '<div class="gra-bookmark-card gra-footnote-card" data-gra-id="'+esc(id)+'">' | ||
+ '<span class="gra-icon gra-icon-footnote" aria-hidden="true"></span>' | + '<span class="gra-icon gra-icon-footnote" aria-hidden="true"></span>' | ||
+ '<div class="gra-bookmark-info">' | + '<div class="gra-bookmark-info">' | ||
+ '<div class="gra-bookmark-name">'+esc( | + '<div class="gra-bookmark-name">'+esc(primary)+'</div>' | ||
+ '<div class="gra-bookmark-quote">'+esc(text)+'</div>' | + (quote ? '<div class="gra-bookmark-quote">'+esc(text)+'</div>' : '') | ||
+ '</div>' | + '</div>' | ||
+ '</div>'; | + '</div>'; | ||