@ -181,7 +181,7 @@ var run = function() {
var untitledCount = '' ;
var untitledCount = '' ;
if ( ! getFiles ( ) . length || window . localStorage [ 'sol-cache' ] ) {
if ( ! getFiles ( ) . length || window . localStorage [ 'sol-cache' ] ) {
if ( loadingFromGist ) return ;
if ( loadingFromGist ) return ;
// Backwards-compatibility
// Backwards-compatibility
while ( window . localStorage [ SOL _CACHE _UNTITLED + untitledCount ] )
while ( window . localStorage [ SOL _CACHE _UNTITLED + untitledCount ] )
untitledCount = ( untitledCount - 0 ) + 1 ;
untitledCount = ( untitledCount - 0 ) + 1 ;
SOL _CACHE _FILE = SOL _CACHE _UNTITLED + untitledCount ;
SOL _CACHE _FILE = SOL _CACHE _UNTITLED + untitledCount ;
@ -262,7 +262,7 @@ var run = function() {
// ------------------ gist publish --------------
// ------------------ gist publish --------------
var packageFiles = function ( ) {
var packageFiles = function ( ) {
var files = { } ;
var files = { } ;
var filesArr = getFiles ( ) ;
var filesArr = getFiles ( ) ;
@ -272,16 +272,16 @@ var run = function() {
content : localStorage [ filesArr [ f ] ]
content : localStorage [ filesArr [ f ] ]
} ;
} ;
}
}
return files ;
return files ;
} ;
} ;
$ ( '#gist' ) . click ( function ( ) {
$ ( '#gist' ) . click ( function ( ) {
if ( confirm ( "Are you sure you want to publish all your files anonymously as a public gist on github.com?" ) ) {
if ( confirm ( "Are you sure you want to publish all your files anonymously as a public gist on github.com?" ) ) {
var files = packageFiles ( ) ;
var files = packageFiles ( ) ;
var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://chris eth.github.io/browser-solidity/#version=" + getQueryParams ( ) . version + "&optimize=" + getQueryParams ( ) . optimize + "&gist=" ;
var description = "Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://ethereum .github.io/browser-solidity/#version=" + getQueryParams ( ) . version + "&optimize=" + getQueryParams ( ) . optimize + "&gist=" ;
$ . ajax ( {
$ . ajax ( {
url : 'https://api.github.com/gists' ,
url : 'https://api.github.com/gists' ,
type : 'POST' ,
type : 'POST' ,
data : JSON . stringify ( {
data : JSON . stringify ( {
@ -397,7 +397,7 @@ var run = function() {
for ( var f in files ) {
for ( var f in files ) {
$filesEl . append ( fileTabTemplate ( files [ f ] ) ) ;
$filesEl . append ( fileTabTemplate ( files [ f ] ) ) ;
}
}
if ( SOL _CACHE _FILE ) {
if ( SOL _CACHE _FILE ) {
var active = fileTabFromKey ( SOL _CACHE _FILE ) ;
var active = fileTabFromKey ( SOL _CACHE _FILE ) ;
active . addClass ( 'active' ) ;
active . addClass ( 'active' ) ;
@ -511,9 +511,9 @@ var run = function() {
updateQueryParams ( { version : $ ( '#versionSelector' ) . val ( ) } ) ;
updateQueryParams ( { version : $ ( '#versionSelector' ) . val ( ) } ) ;
loadVersion ( $ ( '#versionSelector' ) . val ( ) ) ;
loadVersion ( $ ( '#versionSelector' ) . val ( ) ) ;
} ) ;
} ) ;
// ----------------- resizeable ui ---------------
// ----------------- resizeable ui ---------------
var EDITOR _SIZE _CACHE _KEY = "editor-size-cache" ;
var EDITOR _SIZE _CACHE _KEY = "editor-size-cache" ;
var dragging = false ;
var dragging = false ;
$ ( '#dragbar' ) . mousedown ( function ( e ) {
$ ( '#dragbar' ) . mousedown ( function ( e ) {
@ -566,13 +566,13 @@ var run = function() {
var hidingRHP = false ;
var hidingRHP = false ;
$ ( '.toggleRHP' ) . click ( function ( ) {
$ ( '.toggleRHP' ) . click ( function ( ) {
hidingRHP = ! hidingRHP ;
hidingRHP = ! hidingRHP ;
setEditorSize ( hidingRHP ? 0 : window . localStorage [ EDITOR _SIZE _CACHE _KEY ] ) ;
setEditorSize ( hidingRHP ? 0 : window . localStorage [ EDITOR _SIZE _CACHE _KEY ] ) ;
$ ( '.toggleRHP i' ) . toggleClass ( 'fa-angle-double-right' , ! hidingRHP ) ;
$ ( '.toggleRHP i' ) . toggleClass ( 'fa-angle-double-right' , ! hidingRHP ) ;
$ ( '.toggleRHP i' ) . toggleClass ( 'fa-angle-double-left' , hidingRHP ) ;
$ ( '.toggleRHP i' ) . toggleClass ( 'fa-angle-double-left' , hidingRHP ) ;
if ( ! hidingRHP ) compile ( ) ;
if ( ! hidingRHP ) compile ( ) ;
} ) ;
} ) ;
// ----------------- editor resize ---------------
// ----------------- editor resize ---------------
@ -595,7 +595,7 @@ var run = function() {
document . querySelector ( '#editor' ) . addEventListener ( 'change' , onResize ) ;
document . querySelector ( '#editor' ) . addEventListener ( 'change' , onResize ) ;
document . querySelector ( '#editorWrap' ) . addEventListener ( 'change' , onResize ) ;
document . querySelector ( '#editorWrap' ) . addEventListener ( 'change' , onResize ) ;
// ----------------- compiler ----------------------
// ----------------- compiler ----------------------
var compileJSON ;
var compileJSON ;
@ -637,13 +637,13 @@ var run = function() {
if ( errortype ( err ) !== 'warning' ) noFatalErrors = false ;
if ( errortype ( err ) !== 'warning' ) noFatalErrors = false ;
} ) ;
} ) ;
}
}
if ( missingInputs !== undefined && missingInputs . length > 0 )
if ( missingInputs !== undefined && missingInputs . length > 0 )
compile ( missingInputs ) ;
compile ( missingInputs ) ;
else if ( noFatalErrors && ! hidingRHP )
else if ( noFatalErrors && ! hidingRHP )
renderContracts ( data , editor . getValue ( ) ) ;
renderContracts ( data , editor . getValue ( ) ) ;
} ;
} ;
var compileTimeout = null ;
var compileTimeout = null ;
var onChange = function ( ) {
var onChange = function ( ) {
var input = editor . getValue ( ) ;
var input = editor . getValue ( ) ;
@ -860,18 +860,18 @@ var run = function() {
code += "var " + contractName + "Contract = web3.eth.contract(" + interface . replace ( "\n" , "" ) + ");"
code += "var " + contractName + "Contract = web3.eth.contract(" + interface . replace ( "\n" , "" ) + ");"
+ "\nvar " + contractName + " = " + contractName + "Contract.new(" ;
+ "\nvar " + contractName + " = " + contractName + "Contract.new(" ;
$ . each ( funABI . inputs , function ( i , inp ) {
$ . each ( funABI . inputs , function ( i , inp ) {
code += "\n " + inp . name + "," ;
code += "\n " + inp . name + "," ;
} ) ;
} ) ;
code += "\n {" +
code += "\n {" +
"\n from: web3.eth.accounts[0], " +
"\n from: web3.eth.accounts[0], " +
"\n data: '" + bytecode + "', " +
"\n data: '" + bytecode + "', " +
"\n gas: 3000000" +
"\n gas: 3000000" +
"\n }, function(e, contract){" +
"\n }, function(e, contract){" +
"\n console.log(e, contract);" +
"\n console.log(e, contract);" +
"\n if (typeof contract.address != 'undefined') {" +
"\n if (typeof contract.address != 'undefined') {" +
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }" +
"\n }" +
"\n })" ;
"\n })" ;
@ -1010,7 +1010,7 @@ var run = function() {
return text ;
return text ;
} ;
} ;
$ ( '.asmOutput button' ) . click ( function ( ) { $ ( this ) . parent ( ) . find ( 'pre' ) . toggle ( ) ; } ) ;
$ ( '.asmOutput button' ) . click ( function ( ) { $ ( this ) . parent ( ) . find ( 'pre' ) . toggle ( ) ; } ) ;
var getConstructorInterface = function ( abi ) {
var getConstructorInterface = function ( abi ) {
@ -1029,4 +1029,4 @@ var run = function() {
module . exports = {
module . exports = {
'run' : run
'run' : run
} ;
} ;