Incorporating feedback from @chriseth

pull/1/head
Dave Hoover 9 years ago
parent 712a33943a
commit 2b9a2bc7b3
  1. 4
      src/app.js
  2. 4
      src/app/compiler.js
  3. 10
      src/app/editor.js
  4. 10
      src/app/renderer.js

@ -210,7 +210,7 @@ var run = function() {
return false; return false;
} }
function fileTabFromKey() { function activeFileTab() {
var name = editor.getCacheFile(); var name = editor.getCacheFile();
return $('#files .file').filter(function(){ return $(this).find('.name').text() == name; }); return $('#files .file').filter(function(){ return $(this).find('.name').text() == name; });
} }
@ -227,7 +227,7 @@ var run = function() {
} }
if (editor.cacheFileIsPresent()) { if (editor.cacheFileIsPresent()) {
var active = fileTabFromKey(); var active = activeFileTab();
active.addClass('active'); active.addClass('active');
editor.resetSession(); editor.resetSession();
} }

@ -21,7 +21,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update
function onChange() { function onChange() {
var input = editor.getValue(); var input = editor.getValue();
if (input === "") { if (input === "") {
window.localStorage.setItem(editor.getRawCacheFile(), ''); editor.setCacheFileContent('');
return; return;
} }
if (input === previousInput) if (input === previousInput)
@ -38,7 +38,7 @@ function Compiler(web3, editor, handleGithubCall, outputField, hidingRHP, update
sourceAnnotations = []; sourceAnnotations = [];
outputField.empty(); outputField.empty();
var input = editor.getValue(); var input = editor.getValue();
window.localStorage.setItem(editor.getRawCacheFile(), input); editor.setCacheFileContent(input)
var files = {}; var files = {};
files[editor.getCacheFile()] = input; files[editor.getCacheFile()] = input;

@ -11,15 +11,15 @@ function Editor(loadingFromGist) {
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
sessions[SOL_CACHE_FILE] = null; sessions[SOL_CACHE_FILE] = null;
window.localStorage[SOL_CACHE_FILE] = ''; this.setCacheFileContent('');
}; };
this.setCacheFile = function(cacheFile) { this.setCacheFileContent = function(content) {
SOL_CACHE_FILE = utils.fileKey(cacheFile); window.localStorage.setItem(SOL_CACHE_FILE, content);
}; };
this.getRawCacheFile = function() { this.setCacheFile = function(cacheFile) {
return SOL_CACHE_FILE; SOL_CACHE_FILE = utils.fileKey(cacheFile);
}; };
this.getCacheFile = function() { this.getCacheFile = function() {

@ -83,8 +83,8 @@ function Renderer(web3, editor, compiler, updateFiles) {
}; };
this.error = renderError; this.error = renderError;
var combined = function(contractName, interface, bytecode){ var combined = function(contractName, jsonInterface, bytecode){
return JSON.stringify([{name: contractName, interface: interface, bytecode: bytecode}]); return JSON.stringify([{name: contractName, interface: jsonInterface, bytecode: bytecode}]);
}; };
function renderContracts(data, source) { function renderContracts(data, source) {
@ -224,15 +224,15 @@ function Renderer(web3, editor, compiler, updateFiles) {
return text; return text;
}; };
function gethDeploy(contractName, interface, bytecode){ function gethDeploy(contractName, jsonInterface, bytecode){
var code = ""; var code = "";
var funABI = getConstructorInterface(JSON.parse(interface)); var funABI = getConstructorInterface(JSON.parse(jsonInterface));
funABI.inputs.forEach(function(inp) { funABI.inputs.forEach(function(inp) {
code += "var " + inp.name + " = /* var of type " + inp.type + " here */ ;\n"; code += "var " + inp.name + " = /* var of type " + inp.type + " here */ ;\n";
}); });
code += "var " + contractName + "Contract = web3.eth.contract(" + interface.replace("\n","") + ");" code += "var " + contractName + "Contract = web3.eth.contract(" + jsonInterface.replace("\n","") + ");"
+"\nvar " + contractName + " = " + contractName + "Contract.new("; +"\nvar " + contractName + " = " + contractName + "Contract.new(";
funABI.inputs.forEach(function(inp) { funABI.inputs.forEach(function(inp) {

Loading…
Cancel
Save