1a12fb870b
- New /developers/ page with API docs, SDKs, pricing, use cases - OpenAPI 3.0 spec for Orders, Missions, Photos, Analytics - Case study: Glasskiosken i Flatenbadet — complete ROI analysis - Updated /order/ with recurring missions and frequency dropdown
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
/**
|
|
* SMP Tag Helper
|
|
*
|
|
* Automatically converts SMP tags to glossary links
|
|
* Usage: <span data-smp="term-id">Term Name</span>
|
|
*
|
|
* This script:
|
|
* 1. Scans the page for data-smp attributes
|
|
* 2. Fetches the glossary data
|
|
* 3. Converts tags to linked terms with tooltips
|
|
*/
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
const GLOSSARY_URL = '/glossary/glossary-data.json';
|
|
let glossaryData = null;
|
|
|
|
// Load glossary data
|
|
async function loadGlossary() {
|
|
try {
|
|
const response = await fetch(GLOSSARY_URL);
|
|
if (!response.ok) throw new Error('Failed to load glossary');
|
|
glossaryData = await response.json();
|
|
processTags();
|
|
} catch (error) {
|
|
console.warn('SMP Tag Helper: Could not load glossary', error);
|
|
}
|
|
}
|
|
|
|
// Process all SMP tags
|
|
function processTags() {
|
|
if (!glossaryData) return;
|
|
|
|
const tags = document.querySelectorAll('[data-smp]');
|
|
tags.forEach(tag => {
|
|
const termId = tag.getAttribute('data-smp');
|
|
const term = glossaryData.terms.find(t => t.id === termId);
|
|
|
|
if (term) {
|
|
// Create link
|
|
const link = document.createElement('a');
|
|
link.href = '/glossary/#' + termId;
|
|
link.className = 'smp-tag';
|
|
link.innerHTML = tag.innerHTML;
|
|
link.setAttribute('data-term', termId);
|
|
|
|
// Add tooltip
|
|
link.title = term.short;
|
|
|
|
// Replace original element
|
|
tag.parentNode.replaceChild(link, tag);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Initialize
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', loadGlossary);
|
|
} else {
|
|
loadGlossary();
|
|
}
|
|
})();
|