TinyCore.js - Register/Start Modules (ultra-basic)
by JuanMa Garrido
HTML
<script src="https://raw.github.com/mawrkus/tinycore/master/src/TinyCore.js"></script>
<div id="container">
<ol>
<li><button id='startModule'>Start Module</button> → press button to start the module</li>
</ol>
</div>
CSS
#container { padding:10px; font-family: Arial; }
em { font-family: Courier; font-size:13px; font-weight:bold; }
h3 { font-style: italic; margin-bottom:10px; }
JavaScript
$(document).ready(function () {
// Register the Module
TinyCore.Module.register( 'my-module', function( bus ) {
return {
onStart: function( oData ) {
alert(oData.msg);
}
};
});
$("#startModule").click(function () {
// Start the Module
TinyCore.Module.start("my-module", { msg : "Hello World!" });
return false;
});
});