-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update diary, implement backref for Web
- Loading branch information
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const citations = document.querySelectorAll('.link-reference > .link.local > a') | ||
|
||
const citation_map = {} | ||
|
||
for (const citation of citations) { | ||
const href = citation.getAttribute('href') | ||
citation_map[href] = citation_map[href] || 0 | ||
const citation_id = ++citation_map[href] | ||
citation.setAttribute('id', `ref-${href.replace('.xml', '')}-${citation_id}`) | ||
} | ||
|
||
const references = document.querySelectorAll('article footer section[data-taxon="Reference"] details summary header h1 a') | ||
|
||
for (const reference of references) { | ||
const href = reference.getAttribute('href') | ||
const citation_count = citation_map[href] | ||
for (let i = 1; i <= citation_count; i++) { | ||
// create a back reference | ||
const back_reference = document.createElement('a') | ||
back_reference.textContent = '↩' | ||
back_reference.setAttribute('href', `#ref-${href.replace('.xml', '')}-${i}`) | ||
back_reference.setAttribute('style', 'color: var(--uts-text-gentle) !important;text-decoration: none; margin-left: 0.5ex; margin-right: 0.5ex;') | ||
reference.parentElement?.parentElement?.appendChild(back_reference) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters