diff --git a/index.html b/index.html index cb95951249..590a905c86 100644 --- a/index.html +++ b/index.html @@ -47,37 +47,37 @@ THE SOFTWARE. - + -
+
- + + + +
+
+
+ +
+
+ +
-
-
- -
-
- -
-
- - - - + if (Module) + onCompilerLoaded(); + + editor.getSession().on('change', onChange); + + document.querySelector('#optimize').addEventListener('change', compile); + + // ----------------- compiler output renderer ---------------------- + var detailsOpen = {}; + + var renderError = function(message) { + $('#output') + .append($('
').text(message));
+			var err = message.match(/^:([0-9]*):([0-9]*)/)
+			if (err && err.length) {
+				var errLine = parseInt( err[1], 10 ) - 1;
+				var errCol = err[2] ? parseInt( err[2], 10 ) : 0;
+				sourceAnnotations[sourceAnnotations.length] ={
+					row: errLine,
+					column: errCol,
+					text: message,
+					type: "error"
+				};
+				editor.getSession().setAnnotations(sourceAnnotations);
+			}
+		};
+
+		var gethDeploy = function(contractName, interface, bytecode){
+			var code = "";
+			var funABI = getConstructorInterface($.parseJSON(interface));
+
+			$.each(funABI.inputs, function(i, inp) {
+				code += "var "+inp.name+" = /* var of type " + inp.type + " here */ ;\n";
+			});
+
+			code += "\nvar "+contractName+"Contract = web3.eth.contract("+interface.replace("\n","")+");"
+				+"\nvar "+contractName+" = "+contractName+"Contract.new(";
+			
+			$.each(funABI.inputs, function(i, inp) {
+				code += "\n   "+inp.name+",";
+			});
+						
+			code += "\n   {"+
+			"\n     from: web3.eth.accounts[0], "+
+			"\n     data: '"+bytecode+"', "+
+			"\n     gas: 1000000"+
+			"\n   }, function(e, contract){"+
+			"\n    if (typeof contract.address != 'undefined') {"+            
+			"\n         console.log(e, contract);"+
+			"\n         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
+			"\n    }" +
+			"\n })";
+
+
+			return code;
+		};
+
+		var combined = function(contractName, interface, bytecode){
+			return JSON.stringify( [{name: contractName, interface: interface, bytecode: bytecode}]);
+
+		};
+
+		var renderContracts = function(data, source) {
+		window.localStorage.setItem( SOL_CACHE_FILE, source );
+
+			$('#output').empty();
+			for (var contractName in data.contracts) {
+				var contract = data.contracts[contractName];
+				var title = $('

').text(contractName); + var contractOutput = $('
') + .append(title); + var body = $('
') + contractOutput.append( body ); + if (contract.bytecode.length > 0) + title.append($('
').text((contract.bytecode.length / 2) + ' bytes')) + body.append(getExecuteInterface(contract, contractName)) + .append(tableRow('Bytecode', contract.bytecode)); + body.append(tableRow('Interface', contract['interface'])) + .append(textRow('Web3 deploy', gethDeploy(contractName.toLowerCase(),contract['interface'],contract.bytecode), 'deploy')) + .append(textRow('uDApp', combined(contractName,contract['interface'],contract.bytecode), 'deploy')) + .append(getDetails(contract, source, contractName)); + + $('#output').append(contractOutput); + title.click(function(ev){ $(this).parent().toggleClass('hide') }); + } + + $('.col2 input,textarea').click(function() { this.select(); } ); + }; + var tableRowItems = function(first, second, cls) { + return $('
') + .addClass(cls) + .append($('
').append(first)) + .append($('
').append(second)); + }; + var tableRow = function(description, data) { + return tableRowItems( + $('').text(description), + $('').val(data)); + }; + var textRow = function(description, data, cls) { + return tableRowItems( + $('').text(description), + $('