Click Run button to execute code.
Drag & drop block, Click expression for edit code.
Download and extract.
DownloadOpen index.html to same this page.
Editor load mameBlock_template.html.
Copy some files and folders and set these css, HTML and Javascript on your HTML file.
Copy these files
Make html file and set css
<link rel="stylesheet" type="text/css" href="css/mameblock.min.css" media="all" />
set Run button with block area in html
<a id="mameRun" href="javascript:void(0)">Run</a> <a id="mameCode" href="javascript:void(0)">View Code</a> <div id="loading_area">Edit Area:</div>
set frame of dialog in html.
<!-- express dialog -->
<div id="modal-express">
<div class="modal-body">
<label for="expModalText">Edit expression</label><br />
<input id="expModalText" type="text" />
</div>
<a class="modal_close" href="#">[OK]</a>
</div>
Load jquery and library in index.html.
<!-- Javascript --> <script type="text/javascript" src="js/jquery-1.11.2.min.js"></script> <script type="text/javascript" src="js/mameblock.min.js"></script>
Load control script in index.html.
<script type="text/javascript">
$(function() {
<!-- # Init -->
var codeArea = $("#exampleArea");
var codeText = MAME_BLOCK.init("#loading_area", "mameBlock_template.html");
/* wait for DOM building */
var wait0 = setTimeout(function() {
setCode(MAME_BLOCK.getCodeBlock(), codeArea);
}, 500);
<!-- # Run -->
$("#mameRun").click(function() {
<!-- get code -->
var codeText = MAME_BLOCK.getCodeBlock();
setCode(codeText, codeArea);
var mameExec = new Function(codeText);
mameExec();
});
<!-- # View code -->
$("#mameCode").click(function() {
alert(MAME_BLOCK.getCodeBlock());
});
});
</script>
You can use your favarite librarly for code-highlighter and excutting code. I use highlight.js and Function class.
MameBlock.js tested and working in these browsers.