Skip to content

Commit

Permalink
Merge pull request #8 from nhs-r-community/7_update_url_with_correcte…
Browse files Browse the repository at this point in the history
…d_repo_name

Update url with corrected repo name
  • Loading branch information
ThomUK authored Nov 7, 2023
2 parents c1abecd + e1f5895 commit 987273e
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 12 deletions.
110 changes: 105 additions & 5 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.335">
<meta name="generator" content="quarto-1.3.450">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand All @@ -17,7 +17,7 @@
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
</style>
Expand Down Expand Up @@ -89,7 +89,7 @@ <h2 class="anchored" data-anchor-id="related-projects">Related projects</h2>
<tr class="even">
<td>Health Inequalities Notebook</td>
<td>Health inequalities information and analytical approach sharing</td>
<td><a href="https://github.com/nhs-r-community/HIQ_QuartoBook" class="uri">https://github.com/nhs-r-community/HIQ_QuartoBook</a></td>
<td><a href="https://github.com/nhs-r-community/health-inequalities-notebook/" class="uri">https://github.com/nhs-r-community/health-inequalities-notebook/</a></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -126,9 +126,23 @@ <h2 class="anchored" data-anchor-id="related-projects">Related projects</h2>
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', function(e) {
Expand Down Expand Up @@ -193,6 +207,92 @@ <h2 class="anchored" data-anchor-id="related-projects">Related projects</h2>
return note.innerHTML;
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Health Inequalities Notebook

This project is a collection of information and knowledge related to analytical work on "Health Inequalities", as performed in the NHS and the wider UK Health and Social Care sector.
This project is a collection of information and knowledge related to analytical work on "Health Inequalities", as performed in the NHS and the wider UK Health and Social Care sector.

## Aim

Expand Down Expand Up @@ -32,9 +32,9 @@ The project is organic, and will be taken in the direction that contributors (wi

This project has a "sister" project, which is a code repository of R code and functions of interest to analysts actively working on data. It is also at an early stage, and there is an open call for contributors. Please get involved if you can. You can find links to both sister projects here:

| Name | Purpose | Link |
|--------------------------|-----------------------------------------------------------------|-----------------------------------------------------|
| msdn-collab | Health inequalities code sharing | <https://github.com/nhs-r-community/mdsn-collab> |
| Health Inequalities Notebook | Health inequalities information and analytical approach sharing | <https://github.com/nhs-r-community/health-inequalites-notebook/> |
| Name | Purpose | Link |
|-----------------|-------------------------------|-------------------------|
| msdn-collab | Health inequalities code sharing | <https://github.com/nhs-r-community/mdsn-collab> |
| Health Inequalities Notebook | Health inequalities information and analytical approach sharing | <https://github.com/nhs-r-community/health-inequalities-notebook/> |

END
4 changes: 2 additions & 2 deletions README_files/libs/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions README_files/libs/quarto-html/quarto-syntax-highlighting.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 987273e

Please sign in to comment.