Commit c66af27e authored by Alex Beregszaszi's avatar Alex Beregszaszi

Standard: format whitespace (using semistandard-format)

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