-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (61 loc) · 2.12 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
<!DOCTYPE html>
<html>
<head>
<title>Playing with blockly</title>
<script src="js/blockly_compressed.js"></script>
<script src="js/blocks_compressed.js"></script>
<script src="js/en.js"></script>
</head>
<body>
<h1>Playing with blockly</h1>
<div id="blocklyDiv" style="position: absolute"></div>
<div id="blocklyArea" style="height: 600px; width: 100%;"></div>
<xml id="toolbox" style="display: none">
<block type="IDontWorkInMobile"></block>
</xml>
<script>
// HERE BE THE FieldImaged block
Blockly.Blocks['IDontWorkInMobile'] = {
init: function() {
this.appendDummyInput()
.appendField("Click the star to alert hello")
.appendField(new Blockly.FieldImage(
"https://www.gstatic.com/codesite/ph/images/star_on.gif",
15,
15,
"I'm a star, click me",
function(){alert("HELLO")}
));
this.setInputsInline(true);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};
var blocklyArea = document.getElementById('blocklyArea');
var blocklyDiv = document.getElementById('blocklyDiv');
var workspace = Blockly.inject(blocklyDiv,
{toolbox: document.getElementById('toolbox')});
var onresize = function(e) {
// Compute the absolute coordinates and dimensions of blocklyArea.
var element = blocklyArea;
var x = 0;
var y = 0;
do {
x += element.offsetLeft;
y += element.offsetTop;
element = element.offsetParent;
} while (element);
// Position blocklyDiv over blocklyArea.
blocklyDiv.style.left = x + 'px';
blocklyDiv.style.top = y + 'px';
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
Blockly.svgResize(workspace);
};
window.addEventListener('resize', onresize, false);
onresize();
Blockly.svgResize(workspace);
</script>
</body>
</html>