Commit c66af27e authored by Alex Beregszaszi's avatar Alex Beregszaszi

Standard: format whitespace (using semistandard-format)

parent 18f094d7
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
var multi = function(func) { return func.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; } var multi = function (func) { return func.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; };
var BALLOT_EXAMPLE = multi(function(){/*contract Ballot { var BALLOT_EXAMPLE = multi(function () { /*contract Ballot {
struct Voter { struct Voter {
uint weight; uint weight;
......
/* global chrome */ /* global chrome */
chrome.browserAction.onClicked.addListener(function (tab) { chrome.browserAction.onClicked.addListener(function (tab) {
chrome.storage.sync.set({ 'chrome-app-sync': true });
chrome.storage.sync.set({ 'chrome-app-sync' : true });
chrome.tabs.create({ 'url': chrome.extension.getURL('index.html') }, function (tab) { chrome.tabs.create({ 'url': chrome.extension.getURL('index.html') }, function (tab) {
// tab opened // tab opened
}); });
}); });
...@@ -21,7 +21,6 @@ window.addEventListener('message', function (ev) { ...@@ -21,7 +21,6 @@ window.addEventListener('message', function (ev) {
}, false); }, false);
var run = function () { var run = function () {
function loadFiles (files) { function loadFiles (files) {
for (var f in files) { for (var f in files) {
var key = utils.fileKey(f); var key = utils.fileKey(f);
...@@ -46,7 +45,6 @@ var run = function () { ...@@ -46,7 +45,6 @@ var run = function () {
loadFiles(filesToLoad); loadFiles(filesToLoad);
} }
// ------------------ query params (hash) ---------------- // ------------------ query params (hash) ----------------
function syncQueryParams () { function syncQueryParams () {
...@@ -57,6 +55,7 @@ var run = function () { ...@@ -57,6 +55,7 @@ var run = function () {
syncQueryParams(); syncQueryParams();
// -------- check file upload capabilities ------- // -------- check file upload capabilities -------
if (!(window.File || window.FileReader || window.FileList || window.Blob)) { if (!(window.File || window.FileReader || window.FileList || window.Blob)) {
$(".uploadFile").remove(); $(".uploadFile").remove();
} }
...@@ -80,19 +79,16 @@ var run = function () { ...@@ -80,19 +79,16 @@ var run = function () {
}); });
}); });
// ----------------- storage -------------------- // ----------------- storage --------------------
var storageHandler = new StorageHandler(updateFiles); var storageHandler = new StorageHandler(updateFiles);
window.syncStorage = storageHandler.sync; window.syncStorage = storageHandler.sync;
storageHandler.sync(); storageHandler.sync();
// ----------------- editor ---------------------- // ----------------- editor ----------------------
var editor = new Editor(loadingFromGist); var editor = new Editor(loadingFromGist);
// ----------------- tabbed menu ------------------- // ----------------- tabbed menu -------------------
$('#options li').click(function (ev) { $('#options li').click(function (ev) {
...@@ -110,12 +106,10 @@ var run = function () { ...@@ -110,12 +106,10 @@ var run = function () {
} }
}); });
// ------------------ gist publish -------------- // ------------------ gist publish --------------
$('#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 = editor.packageFiles(); var files = editor.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://ethereum.github.io/browser-solidity/#version=' + queryParams.get().version + '&optimize=' + queryParams.get().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=' + queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&gist=';
...@@ -239,7 +233,6 @@ var run = function () { ...@@ -239,7 +233,6 @@ var run = function () {
return $('#files .file').filter(function () { return $(this).find('.name').text() === name; }); return $('#files .file').filter(function () { return $(this).find('.name').text() === name; });
} }
function updateFiles () { function updateFiles () {
var $filesEl = $('#files'); var $filesEl = $('#files');
var files = editor.getFiles(); var files = editor.getFiles();
...@@ -392,7 +385,6 @@ var run = function () { ...@@ -392,7 +385,6 @@ var run = function () {
if (cachedSize) setEditorSize(cachedSize); if (cachedSize) setEditorSize(cachedSize);
else getEditorSize(); else getEditorSize();
// ----------------- toggle right hand panel ----------------- // ----------------- toggle right hand panel -----------------
var hidingRHP = false; var hidingRHP = false;
...@@ -418,12 +410,10 @@ var run = function () { ...@@ -418,12 +410,10 @@ 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 output renderer ---------------------- // ----------------- compiler output renderer ----------------------
$('.asmOutput button').click(function () { $(this).parent().find('pre').toggle(); }); $('.asmOutput button').click(function () { $(this).parent().find('pre').toggle(); });
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
function handleGithubCall (root, path, cb) { function handleGithubCall (root, path, cb) {
...@@ -454,7 +444,7 @@ var run = function () { ...@@ -454,7 +444,7 @@ var run = function () {
loadVersion(queryParams.get().version || 'soljson-latest.js'); loadVersion(queryParams.get().version || 'soljson-latest.js');
document.querySelector('#optimize').addEventListener('change', function () { document.querySelector('#optimize').addEventListener('change', function () {
queryParams.update({optimize: document.querySelector('#optimize').checked }); queryParams.update({ optimize: document.querySelector('#optimize').checked });
compiler.compile(); compiler.compile();
}); });
......
var version = function() { return '(loading)'; } var version = function () { return '(loading)'; };
var compileJSON = function() { return ''; } var compileJSON = function () { return ''; };
var missingInputs = []; var missingInputs = [];
module.exports = function (self) { module.exports = function (self) {
self.addEventListener('message', function(e) { self.addEventListener('message', function (e) {
var data = e.data; var data = e.data;
switch (data.cmd) { switch (data.cmd) {
case 'loadVersion': case 'loadVersion':
...@@ -16,10 +16,10 @@ module.exports = function (self) { ...@@ -16,10 +16,10 @@ module.exports = function (self) {
if ('_compileJSONCallback' in Module) if ('_compileJSONCallback' in Module)
{ {
var compileJSONInternal = Module.cwrap("compileJSONCallback", "string", ["string", "number", "number"]); var compileJSONInternal = Module.cwrap("compileJSONCallback", "string", ["string", "number", "number"]);
var missingInputCallback = Module.Runtime.addFunction(function(path) { var missingInputCallback = Module.Runtime.addFunction(function (path) {
missingInputs.push(Module.Pointer_stringify(path)); missingInputs.push(Module.Pointer_stringify(path));
}); });
compileJSON = function(input, optimize) { compileJSON = function (input, optimize) {
return compileJSONInternal(input, optimize, missingInputCallback); return compileJSONInternal(input, optimize, missingInputCallback);
}; };
} }
...@@ -39,4 +39,4 @@ module.exports = function (self) { ...@@ -39,4 +39,4 @@ module.exports = function (self) {
break; break;
} }
}, false); }, false);
} };
...@@ -42,7 +42,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -42,7 +42,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
sourceAnnotations = []; sourceAnnotations = [];
outputField.empty(); outputField.empty();
var input = editor.getValue(); var input = editor.getValue();
editor.setCacheFileContent(input) editor.setCacheFileContent(input);
var files = {}; var files = {};
files[editor.getCacheFile()] = input; files[editor.getCacheFile()] = input;
...@@ -148,7 +148,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -148,7 +148,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
function loadInternal (url, setVersionText) { function loadInternal (url, setVersionText) {
Module = null; Module = null;
// Set a safe fallback until the new one is loaded // Set a safe fallback until the new one is loaded
compileJSON = function(source, optimize) { compilationFinished('{}'); }; compileJSON = function (source, optimize) { compilationFinished('{}'); };
var newScript = document.createElement('script'); var newScript = document.createElement('script');
newScript.type = 'text/javascript'; newScript.type = 'text/javascript';
...@@ -178,7 +178,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -178,7 +178,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
case 'compiled': case 'compiled':
compilationFinished(data.data, data.missingInputs); compilationFinished(data.data, data.missingInputs);
break; break;
}; }
}); });
worker.onerror = function (msg) { console.log(msg.data); }; worker.onerror = function (msg) { console.log(msg.data); };
worker.addEventListener('error', function (msg) { console.log(msg.data); }); worker.addEventListener('error', function (msg) { console.log(msg.data); });
...@@ -186,7 +186,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -186,7 +186,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
worker.postMessage({cmd: 'compile', source: source, optimize: optimize}); worker.postMessage({cmd: 'compile', source: source, optimize: optimize});
}; };
worker.postMessage({cmd: 'loadVersion', data: url}); worker.postMessage({cmd: 'loadVersion', data: url});
}; }
function gatherImports (files, importHints, cb) { function gatherImports (files, importHints, cb) {
importHints = importHints || []; importHints = importHints || [];
...@@ -243,4 +243,4 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -243,4 +243,4 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
} }
} }
module.exports = Compiler module.exports = Compiler;
...@@ -34,5 +34,5 @@ function updateQueryParams (params) { ...@@ -34,5 +34,5 @@ function updateQueryParams (params) {
module.exports = { module.exports = {
get: getQueryParams, get: getQueryParams,
update: updateQueryParams, update: updateQueryParams
}; };
...@@ -6,7 +6,6 @@ var utils = require('./utils'); ...@@ -6,7 +6,6 @@ var utils = require('./utils');
var ExecutionContext = require('./execution-context'); var ExecutionContext = require('./execution-context');
function Renderer (editor, compiler, updateFiles) { function Renderer (editor, compiler, updateFiles) {
var detailsOpen = {}; var detailsOpen = {};
var executionContext = new ExecutionContext(compiler); var executionContext = new ExecutionContext(compiler);
...@@ -43,7 +42,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -43,7 +42,7 @@ function Renderer (editor, compiler, updateFiles) {
return false; return false;
}); });
} }
}; }
this.error = renderError; this.error = renderError;
var combined = function (contractName, jsonInterface, bytecode) { var combined = function (contractName, jsonInterface, bytecode) {
...@@ -51,7 +50,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -51,7 +50,6 @@ function Renderer (editor, compiler, updateFiles) {
}; };
function renderContracts (data, source) { function renderContracts (data, source) {
var udappContracts = []; var udappContracts = [];
for (var contractName in data.contracts) { for (var contractName in data.contracts) {
var contract = data.contracts[contractName]; var contract = data.contracts[contractName];
...@@ -105,7 +103,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -105,7 +103,7 @@ function Renderer (editor, compiler, updateFiles) {
$contractOutput.find('.title').click(function (ev) { $(this).closest('.contract').toggleClass('hide'); }); $contractOutput.find('.title').click(function (ev) { $(this).closest('.contract').toggleClass('hide'); });
$('#output').append($contractOutput); $('#output').append($contractOutput);
$('.col2 input,textarea').click(function () { this.select(); }); $('.col2 input,textarea').click(function () { this.select(); });
}; }
this.contracts = renderContracts; this.contracts = renderContracts;
var tableRowItems = function (first, second, cls) { var tableRowItems = function (first, second, cls) {
...@@ -154,7 +152,7 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -154,7 +152,7 @@ function Renderer (editor, compiler, updateFiles) {
}; };
var formatGasEstimates = function (data) { var formatGasEstimates = function (data) {
var gasToText = function (g) { return g === null ? 'unknown' : g; } var gasToText = function (g) { return g === null ? 'unknown' : g; };
var text = ''; var text = '';
var fun; var fun;
if ('creation' in data) { if ('creation' in data) {
...@@ -227,7 +225,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -227,7 +225,6 @@ function Renderer (editor, compiler, updateFiles) {
'\n }' + '\n }' +
'\n })'; '\n })';
return code; return code;
} }
...@@ -241,7 +238,6 @@ function Renderer (editor, compiler, updateFiles) { ...@@ -241,7 +238,6 @@ function Renderer (editor, compiler, updateFiles) {
} }
return funABI; return funABI;
} }
} }
module.exports = Renderer; module.exports = Renderer;
...@@ -3,16 +3,14 @@ ...@@ -3,16 +3,14 @@
var utils = require('./utils'); var utils = require('./utils');
function StorageHandler (updateFiles) { function StorageHandler (updateFiles) {
this.sync = function () { this.sync = function () {
if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) { if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) {
return; return;
} }
var obj = {}; var obj = {};
var done = false; var done = false;
var count = 0 var count = 0;
var dont = 0; var dont = 0;
function check (key) { function check (key) {
...@@ -30,9 +28,9 @@ function StorageHandler (updateFiles) { ...@@ -30,9 +28,9 @@ function StorageHandler (updateFiles) {
if (done >= count) { if (done >= count) {
chrome.storage.sync.set(obj, function () { chrome.storage.sync.set(obj, function () {
console.log('updated cloud files with: ', obj, this, arguments); console.log('updated cloud files with: ', obj, this, arguments);
}) });
} }
}) });
} }
for (var y in window.localStorage) { for (var y in window.localStorage) {
......
...@@ -85,7 +85,6 @@ UniversalDApp.prototype.render = function () { ...@@ -85,7 +85,6 @@ UniversalDApp.prototype.render = function () {
if (this.contracts.length === 0) { if (this.contracts.length === 0) {
this.$el.append(this.getABIInputForm()); this.$el.append(this.getABIInputForm());
} else { } else {
for (var c in this.contracts) { for (var c in this.contracts) {
var $contractEl = $('<div class="contract"/>'); var $contractEl = $('<div class="contract"/>');
...@@ -147,7 +146,6 @@ UniversalDApp.prototype.getABIInputForm = function (cb) { ...@@ -147,7 +146,6 @@ UniversalDApp.prototype.getABIInputForm = function (cb) {
return $el; return $el;
}; };
UniversalDApp.prototype.getCreateInterface = function ($container, contract) { UniversalDApp.prototype.getCreateInterface = function ($container, contract) {
var self = this; var self = this;
var $createInterface = $('<div class="create"/>'); var $createInterface = $('<div class="create"/>');
...@@ -181,7 +179,6 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -181,7 +179,6 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
var $createInterface = $('<div class="createContract"/>'); var $createInterface = $('<div class="createContract"/>');
var appendFunctions = function (address, $el) { var appendFunctions = function (address, $el) {
var $instance = $('<div class="instance"/>'); var $instance = $('<div class="instance"/>');
if (self.options.removable_instances) { if (self.options.removable_instances) {
var $close = $('<div class="udapp-close" />'); var $close = $('<div class="udapp-close" />');
...@@ -497,7 +494,6 @@ UniversalDApp.prototype.getCallButton = function (args) { ...@@ -497,7 +494,6 @@ UniversalDApp.prototype.getCallButton = function (args) {
$result.append(getReturnOutput(result)).append(getGasUsedOutput(result)); $result.append(getReturnOutput(result)).append(getGasUsedOutput(result));
} }
}); });
} }
}); });
}; };
...@@ -574,7 +570,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) { ...@@ -574,7 +570,7 @@ UniversalDApp.prototype.deployLibrary = function (contractName, cb) {
self.getContractByName(contractName).address = result.createdAddress; self.getContractByName(contractName).address = result.createdAddress;
cb(err, result.createdAddress); cb(err, result.createdAddress);
} else { } else {
tryTillResponse(self.web3, result, function(err, finalResult) { tryTillResponse(self.web3, result, function (err, finalResult) {
if (err) return cb(err); if (err) return cb(err);
self.getContractByName(contractName).address = finalResult.contractAddress; self.getContractByName(contractName).address = finalResult.contractAddress;
cb(null, finalResult.contractAddress); cb(null, finalResult.contractAddress);
...@@ -635,7 +631,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) { ...@@ -635,7 +631,7 @@ UniversalDApp.prototype.runTx = function (data, args, cb) {
var address = this.options.getAddress ? this.options.getAddress() : this.getAccounts()[0]; var address = this.options.getAddress ? this.options.getAddress() : this.getAccounts()[0];
var account = this.accounts[address]; var account = this.accounts[address];
tx = new EthJSTX({ tx = new EthJSTX({
nonce: new Buffer([account.nonce++]), //@todo count beyond 255 nonce: new Buffer([account.nonce++]), // @todo count beyond 255
gasPrice: 1, gasPrice: 1,
gasLimit: 3000000000, // plenty gasLimit: 3000000000, // plenty
to: to, to: to,
...@@ -668,7 +664,6 @@ function tryTillResponse (web3, txhash, done) { ...@@ -668,7 +664,6 @@ function tryTillResponse (web3, txhash, done) {
done(err, address); done(err, address);
} }
} }
} }
module.exports = UniversalDApp; module.exports = UniversalDApp;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment