summaryrefslogtreecommitdiffstats
path: root/src/js/templates.js
blob: 4b716384542caa1b51ef4c13e13a7a148a7d60f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export function load(template) {
    return new Promise(function(resolve, reject){
        var xhr = new XMLHttpRequest();

        xhr.open('GET', './templates/'+template);
    
        xhr.send();
    
        xhr.onload = function() {
            if (xhr.status != 200 && xhr.status != 0) {
                console.error('Error loading template', xhr.status, xhr.statusText);
                reject(xhr.status);
            } else {
                console.log(xhr.responseType);
                resolve(xhr.responseText);
            }
        };
    });
}