Commit a1901030 authored by carlosperate's avatar carlosperate

Remove automatic init call on page load from ardublockly.js.

Importing a js file should not have any secondary effects, like automatically running code. This also allows other Ardublockly-based applications to reuse a lot of the Ardublockly front end code and have their own onLoad init.
parent c6695862
...@@ -21,9 +21,8 @@ Ardublockly.LANGUAGE_NAME = { ...@@ -21,9 +21,8 @@ Ardublockly.LANGUAGE_NAME = {
*/ */
Ardublockly.LANG = 'en'; Ardublockly.LANG = 'en';
/** Initialize function for Ardublockly on page load. */ /** Initialize function for Ardublockly, to be called on page load. */
window.addEventListener('load', function load(event) { Ardublockly.init = function() {
window.removeEventListener('load', load, false);
// Lang init must run first for the rest of the page to pick the right msgs // Lang init must run first for the rest of the page to pick the right msgs
Ardublockly.initLanguage(); Ardublockly.initLanguage();
...@@ -43,7 +42,7 @@ window.addEventListener('load', function load(event) { ...@@ -43,7 +42,7 @@ window.addEventListener('load', function load(event) {
document.location.hostname != '192.168.0.7') { document.location.hostname != '192.168.0.7') {
Ardublockly.openNotConnectedModal(); Ardublockly.openNotConnectedModal();
} }
}); };
/** Binds functions to each of the buttons, nav links, and related. */ /** Binds functions to each of the buttons, nav links, and related. */
Ardublockly.bindActionFunctions = function() { Ardublockly.bindActionFunctions = function() {
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
<div class="settings_div"> <div class="settings_div">
<label>Default IDE button:</label> <br> <label>Default IDE button:</label> <br>
<select name="settings_ide" id="ide_settings"> <select name="settings_ide" id="ide_settings">
<option value="verify">IDE ptions unknown</option> <option value="verify">IDE ptions unknown</option>
</select> </select>
</div> </div>
<div class="settings_div"> <div class="settings_div">
...@@ -298,5 +298,11 @@ ...@@ -298,5 +298,11 @@
<script src="ardublockly_design.js"></script> <script src="ardublockly_design.js"></script>
<script src="ardublockly_blockly.js"></script> <script src="ardublockly_blockly.js"></script>
<script src="ardublockly.js"></script> <script src="ardublockly.js"></script>
<script>
window.addEventListener('load', function load(event) {
window.removeEventListener('load', load, false);
Ardublockly.init();
});
</script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment