Skip to content

Commit 143af7a

Browse files
committedSep 5, 2024·
wip read annoations from file
1 parent 219619a commit 143af7a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
 
File renamed without changes.

‎html/main.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function highlightSelectionAndShowModal() {
1+
function fetchSpanIds() {
22
const selection = window.getSelection();
33
if (!selection.rangeCount) return; // No selection, so exit
44

@@ -19,7 +19,7 @@ function highlightSelectionAndShowModal() {
1919
}
2020
});
2121
startId = selectedSpanIds[0];
22-
endId =selectedSpanIds[selectedSpanIds.length - 1]
22+
endId = selectedSpanIds[selectedSpanIds.length - 1]
2323

2424
// If startId and endId are set, construct the URL and open the modal
2525
if (startId && endId) {
@@ -40,13 +40,20 @@ function highlightSelectionAndShowModal() {
4040
}
4141

4242
// Example: bind this function to mouseup event to trigger on text selection
43-
document.addEventListener('mouseup', highlightSelectionAndShowModal);
43+
document.addEventListener('mouseup', fetchSpanIds);
4444

4545
function highlightBetweenIdsFromUrl() {
4646
// Parse the URL parameters
4747
const urlParams = new URLSearchParams(window.location.search);
4848
const startId = urlParams.get('start-id');
4949
const endId = urlParams.get('end-id');
50+
const annotationSource = urlParams('annotations')
51+
if (annotationSource) {
52+
fetch(annotationSource)
53+
.then((res) => {
54+
console.log(res)
55+
})
56+
}
5057

5158
// If startId or endId is missing, stop
5259
if (!startId || !endId) {
@@ -92,8 +99,8 @@ function highlightBetweenIdsFromUrl() {
9299

93100
// Move to the next node (including text nodes, elements, etc.)
94101
currentElement = newEl.nextSibling;
95-
96-
102+
103+
97104
}
98105
}
99106

0 commit comments

Comments
 (0)
Please sign in to comment.