File size: 1,407 Bytes
8ed13f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// init.js - Data loading functions (pure library, no auto-execution)
// Called by bootstrap.js in the proper sequence

// Load artifacts from JSON
export async function loadArtifacts() {
    try {
        const response = await fetch('/data/artifacts.json');
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        const artifacts = await response.json();
        
        // Make globally available
        window.allArtifacts = artifacts;
        
        return artifacts;
    } catch (error) {
        console.error('Failed to load artifacts:', error);
        window.allArtifacts = [];
        throw error;
    }
}

// Helper functions for accessing loaded data
export function getArtifacts() {
    return window.allArtifacts || [];
}

export function getFeaturedArtifacts() {
    const artifacts = getArtifacts();
    return artifacts
        .filter(artifact => artifact.featured === true)
        .sort((a, b) => new Date(b.date) - new Date(a.date));
}

export function getAreasData() {
    return window.areasData || {};
}

// Legacy app object for backward compatibility with existing code
export const app = {
    getArtifacts,
    getFeaturedArtifacts,
    getAreasData,
    waitForInit: () => Promise.resolve() // No-op since bootstrap handles initialization
};

// Make available globally for non-module scripts
window.app = app;