-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.js
82 lines (66 loc) · 1.88 KB
/
player.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
window.fsG = window.fsG || {
inited: false,
log: (message) => console.log("[fastgenuity] " + message),
next: () => {
if (API.FrameChain.framesStatus.length == API.FrameChain.currentFrame) {
fsG.log("attemping to go to the next activity")
return window.parent.document.querySelector(".goRight").click()
}
fsG.log("attemping to go to the next frame")
API.FrameChain.nextFrame()
},
removeInvisDiv: () => {
const elem = $("#invis-o-div");
elem && elem.remove();
},
showAllQuestions: () => {
API.childWindow.document.querySelectorAll("[fstack]").forEach((elem) => {
elem.style = "";
});
},
bindToDoneButton: () => {
const elem = document.querySelector("#btnCheck")
if (elem && !elem.fsG) {
elem.onclick = () => {
API.Frame.check();
setTimeout(() => {
if (API.Frame.isComplete()) {
fsG.next()
}
}, 500);
}
elem.fsG = true;
}
},
MessageHandler: (e) => {
setTimeout(fsG.startVideoTask, 6000);
fsG.startQuestionTask();
},
startVideoTask: () => {
if (API.Video.video && !API.Video.video.fsG) {
API.Video.video.fsG = true;
fsG.log("starting video task");
API.Video.video.addEventListener("progress", () => {
fsG.log("attemping to skip on progress event");
fsG.next();
});
API.Video.video.addEventListener("ended", () => {
console.log("attemping to skip on ended event");
fsG.next();
});
}
},
startQuestionTask: () => {
fsG.log("starting question task");
fsG.removeInvisDiv();
fsG.showAllQuestions();
fsG.bindToDoneButton();
},
init: () => {
fsG.log("operating on a new staging frame");
window.parent.addEventListener("message", fsG.MessageHandler);
fsG.inited = true;
},
};
var fsG = window.fsG;
if (!fsG.inited) fsG.init();