|
1 | 1 | /* eslint-disable class-methods-use-this */
|
| 2 | +import { loadPrism, highlight } from '../../utils/prism/prism.js'; |
| 3 | + |
2 | 4 | // utility functions
|
3 | 5 | function getFormData(form) {
|
4 | 6 | const data = {};
|
@@ -88,15 +90,17 @@ function calculatePastDate(days, hours, mins, now = new Date()) {
|
88 | 90 |
|
89 | 91 | // loading button management
|
90 | 92 | function showLoadingButton(button) {
|
91 |
| - const { width } = button.getBoundingClientRect(); |
| 93 | + button.disabled = true; |
| 94 | + const { width, height } = button.getBoundingClientRect(); |
92 | 95 | button.style.minWidth = `${width}px`;
|
| 96 | + button.style.minHeight = `${height}px`; |
93 | 97 | button.dataset.label = button.textContent;
|
94 | 98 | button.innerHTML = '<i class="symbol symbol-loading"></i>';
|
95 | 99 | }
|
96 | 100 |
|
97 | 101 | function resetLoadingButton(button) {
|
98 |
| - button.removeAttribute('style'); |
99 | 102 | button.textContent = button.dataset.label;
|
| 103 | + button.removeAttribute('style'); |
100 | 104 | button.disabled = false;
|
101 | 105 | }
|
102 | 106 |
|
@@ -146,18 +150,20 @@ function writeLoginMessage(owner, repo) {
|
146 | 150 | function registerAdminDetailsListener(buttons) {
|
147 | 151 | buttons.forEach((button) => {
|
148 | 152 | button.addEventListener('click', async () => {
|
| 153 | + showLoadingButton(button); |
149 | 154 | const url = new URL(button.dataset.url);
|
150 | 155 | const { createModal } = await import('../../blocks/modal/modal.js');
|
151 | 156 | if (url) {
|
152 | 157 | const res = await fetch(url);
|
153 | 158 | const jsonContent = await res.json();
|
154 | 159 | const modalContent = document.createElement('div');
|
155 |
| - modalContent.innerHTML = `<pre> |
156 |
| - ${JSON.stringify(jsonContent, null, 3)} |
157 |
| - </pre>`; |
| 160 | + modalContent.innerHTML = `<pre><code class="language-js">${JSON.stringify(jsonContent, null, 2)} |
| 161 | + </code></pre>`; |
158 | 162 | const { showModal } = await createModal(modalContent.childNodes);
|
159 | 163 | showModal();
|
| 164 | + highlight(document.querySelector('.modal')); |
160 | 165 | }
|
| 166 | + resetLoadingButton(button); |
161 | 167 | });
|
162 | 168 | });
|
163 | 169 | }
|
@@ -473,6 +479,8 @@ function registerListeners(doc) {
|
473 | 479 | } else updateTableError('Site URL', 'Enter a valid hlx/aem page or live URL to see logs.');
|
474 | 480 | });
|
475 | 481 |
|
| 482 | + TIMEFRAME_FORM.addEventListener('submit', loadPrism, { once: true }); |
| 483 | + |
476 | 484 | TIMEFRAME_FORM.addEventListener('reset', (e) => {
|
477 | 485 | e.preventDefault();
|
478 | 486 | SITE_FIELD.value = '';
|
|
0 commit comments