-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
173 lines (161 loc) · 7.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="./main.css?id=0002" />
<link rel="icon" href="./favicon.ico" />
<title>CodeBuilderPMMP </title>
<meta property="og:title" content="CodeBuilderPMMP" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://gollilla.github.io/CodeBuilderPMMP/" />
<meta property="og:image" content="https://gollilla.github.io/CodeBuilderPMMP/ogp.png" />
<meta property="og:site_name" content="CodeBuilderPMMP" />
<meta property="og:description" content="ビジュアル言語でプラグイン作成" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@sdo_re" />
</head>
<body>
<button onclick="codeTo()" id="compile_button">コード表示</button>
<div class="link-to-github"><img id="github-logo" src="./GitHub-Mark-32px.png"> To GitHub</div>
<div class="auto-compile">
<span style="font-weight: bold;font-size: 10px;">自動コード変換</span>
<div class="switchArea" style="display: inline-block">
<input type="checkbox" id="switch1">
<label for="switch1"><span></span></label>
<div id="swImg"></div>
</div>
</div>
<div class="container">
<div id="editor"></div>
<div id="code"></div>
</div>
<div class="toolbox-area"></div>
<xml id="examples" xmlns="https://developers.google.com/blockly/xml" style="display: none;">
<variables>
<variable id="Qoy:zatDMHB@w~RDRoU{">event</variable>
<variable id="/ZSCYbn_M{E|@1=6Mg]v">player</variable>
</variables>
<block type="eventhandler" id="E0|ie+O+xm4Ide{k]4vz" x="40" y="35">
<field name="eventList">PlayerJoinEvent</field>
<field name="event" id="Qoy:zatDMHB@w~RDRoU{">event</field>
<statement name="doing">
<block type="variables_set" id="LVcJyZKX%K7Pf(]N95Xw">
<field name="VAR" id="/ZSCYbn_M{E|@1=6Mg]v">player</field>
<value name="VALUE">
<block type="getter" id="L-`buAh1}Er]g#+ad?)s">
<value name="objects">
<block type="variables_get" id="D{r0G5?iYZ%fGo9YOxKI">
<field name="VAR" id="Qoy:zatDMHB@w~RDRoU{">event</field>
</block>
</value>
<value name="value">
<block type="text" id="ut?@i(kJiDGv*]CB*mzv">
<field name="TEXT">Player</field>
</block>
</value>
</block>
</value>
<next>
<block type="sendmessage" id="26I/7YBnJ|$+9^35-{eK">
<value name="value">
<block type="variables_get" id="0G;lc(5?HFF1^8j|B:t7">
<field name="VAR" id="/ZSCYbn_M{E|@1=6Mg]v">player</field>
</block>
</value>
<value name="message">
<block type="text" id="0[}P@H$JN!i5^O2?~md3">
<field name="TEXT">こんにちは</field>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</xml>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ace.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.11/ext-language_tools.min.js"></script>
<script src="./blockly_compressed.js"></script>
<script src="./blocks_compressed.js"></script>
<script src="./javascript_compressed.js"></script>
<script src="./php_compressed.js"></script>
<script src="./pmmp_blocks.js"></script>
<script src="./pmmp_code_gen.js"></script>
<script src="./msg/js/ja.js"></script>
<script>
let workspace;
let editor;
let auto_compile_func;
$(function () {
$(".toolbox-area").load("./toolbox.xml", (data, status, obj) => {
workspace = Blockly.inject('editor', {
toolbox: document.getElementById("toolbox"), maxBlocks: Infinity, sounds: false, trashcan: true, zoom: {
controls: true,
wheel: false,
startScale: 0.8,
maxScale: 3,
minScale: 0.3,
scaleSpeed: 1.2
}
});
auto_compile_func = (e) => {
if (e.type !== Blockly.Events.BLOCK_MOVE && e.type !== Blockly.Events.CLICK && e.type !== Blockly.Events.SELECTD && e.type !== Blockly.Events.VIEWPORT_CHANGE) {
//console.log(e.type);
codeTo();
}
};
$("#switch1").change(() => {
if ($("#switch1").prop("checked")) { //自動変換 ON
workspace.addChangeListener(auto_compile_func);
codeTo();
$("#compile_button").hide();
} else {
workspace.removeChangeListener(auto_compile_func);
$("#compile_button").show();
}
})
Blockly.Xml.domToWorkspace(document.getElementById('examples'), workspace);
});
editor = ace.edit("code");
editor.$blockScrolling = Infinity;
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true,
enableAutoIndent: true
});
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/php");
editor.setFontSize(15);
editor.setShowPrintMargin(false);
});
$(".link-to-github").click(() => {
window.open("https://github.com/gollilla/CodeBuilderPMMP", "_blank");
});
function codeTo() {
let code = Blockly.PHP.workspaceToCode(workspace);
code = "<?php\n"
+ "namespace test\\test;\n\n"
+ "use pocketmine\\event\\player\\{\n"
+ " PlayerJoinEvent,\n"
+ " PlayerMoveEvent,\n"
+ " PlayerQuitEvent\n"
+ "};\n\n"
+ "class Main extends PluginBase implements Listener {\n\n"
+ " public function onEnable(){\n"
+ " $this->getServer()->getPluginManager()->registerEvents($this, $this);\n"
+ " }\n"
+ "\n"
+ code;
code = code
+ "}\n";
editor.setValue(code);
editor.getSelection().clearSelection();
setTimeout(() => {
editor.autoIndent();
}, 100);
}
</script>
</body>
</html>