| |
| async function renderJSON(filePath, elementId) { |
| try { |
| const response = await fetch(filePath); |
| if (!response.ok) { |
| throw new Error(`HTTP error! status: ${response.status}`); |
| } |
| const data = await response.json(); |
|
|
| |
| |
| document.querySelector(`#${elementId} pre`).textContent = JSON.stringify(data, null, 4); |
| } catch (error) { |
| console.error(`Could not load ${filePath}:`, error); |
| document.querySelector(`#${elementId} pre`).textContent = `Error loading data.`; |
| } |
| } |
|
|
| async function render_text(filePath, elementId) { |
| try { |
| const response = await fetch(filePath); |
| if (!response.ok) { |
| throw new Error(`HTTP error! status: ${response.status}`); |
| } |
| const text = await response.text(); |
| document.querySelector(`#${elementId} pre`).textContent = text; |
| } catch (error) { |
| console.error(`Could not load ${filePath}:`, error); |
| document.querySelector(`#${elementId} pre`).textContent = `Error loading data.`; |
| } |
| } |
|
|
| |
| document.addEventListener("DOMContentLoaded", e => { |
| renderJSON('./state.json', 'state'); |
| renderJSON('./identity.json', 'identity'); |
| render_text("./tables.sql", "sql") |
| render_text("concept.txt", 'concept') |
| render_text('concept.py', 'python') |
| }) |