aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MenuItem.mjs35
-rw-r--r--src/css/dumbymap.css49
-rw-r--r--src/dumbymap.mjs13
3 files changed, 82 insertions, 15 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs
index 5604ef1..b4d4650 100644
--- a/src/MenuItem.mjs
+++ b/src/MenuItem.mjs
@@ -171,7 +171,38 @@ export const renderResults = (dumbymap, map) =>
171 modal.closeByEscKey = false; 171 modal.closeByEscKey = false;
172 // HACK find another way to override inline style 172 // HACK find another way to override inline style
173 document.querySelector('.plainmodal-overlay-force').style.position = 173 document.querySelector('.plainmodal-overlay-force').style.position =
174 'static'; 174 'relative';
175 console.log(map.renderer.results) 175 map.renderer.results.forEach(result =>
176 printObject(
177 result,
178 dumbymap.modalContent,
179 `${result.func.name} (${result.state})`,
180 ),
181 );
176 }, 182 },
177 }); 183 });
184
185function printObject(obj, parentElement, name) {
186 const detailsEle = document.createElement('details');
187 const details = name ?? Object.values(obj)[0];
188 detailsEle.innerHTML = `<summary>${details}</summary`;
189 parentElement.appendChild(detailsEle);
190
191 detailsEle.onclick = () => {
192 if (detailsEle.children.length > 1) return;
193
194 Object.entries(obj).forEach(([key, value]) => {
195 if (typeof value === 'object') {
196 printObject(value, detailsEle, key);
197 } else {
198 let valueString =
199 typeof value === 'function'
200 ? `<pre>${value}</pre>`
201 : value ?? typeof value;
202 const propertyElement = document.createElement('p');
203 propertyElement.innerHTML = `<strong>${key}</strong>: ${valueString}`;
204 detailsEle.appendChild(propertyElement);
205 }
206 });
207 };
208}
diff --git a/src/css/dumbymap.css b/src/css/dumbymap.css
index 822353f..999dab5 100644
--- a/src/css/dumbymap.css
+++ b/src/css/dumbymap.css
@@ -659,6 +659,8 @@ root {
659.sub-menu { 659.sub-menu {
660 overflow: scroll; 660 overflow: scroll;
661 width: fit-content; 661 width: fit-content;
662 min-width: 6rem;
663 max-height: 40vh;
662 664
663 position: absolute; 665 position: absolute;
664 z-index: 100; 666 z-index: 100;
@@ -667,12 +669,53 @@ root {
667 border-radius: 6px; 669 border-radius: 6px;
668 670
669 background: white; 671 background: white;
670 min-width: 6rem;
671 max-height: 40vh;
672 672
673 .menu-item { 673 .menu-item {
674 min-width: 5em;
674 margin: 0 auto; 675 margin: 0 auto;
675 padding-inline: 0.5em; 676 padding-inline: 0.5em;
676 min-width: 5em; 677 }
678}
679
680.plainoverlay-body {
681 position: absolute;
682}
683
684.plainmodal-content {
685 width: 700px;
686 height: 80%;
687 padding: 1em;
688
689 position: absolute;
690 left: 50vw;
691 top: 50vh;
692
693 background: white;
694
695 transform: translate(-50%, -50%);
696 overflow-y: scroll;
697
698 details {
699 margin-bottom: 0.5em;
700 }
701
702 summary {
703 cursor: pointer;
704 }
705
706 details > :not(summary) {
707 padding-left: 1em;
708 }
709
710 p {
711 margin: 0.3em;
712 white-space: nowrap;
713 overflow-x: scroll;
714 }
715
716 pre {
717 padding: 0.5em;
718
719 background: #f0f0f0;
677 } 720 }
678} 721}
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs
index b9b9fa2..c7bdc92 100644
--- a/src/dumbymap.mjs
+++ b/src/dumbymap.mjs
@@ -167,6 +167,7 @@ export const generateMaps = (container, { delay, mapCallback }) => {
167 showcase, 167 showcase,
168 blocks, 168 blocks,
169 modal, 169 modal,
170 modalContent,
170 utils: { 171 utils: {
171 ...utils, 172 ...utils,
172 renderedMaps: () => 173 renderedMaps: () =>
@@ -531,19 +532,11 @@ export const generateMaps = (container, { delay, mapCallback }) => {
531 const menu = document.createElement('div'); 532 const menu = document.createElement('div');
532 menu.className = 'menu'; 533 menu.className = 'menu';
533 menu.onclick = () => (menu.style.display = 'none'); 534 menu.onclick = () => (menu.style.display = 'none');
534 new MutationObserver(() => {
535 if (menu.style.display === 'none') {
536 menu.style.cssText = '';
537 menu.replaceChildren();
538 }
539 }).observe(menu, {
540 attributes: true,
541 attributeFilter: ['style'],
542 });
543 container.appendChild(menu); 535 container.appendChild(menu);
544 536
545 // Menu Items 537 // Menu Items
546 container.oncontextmenu = e => { 538 container.oncontextmenu = e => {
539 menu.replaceChildren();
547 e.preventDefault(); 540 e.preventDefault();
548 541
549 // GeoLinks 542 // GeoLinks
@@ -558,7 +551,7 @@ export const generateMaps = (container, { delay, mapCallback }) => {
558 551
559 // Print Map Results 552 // Print Map Results
560 const map = e.target.closest('.mapclay'); 553 const map = e.target.closest('.mapclay');
561 if (map) { 554 if (map?.renderer?.results) {
562 menu.appendChild(menuItem.renderResults(dumbymap, map)); 555 menu.appendChild(menuItem.renderResults(dumbymap, map));
563 } 556 }
564 557