Team:Aachen/Template:Team:Aachen/JS/references
$(function () {
var matches = $('.container-primary').html().match(/<ref>(.*?)<\/ref>/gi); var uniqueReferences = [] // collecting unique references //Step 1 build reference list var n = 1;var referenceList = "
- ";
if (matches != null) {
matches.forEach(function (match) {
if (match in uniqueReferences == false)
{
uniqueReferences += match;
n++;
}
else
{
// do not add this reference again
}
});
uniq.forEach(function (reference) {
referenceList += "
- " + match.replace("<ref>", "").replace("</ref>", "") + " ";
});$(referenceList + "
var html = $('.container-primary').html(); //substitute original links n = 1;//reset counter matches.forEach(function (match) { html = html.replace(match, ' <a href="#References">[' + uniqueReferences.indexOf(match) + ']</a>'); n++; }); $('.container-primary').html(html); }
});