Provide a way to select and switch the compiler version.

pull/1/head
chriseth 9 years ago
parent be1fc35b58
commit e3852b338c
  1. 40
      index.html

@ -1,4 +1,6 @@
<html> <html>
<head>
<meta charset="utf-8">
<!-- <!--
The MIT License (MIT) The MIT License (MIT)
@ -24,8 +26,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
--> -->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1"> <meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Solidity realtime compiler and runtime</title> <title>Solidity realtime compiler and runtime</title>
<link rel="stylesheet" href="stylesheets/styles.css"> <link rel="stylesheet" href="stylesheets/styles.css">
@ -262,6 +262,7 @@ input[readonly] {
<h1>Solidity realtime<br/>compiler and runtime</h1> <h1>Solidity realtime<br/>compiler and runtime</h1>
<div class="info"> <div class="info">
<p>Version: <span id="version">(loading)</span><br/> <p>Version: <span id="version">(loading)</span><br/>
Change to: <select id="versionSelector"></select><br/>
Execution environment does not connect to any node, everyhing is local and in memory only.<br/> Execution environment does not connect to any node, everyhing is local and in memory only.<br/>
<code>tx.origin = <span id="txorigin"/></code></p> <code>tx.origin = <span id="txorigin"/></code></p>
</div> </div>
@ -278,9 +279,6 @@ input[readonly] {
<script> <script>
// ----------------- editor ---------------------- // ----------------- editor ----------------------
var SOL_CACHE_KEY = "sol-cache"; var SOL_CACHE_KEY = "sol-cache";
@ -297,6 +295,27 @@ input[readonly] {
session.setTabSize(4); session.setTabSize(4);
session.setUseSoftTabs(true); session.setUseSoftTabs(true);
// ----------------- version selector-------------
$.get('bin/list.txt').then(function(versionList) {
$('option', '#versionSelector').remove();
$.each(versionList.split('\n'), function(i, file) {
if (file) {
var version = file.replace(/soljson-(.*).js/, "$1");
$('#versionSelector').append(new Option(version, file));
}
});
$('#versionSelector').change(function() {
Module = null;
compileJSON = null;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'bin/' + $('#versionSelector').val();
$('head').append(script);
onCompilerLoaded();
});
});
// ----------------- resizeable ui --------------- // ----------------- resizeable ui ---------------
var EDITOR_SIZE_CACHE_KEY = "editor-size-cache"; var EDITOR_SIZE_CACHE_KEY = "editor-size-cache";
@ -362,8 +381,7 @@ input[readonly] {
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
var compileJSON = Module.cwrap("compileJSON", "string", ["string", "number"]); var compileJSON;
$('#version').text(Module.cwrap("version", "string", [])());
var previousInput = ''; var previousInput = '';
var compile = function() { var compile = function() {
@ -396,7 +414,15 @@ input[readonly] {
if (compileTimeout) window.clearTimeout(compileTimeout); if (compileTimeout) window.clearTimeout(compileTimeout);
compileTimeout = window.setTimeout(compile, 300); compileTimeout = window.setTimeout(compile, 300);
}; };
var onCompilerLoaded = function() {
compileJSON = Module.cwrap("compileJSON", "string", ["string", "number"]);
$('#version').text(Module.cwrap("version", "string", [])());
previousInput = '';
onChange(); onChange();
};
if (Module)
onCompilerLoaded();
editor.getSession().on('change', onChange); editor.getSession().on('change', onChange);

Loading…
Cancel
Save