-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
60 lines (55 loc) · 1.9 KB
/
index.html
File metadata and controls
60 lines (55 loc) · 1.9 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BinaryNumberContentEditor</title>
<!-- Since GitHub Raw files use text/plain as MIME type the script cannot be executed when linking directly, instead routed over jsdelivr-->
<script src='https://cdn.jsdelivr.net/gh/MicroContent/BinaryNumberContentEditor@master/seamlessjs/seamless.child.min.js'></script>
</head>
<body>
<script type="text/javascript">
// Connect to the parent page.
var parent = window.seamless.connect({
url: window.location.url,
allowStyleInjection: true,
});
</script>
<div>
<label for="numberInput">Enter Number between 0 and 255:</label>
<input id="numberInput" type="number"/>
</div>
<button onclick="sendToParent(event)">
Send to toolkit
</button>
<script type="application/javascript">
function dataGetter() {
var val = parseInt(document.getElementById('numberInput').value);
if (val < 0) {
val = Math.abs(val);
}
if (val > 255) {
val = 255;
}
document.getElementById('numberInput').value = val;
return {
// return data object
type: 'toViewer',
number: val,
// preview metadata
title: "Binary Representation of " + val,
description: "Click on the switches to set the correct binary representation of " + val,
imageUrl: "https://raw.githubusercontent.com/MicroContent/BinaryNumberContentViewer/8306856c7abc9999ea07316f79e78c0d2b6468a4/example.png"
}
}
// Send a message
window.sendToParent = function(event) {
event.preventDefault();
var result = dataGetter()
parent.send(result);
};
if (typeof window.data !== 'undefined' && typeof window.data.number == 'number') {
document.getElementById('numberInput').value = window.data.number;
}
</script>
</body>
</html>