-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
30 lines (26 loc) · 755 Bytes
/
Copy pathapi.js
File metadata and controls
30 lines (26 loc) · 755 Bytes
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
const Curricula = {
URL: 'https://www.fsinf.at/files/curricula/',
getIndex: async function(){
let res = await fetch(this.URL + '/index.json');
return await res.json();
},
getCurriculum: async function(code){
let res = await fetch(this.URL + code + '.json');
let curriculum = await res.json();
function linkGroup(group, curriculum){
curriculum.groups[group.name] = group;
if (group.groups)
group.groups.forEach(g => {
linkGroup(g, curriculum);
g.parent = group;
});
if (group.courses){
group.courses = group.courses.map(c => curriculum.courses[c]);
group.courses.forEach(c => {c.parent = group;});
}
}
curriculum.groups = {};
linkGroup(curriculum.group, curriculum);
return curriculum;
}
};