@ -63,25 +63,47 @@ THE SOFTWARE.
< div id = "righthand-panel" >
< div id = "righthand-panel" >
< div id = "header" >
< div id = "header" >
< img id = "solIcon" title = "Solidity realtime compiler and runtime" src = "assets/img/sol.gif" >
< div id = "menu" >
< div class = "info" >
< img id = "solIcon" title = "Solidity realtime compiler and runtime" src = "assets/img/sol.gif" >
< div class = "version" > Solidity version: < span id = "version" > (loading)< / span > < br / > Change to: < select id = "versionSelector" > < / select > < / div >
< ul id = "options" >
< li class = "txView active" > < i class = "fa fa-send" > < / i > < / li >
< li class = "envView" > < i class = "fa fa-tachometer" > < / i > < / li >
< li class = "publishView" > < i class = "fa fa-cloud-upload" > < / i > < / li >
< li class = "settingsView" > < i class = "fa fa-gear" > < / i > < / li >
< / ul >
< / div >
< / div >
< div id = "optimizeBox" >
< div id = "optionViews" class = "txView" >
< button id = "gist" title = "Publish all files as public gist on github.com" > < i class = "fa fa-github" > < / i > Publish gist< / button >
< div id = "txView" >
< label for = "editorWrap" > < input id = "editorWrap" type = "checkbox" > Text Wrap< / label >
< code class = "origin" > tx.origin: < span id = "txorigin" / > < / code >
< label for = "optimize" > < input id = "optimize" type = "checkbox" > Enable Optimization< / label >
< select name = "" id = "" >
< code class = "origin" > tx.origin: < span id = "txorigin" / > < / code >
< option value = "" > Acc< / option >
< span id = "executionContext" >
< / select >
< label for = "vm" title = "Execution environment does not connect to any node, everything is local and in memory only." >
< input type = "text" class = "gas" >
< input id = "vm" type = "radio" value = "vm" checked name = "executionContext" >
< input type = "text" class = "value" >
JavaScript VM
< / div >
< / label >
< div id = "settingsView" >
< label for = "web3" title = "Execution environment connects to node at localhost, transactions will be sent to the network and can cause loss of money or worse!" >
< div class = "version" > Solidity version: < span id = "version" > (loading)< / span > < br / > Change to: < select id = "versionSelector" > < / select > < / div >
< input id = "web3" type = "radio" value = "web3" name = "executionContext" >
< label for = "editorWrap" > < input id = "editorWrap" type = "checkbox" > Text Wrap< / label >
Web3 Provider
< label for = "optimize" > < input id = "optimize" type = "checkbox" > Enable Optimization< / label >
< / label >
< / div >
< / span >
< div id = "publishView" >
< p > < button id = "gist" title = "Publish all files as public gist on github.com" > < i class = "fa fa-github" > < / i > Publish gist< / button > Publish all open files to an anonymous github gist.< / p >
< p > Publish to ipfs ...< / p >
< / div >
< div id = "envView" >
< span id = "executionContext" >
< label for = "vm" title = "Execution environment does not connect to any node, everything is local and in memory only." >
< input id = "vm" type = "radio" value = "vm" checked name = "executionContext" >
JavaScript VM
< / label >
< label for = "web3" title = "Execution environment connects to node at localhost, transactions will be sent to the network and can cause loss of money or worse!" >
< input id = "web3" type = "radio" value = "web3" name = "executionContext" >
Web3 Provider
< / label >
< / span >
< / div >
< / div >
< / div >
< / div >
< / div >
< div id = "output" > < / div >
< div id = "output" > < / div >
@ -95,28 +117,28 @@ THE SOFTWARE.
// ------------------ gist load ----------------
// ------------------ gist load ----------------
function getGistId(str) {
function getGistId(str) {
var idr = /[0-9A-Fa-f]{8,}/
var idr = /[0-9A-Fa-f]{8,}/
var match = idr.exec(str)[0]
var match = idr.exec(str)[0]
return match;
return match;
}
}
var location_hash_params = window.location.hash.substr(1).split("=");
var location_hash_params = window.location.hash.substr(1).split("=");
var loadingFromGist = false;
var loadingFromGist = false;
if (location_hash_params.indexOf('gist') !== -1 & & location_hash_params.length >= 2) {
if (location_hash_params.indexOf('gist') !== -1 & & location_hash_params.length >= 2) {
var index = location_hash_params.indexOf('gist');
var index = location_hash_params.indexOf('gist');
var gistId;
var gistId;
var key = location_hash_params[index+1];
var key = location_hash_params[index+1];
if (key === '') {
if (key === '') {
var str = prompt("Enter the URL or ID of the Gist you'd like to load.")
var str = prompt("Enter the URL or ID of the Gist you'd like to load.")
if (str !== '') {
if (str !== '') {
gistId = getGistId( str );
gistId = getGistId( str );
loadingFromGist = true;
loadingFromGist = true;
}
}
} else {
} else {
gistId = getGistId( key );
gistId = getGistId( key );
loadingFromGist = true;
loadingFromGist = true;
}
}
$.ajax({
$.ajax({
url: 'https://api.github.com/gists/'+gistId,
url: 'https://api.github.com/gists/'+gistId,
jsonp: 'callback',
jsonp: 'callback',
@ -164,6 +186,19 @@ THE SOFTWARE.
session.setTabSize(4);
session.setTabSize(4);
session.setUseSoftTabs(true);
session.setUseSoftTabs(true);
// ----------------- tabbed menu -------------------
$('#options li').click(function(){
var $el = $(this);
var cls = /[a-z]+View/.exec( $el.get(0).className )[0];
$el.parent().find('li').removeClass('active');
$el.addClass('active');
$('#optionViews').attr('class', '').addClass(cls);
console.log(cls)
});
// ----------------- execution context -------------
// ----------------- execution context -------------
var $vmToggle = $('#vm');
var $vmToggle = $('#vm');
@ -218,7 +253,7 @@ THE SOFTWARE.
// ----------------- file selector-------------
// ----------------- file selector-------------
var $filesEl = $('#files');
var $filesEl = $('#files');
$filesEl.on('click','.newFile', function() {
$filesEl.on('click','.newFile', function() {
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount])
untitledCount = (untitledCount - 0) + 1;
untitledCount = (untitledCount - 0) + 1;
@ -289,10 +324,10 @@ THE SOFTWARE.
function updateFiles() {
function updateFiles() {
var $filesEl = $('#files');
var $filesEl = $('#files');
var files = getFiles();
var files = getFiles();
$filesEl.find('.file').remove();
$filesEl.find('.file').remove();
for (var f in files) {
for (var f in files) {
$filesEl.append(fileTabTemplate(files[f]));
$filesEl.append(fileTabTemplate(files[f]));
@ -303,7 +338,7 @@ THE SOFTWARE.
active.addClass('active');
active.addClass('active');
editor.setValue( window.localStorage[SOL_CACHE_FILE] || '', -1);
editor.setValue( window.localStorage[SOL_CACHE_FILE] || '', -1);
editor.focus();
editor.focus();
}
}
$('#input').toggle( !!SOL_CACHE_FILE );
$('#input').toggle( !!SOL_CACHE_FILE );
}
}
@ -622,7 +657,7 @@ THE SOFTWARE.
renderError(err.message);
renderError(err.message);
if (accounts & & accounts[0])
if (accounts & & accounts[0])
$('#txorigin').text(accounts[0]);
$('#txorigin').text(accounts[0]);
else
else
$('#txorigin').text('unknown');
$('#txorigin').text('unknown');
});
});