forked from datacamp/datacamp-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
32 lines (23 loc) · 948 Bytes
/
index.ts
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
import "./helpers/polyfill";
import "nodelist-foreach-polyfill";
import boot from "./boot";
import Hub, { Listener } from "./helpers/hub";
import "./styles/golden-layout/index.css";
export let instances: { [x: string]: Hub } = {};
function bootstrapDCLightExercises() {
// Load all exercise div's and bootstrap the DataCamp Light Angular app
const exercises = document.querySelectorAll("[data-datacamp-exercise]");
exercises.forEach((el: HTMLDivElement) => {
let hub = new Hub();
const id = boot(el, hub);
instances[id] = hub;
});
}
(global as any).bootstrapDCLightExercises = bootstrapDCLightExercises;
(global as any).initAddedDCLightExercises = bootstrapDCLightExercises;
document.addEventListener("DOMContentLoaded", bootstrapDCLightExercises);
if (document.readyState !== "loading") {
bootstrapDCLightExercises();
}
// Exports are exported in global variable 'DCL'
export const init = bootstrapDCLightExercises;