generated from edrys-org/module-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
82 lines (68 loc) · 2.58 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="A LiaScript module, don't forget to specify course" />
<meta name="show-in" content="*" />
<title>LiaScript</title>
<script src="https://edrys-org.github.io/edrys/module/edrys.js"></script>
<script defer src="https://edrys-org.github.io/edrys/module/vendor/alpine.min.js"></script>
<script>
function init(iframe) {
Edrys.onMessage(({
from,
subject,
body
}) => {
if (Edrys.username !== from) {
iframe.contentWindow.postMessage({
subject: subject,
body: body
}, "*")
}
})
window.addEventListener('message', function (e) {
// Get the sent data
const msg = e.data;
switch (msg.subject) {
case "init":
iframe.contentWindow.postMessage({
subject: msg.subject,
body: true
}, "*")
break
default:
// this is required in order to transmit only messages
// from LiaScript otherwise it will loop forever
if (!(msg.event && msg.event == "message"))
Edrys.sendMessage(msg.subject, msg.body)
}
});
}
</script>
</head>
<body>
<template x-if="!!edrys && !!url" x-data="{ edrys: undefined, url: undefined }" x-init="Edrys.onUpdate((e) => {
edrys = {...e}
url = `https://liascript.github.io/course/?${Edrys.liveRoom.name == 'Lobby' ? edrys.module.config.course : btoa(JSON.stringify({'backend':'edrys','course':edrys.module.config.course,'room':Edrys.liveRoom.name}))}`
})">
<iframe :src="url" frameborder="0" style="width:100%;height:100%;" onload="init(this)"
allow="camera; microphone; fullscreen; display-capture;"></iframe>
</template>
<style>
body,
html,
iframe {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
overflow: hidden;
}
</style>
</body>
</html>