diff options
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r-- | src/dumbyUtils.mjs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 214e44f..8fe23eb 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs | |||
@@ -93,7 +93,8 @@ export function removeBlockFocus () { | |||
93 | * @param {HTMLAnchorElement} link | 93 | * @param {HTMLAnchorElement} link |
94 | * @return {HTMLElement[]} markers | 94 | * @return {HTMLElement[]} markers |
95 | */ | 95 | */ |
96 | const getMarkersFromMaps = link => { | 96 | export const getMarkersFromMaps = link => { |
97 | const params = new URLSearchParams(link.search) | ||
97 | const maps = Array.from( | 98 | const maps = Array.from( |
98 | link.closest('.Dumby') | 99 | link.closest('.Dumby') |
99 | .querySelectorAll('.mapclay[data-render="fulfilled"]'), | 100 | .querySelectorAll('.mapclay[data-render="fulfilled"]'), |
@@ -107,7 +108,7 @@ const getMarkersFromMaps = link => { | |||
107 | const marker = map.querySelector(`.marker[data-xy="${lonLat}"]`) ?? | 108 | const marker = map.querySelector(`.marker[data-xy="${lonLat}"]`) ?? |
108 | renderer.addMarker({ | 109 | renderer.addMarker({ |
109 | xy: lonLat, | 110 | xy: lonLat, |
110 | type: link.type, | 111 | type: params.get('type') ?? null, |
111 | }) | 112 | }) |
112 | marker.dataset.xy = lonLat | 113 | marker.dataset.xy = lonLat |
113 | marker.title = new URLSearchParams(link.search).get('xy') ?? lonLat | 114 | marker.title = new URLSearchParams(link.search).get('xy') ?? lonLat |
@@ -167,7 +168,6 @@ export const createGeoLink = (link) => { | |||
167 | link.classList.remove('not-geolink') | 168 | link.classList.remove('not-geolink') |
168 | // TODO refactor as data attribute | 169 | // TODO refactor as data attribute |
169 | link.targets = params.get('id')?.split(',') ?? null | 170 | link.targets = params.get('id')?.split(',') ?? null |
170 | link.type = params.get('type') ?? null | ||
171 | link.title = 'Left-Click to move Camera, Middle-Click to clean anchor' | 171 | link.title = 'Left-Click to move Camera, Middle-Click to clean anchor' |
172 | 172 | ||
173 | link.lines = [] | 173 | link.lines = [] |
@@ -385,7 +385,7 @@ export const dragForAnchor = (container, range, endOfLeaderLine) => { | |||
385 | container.classList.add('dragging-geolink') | 385 | container.classList.add('dragging-geolink') |
386 | const geoLink = document.createElement('a') | 386 | const geoLink = document.createElement('a') |
387 | geoLink.textContent = range.toString() | 387 | geoLink.textContent = range.toString() |
388 | geoLink.classList.add('with-leader-line', 'geolink', 'drag') | 388 | geoLink.classList.add('with-leader-line', 'geolink', 'drag', 'from-text') |
389 | 389 | ||
390 | // Replace current content with link | 390 | // Replace current content with link |
391 | const originContent = range.cloneContents() | 391 | const originContent = range.cloneContents() |
@@ -439,6 +439,11 @@ export const dragForAnchor = (container, range, endOfLeaderLine) => { | |||
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
442 | /** | ||
443 | * addGeoSchemeByText. | ||
444 | * | ||
445 | * @param {Node} node | ||
446 | */ | ||
442 | export const addGeoSchemeByText = async (node) => { | 447 | export const addGeoSchemeByText = async (node) => { |
443 | const digit = '[\\d\\uFF10-\\uFF19]' | 448 | const digit = '[\\d\\uFF10-\\uFF19]' |
444 | const decimal = '[.\\uFF0E]' | 449 | const decimal = '[.\\uFF0E]' |
@@ -451,7 +456,7 @@ export const addGeoSchemeByText = async (node) => { | |||
451 | if (Date.parse(match.at(0) + ' 1990')) return null | 456 | if (Date.parse(match.at(0) + ' 1990')) return null |
452 | 457 | ||
453 | const a = document.createElement('a') | 458 | const a = document.createElement('a') |
454 | a.className = 'not-geolink' | 459 | a.className = 'not-geolink from-text' |
455 | a.href = `geo:0,0?xy=${x},${y}` | 460 | a.href = `geo:0,0?xy=${x},${y}` |
456 | a.textContent = match.at(0) | 461 | a.textContent = match.at(0) |
457 | return a | 462 | return a |