Skip to content

Commit

Permalink
in code/rfc cross-referenced side-by-side view, link to datatracker f…
Browse files Browse the repository at this point in the history
…or rfc's
  • Loading branch information
mjl- committed Mar 11, 2024
1 parent 4699504 commit 6c92949
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions rfc/xr.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,21 @@ let changinghash = false
function hashline(s) {
return s ? ':'+s.substring('#L'.length) : ''
}
function updateRFCLink(s) {
const t = s.split('/')
let e
if (t.length === 2 && t[0] === 'rfc' && ''+parseInt(t[1]) === t[1]) {
e = document.createElement('a')
e.setAttribute('href', 'https://datatracker.ietf.org/doc/html/rfc'+t[1])
e.setAttribute('rel', 'noopener')
} else {
e = document.createElement('span')
}
e.innerText = s
e.style.fontWeight = 'bold'
rfcfile.replaceWith(e)
rfcfile = e
}
function updateHash() {
const code = trimDotHTML(codeiframe.contentWindow.location.pathname.substring(basepath.length))+hashline(codeiframe.contentWindow.location.hash)
const rfc = trimDotHTML(rfciframe.contentWindow.location.pathname.substring(basepath.length))+hashline(rfciframe.contentWindow.location.hash)
Expand All @@ -329,7 +344,7 @@ function updateHash() {
return
}
codefile.innerText = code
rfcfile.innerText = rfc
updateRFCLink(rfc)
const nhash = '#' + code + ',' + rfc
if (location.hash === nhash || location.hash === '' && nhash === '#code,rfc') {
return
Expand Down Expand Up @@ -392,7 +407,7 @@ function updateIframes() {
}
if (rfciframe.src !== rfcsrc) {
rfciframe = replaceIframe(rfciframe, rfcsrc)
rfcfile.innerText = t[1]
updateRFCLink(t[1])
}
}
window.addEventListener('load', function() {
Expand Down

0 comments on commit 6c92949

Please sign in to comment.