Standard: use single quotes for strings

pull/1/head
Alex Beregszaszi 9 years ago
parent 0bbbb237ea
commit 4fb1947c21
  1. 2
      background.js
  2. 50
      src/app.js
  3. 16
      src/app/compiler.js
  4. 6
      src/app/editor.js
  5. 2
      src/app/gist-handler.js
  6. 12
      src/app/query-params.js
  7. 34
      src/app/renderer.js
  8. 12
      src/app/storage-handler.js
  9. 4
      src/index.js
  10. 18
      src/universal-dapp.js
  11. 4
      src/web3-adapter.js

@ -1,6 +1,6 @@
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) {

@ -12,8 +12,8 @@ var Compiler = require('./app/compiler');
// parent will send the message upon the "load" event.
var filesToLoad = null;
var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later
window.addEventListener("message", function(ev) {
if (typeof ev.data === typeof [] && ev.data[0] === "loadFiles") {
window.addEventListener('message', function(ev) {
if (typeof ev.data === typeof [] && ev.data[0] === 'loadFiles') {
loadFilesCallback(ev.data[1]);
}
}, false);
@ -47,7 +47,7 @@ var run = function() {
// ------------------ query params (hash) ----------------
function syncQueryParams() {
$('#optimize').attr( 'checked', (queryParams.get().optimize === "true") );
$('#optimize').attr( 'checked', (queryParams.get().optimize === 'true') );
}
window.onhashchange = syncQueryParams;
@ -64,7 +64,7 @@ var run = function() {
success: function(response) {
if (response.data) {
if (!response.data.files) {
alert( "Gist load error: " + response.data.message );
alert( 'Gist load error: ' + response.data.message );
return;
}
loadFiles(response.data.files);
@ -107,10 +107,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?")) {
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=";
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=';
$.ajax({
url: 'https://api.github.com/gists',
@ -121,7 +121,7 @@ var run = function() {
files: files
})
}).done(function(response) {
if (response.html_url && confirm("Created a gist at " + response.html_url + " Would you like to open it in a new window?")) {
if (response.html_url && confirm('Created a gist at ' + response.html_url + ' Would you like to open it in a new window?')) {
window.open( response.html_url, '_blank' );
}
});
@ -130,14 +130,14 @@ var run = function() {
$('#copyOver').click(function(){
var target = prompt(
"To which other browser-solidity instance do you want to copy over all files?",
"https://ethereum.github.io/browser-solidity/"
'To which other browser-solidity instance do you want to copy over all files?',
'https://ethereum.github.io/browser-solidity/'
);
if (target === null)
return;
var files = editor.packageFiles();
var iframe = $('<iframe/>', {src: target, style: "display:none;", load: function() {
this.contentWindow.postMessage(["loadFiles", files], "*");
var iframe = $('<iframe/>', {src: target, style: 'display:none;', load: function() {
this.contentWindow.postMessage(['loadFiles', files], '*');
}}).appendTo('body');
});
@ -150,7 +150,7 @@ var run = function() {
editor.newFile();
updateFiles();
$filesEl.animate({left: Math.max( (0 - activeFilePos() + (FILE_SCROLL_DELTA/2)), 0)+ "px"}, "slow", function(){
$filesEl.animate({left: Math.max( (0 - activeFilePos() + (FILE_SCROLL_DELTA/2)), 0)+ 'px'}, 'slow', function(){
reAdjust();
});
});
@ -176,7 +176,7 @@ var run = function() {
$fileNameInputEl.off('blur');
$fileNameInputEl.off('keyup');
if (newName !== originalName && confirm("Are you sure you want to rename: " + originalName + " to " + newName + '?')) {
if (newName !== originalName && confirm('Are you sure you want to rename: ' + originalName + ' to ' + newName + '?')) {
var content = window.localStorage.getItem( utils.fileKey(originalName) );
window.localStorage[utils.fileKey( newName )] = content;
window.localStorage.removeItem( utils.fileKey( originalName) );
@ -194,7 +194,7 @@ var run = function() {
ev.preventDefault();
var name = $(this).parent().find('.name').text();
if (confirm("Are you sure you want to remove: " + name + " from local storage?")) {
if (confirm('Are you sure you want to remove: ' + name + ' from local storage?')) {
window.localStorage.removeItem( utils.fileKey( name ) );
editor.setNextFile(utils.fileKey(name));
updateFiles();
@ -282,20 +282,20 @@ var run = function() {
$scrollerLeft.fadeIn('fast');
} else {
$scrollerLeft.fadeOut('fast');
$filesEl.animate({left: getLeftPosi() + "px"},'slow');
$filesEl.animate({left: getLeftPosi() + 'px'},'slow');
}
}
$scrollerRight.click(function() {
var delta = (getLeftPosi() - FILE_SCROLL_DELTA);
$filesEl.animate({left: delta + "px"},'slow',function(){
$filesEl.animate({left: delta + 'px'},'slow',function(){
reAdjust();
});
});
$scrollerLeft.click(function() {
var delta = Math.min( (getLeftPosi() + FILE_SCROLL_DELTA), 0 );
$filesEl.animate({left: delta + "px"},'slow',function(){
$filesEl.animate({left: delta + 'px'},'slow',function(){
reAdjust();
});
});
@ -309,7 +309,7 @@ var run = function() {
$('option', '#versionSelector').remove();
$.each(soljsonSources, function(i, file) {
if (file) {
var version = file.replace(/soljson-(.*).js/, "$1");
var version = file.replace(/soljson-(.*).js/, '$1');
$('#versionSelector').append(new Option(version, file));
}
});
@ -320,7 +320,7 @@ var run = function() {
// ----------------- resizeable ui ---------------
var EDITOR_SIZE_CACHE_KEY = "editor-size-cache";
var EDITOR_SIZE_CACHE_KEY = 'editor-size-cache';
var dragging = false;
$('#dragbar').mousedown(function(e){
e.preventDefault();
@ -334,15 +334,15 @@ var run = function() {
}).prependTo('body');
$(document).mousemove(function(e){
ghostbar.css("left",e.pageX+2);
ghostbar.css('left',e.pageX+2);
});
});
var $body = $('body');
function setEditorSize (delta) {
$('#righthand-panel').css("width", delta);
$('#editor').css("right", delta);
$('#righthand-panel').css('width', delta);
$('#editor').css('right', delta);
onResize();
}
@ -402,7 +402,7 @@ var run = function() {
// ----------------- compiler ----------------------
function handleGithubCall(root, path, cb) {
$('#output').append($('<div/>').append($('<pre/>').text("Loading github.com/" + root + "/" + path + " ...")));
$('#output').append($('<div/>').append($('<pre/>').text('Loading github.com/' + root + '/' + path + ' ...')));
return $.getJSON('https://api.github.com/repos/' + root + '/contents/' + path, cb);
}
@ -413,7 +413,7 @@ var run = function() {
}
var loadVersion = function(version) {
setVersionText("(loading)");
setVersionText('(loading)');
queryParams.update({version: version});
var isFirefox = typeof InstallTrigger !== 'undefined';
if (document.location.protocol !== 'file:' && Worker !== undefined && isFirefox) {
@ -427,7 +427,7 @@ var run = function() {
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'https://ethereum.github.io/solc-bin/bin/' + version;
document.getElementsByTagName("head")[0].appendChild(newScript);
document.getElementsByTagName('head')[0].appendChild(newScript);
var check = window.setInterval(function() {
if (!Module) return;
window.clearInterval(check);

@ -20,7 +20,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
function onChange() {
var input = editor.getValue();
if (input === "") {
if (input === '') {
editor.setCacheFileContent('');
return;
}
@ -72,17 +72,17 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
var missingInputsCallback = Module.Runtime.addFunction(function(path, contents, error) {
missingInputs.push(Module.Pointer_stringify(path));
});
var compileInternal = Module.cwrap("compileJSONCallback", "string", ["string", "number", "number"]);
var compileInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']);
compile = function(input, optimize) {
missingInputs.length = 0;
return compileInternal(input, optimize, missingInputsCallback);
};
} else if ('_compileJSONMulti' in Module) {
compilerAcceptsMultipleFiles = true;
compile = Module.cwrap("compileJSONMulti", "string", ["string", "number"]);
compile = Module.cwrap('compileJSONMulti', 'string', ['string', 'number']);
} else {
compilerAcceptsMultipleFiles = false;
compile = Module.cwrap("compileJSON", "string", ["string", "number"]);
compile = Module.cwrap('compileJSON', 'string', ['string', 'number']);
}
compileJSON = function(source, optimize, cb) {
try {
@ -92,7 +92,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
}
compilationFinished(result, missingInputs);
};
setVersionText(Module.cwrap("version", "string", [])());
setVersionText(Module.cwrap('version', 'string', [])());
}
previousInput = '';
onChange();
@ -191,13 +191,13 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
gatherImports(files, importHints, cb);
}
else
cb(null, "Unable to import \"" + m + "\"");
cb(null, 'Unable to import "' + m + '"');
}).fail(function(){
cb(null, "Unable to import \"" + m + "\"");
cb(null, 'Unable to import "' + m + '"');
});
return;
} else {
cb(null, "Unable to import \"" + m + "\"");
cb(null, 'Unable to import "' + m + '"');
return;
}
}

@ -73,7 +73,7 @@ function Editor(loadingFromGist) {
session.setUseWrapMode(document.querySelector('#editorWrap').checked);
if(session.getUseWrapMode()) {
var characterWidth = editor.renderer.characterWidth;
var contentWidth = editor.container.ownerDocument.getElementsByClassName("ace_scroller")[0].clientWidth;
var contentWidth = editor.container.ownerDocument.getElementsByClassName('ace_scroller')[0].clientWidth;
if(contentWidth > 0) {
session.setWrapLimit(parseInt(contentWidth / characterWidth, 10));
@ -107,7 +107,7 @@ function Editor(loadingFromGist) {
};
function newEditorSession(filekey) {
var s = new ace.EditSession(window.localStorage[filekey], "ace/mode/javascript")
var s = new ace.EditSession(window.localStorage[filekey], 'ace/mode/javascript')
s.setUndoManager(new ace.UndoManager());
s.setTabSize(4);
s.setUseSoftTabs(true);
@ -140,7 +140,7 @@ function Editor(loadingFromGist) {
var SOL_CACHE_UNTITLED = utils.getCacheFilePrefix() + 'Untitled';
var SOL_CACHE_FILE = null;
var editor = ace.edit("input");
var editor = ace.edit('input');
var sessions = {};
setupStuff(this.getFiles());

@ -6,7 +6,7 @@ function handleLoad(cb) {
if (typeof params['gist'] !== undefined) {
var gistId;
if (params['gist'] === '') {
var str = prompt("Enter the URL or ID of the Gist you would like to load.");
var str = prompt('Enter the URL or ID of the Gist you would like to load.');
if (str !== '') {
gistId = getGistId( str );
loadingFromGist = !!gistId;

@ -4,14 +4,14 @@ function getQueryParams() {
if (window.location.search.length > 0) {
// use legacy query params instead of hash
window.location.hash = window.location.search.substr(1);
window.location.search = "";
window.location.search = '';
}
var params = {};
var parts = qs.split("&");
var parts = qs.split('&');
for (var x in parts) {
var keyValue = parts[x].split("=");
if (keyValue[0] !== "") params[keyValue[0]] = keyValue[1];
var keyValue = parts[x].split('=');
if (keyValue[0] !== '') params[keyValue[0]] = keyValue[1];
}
return params;
}
@ -22,10 +22,10 @@ function updateQueryParams(params) {
for (var x in keys) {
currentParams[keys[x]] = params[keys[x]];
}
var queryString = "#";
var queryString = '#';
var updatedKeys = Object.keys(currentParams);
for( var y in updatedKeys) {
queryString += updatedKeys[y] + "=" + currentParams[updatedKeys[y]] + "&";
queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&';
}
window.location.hash = queryString.slice(0, -1);
}

@ -13,7 +13,7 @@ function Renderer(editor, compiler, updateFiles) {
// Forcing all of this setup into its own scope.
(function(){
function executionContextChange (ev) {
if (ev.target.value === 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) {
if (ev.target.value === 'web3' && !confirm('Are you sure you want to connect to a local ethereum node?') ) {
$vmToggle.get(0).checked = true;
executionContext = 'vm';
} else {
@ -50,7 +50,7 @@ function Renderer(editor, compiler, updateFiles) {
function renderError(message) {
var type = utils.errortype(message);
var $pre = $("<pre />").text(message);
var $pre = $('<pre />').text(message);
var $error = $('<div class="sol ' + type + '"><div class="close"><i class="fa fa-close"></i></div></div>').prepend($pre);
$('#output').append( $error );
var err = message.match(/^([^:]*):([0-9]*):(([0-9]*):)? /);
@ -228,30 +228,30 @@ function Renderer(editor, compiler, updateFiles) {
};
function gethDeploy(contractName, jsonInterface, bytecode){
var code = "";
var code = '';
var funABI = getConstructorInterface(JSON.parse(jsonInterface));
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(" + jsonInterface.replace("\n","") + ");"
+"\nvar " + contractName + " = " + contractName + "Contract.new(";
code += 'var ' + contractName + 'Contract = web3.eth.contract(' + jsonInterface.replace('\n','') + ');'
+'\nvar ' + contractName + ' = ' + contractName + 'Contract.new(';
funABI.inputs.forEach(function(inp) {
code += "\n " + inp.name + ",";
code += '\n ' + inp.name + ',';
});
code += "\n {"+
"\n from: web3.eth.accounts[0], "+
"\n data: '"+bytecode+"', "+
"\n gas: 3000000"+
"\n }, function(e, contract){"+
"\n console.log(e, contract);"+
"\n if (typeof contract.address !== 'undefined') {"+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" +
"\n }" +
"\n })";
code += '\n {'+
'\n from: web3.eth.accounts[0], '+
'\n data: \''+bytecode+'\', '+
'\n gas: 3000000'+
'\n }, function(e, contract){'+
'\n console.log(e, contract);'+
'\n if (typeof contract.address !== \'undefined\') {'+
'\n console.log(\'Contract mined! address: \' + contract.address + \' transactionHash: \' + contract.transactionHash);' +
'\n }' +
'\n })';
return code;

@ -13,24 +13,24 @@ function StorageHandler(updateFiles) {
function check(key){
chrome.storage.sync.get( key, function(resp){
console.log("comparing to cloud", key, resp);
if (typeof resp[key] !== 'undefined' && obj[key] !== resp[key] && confirm("Overwrite '" + fileNameFromKey(key) + "'? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.")) {
console.log("Overwriting", key );
console.log('comparing to cloud', key, resp);
if (typeof resp[key] !== 'undefined' && obj[key] !== resp[key] && confirm('Overwrite "' + fileNameFromKey(key) + '"? Click Ok to overwrite local file with file from cloud. Cancel will push your local file to the cloud.')) {
console.log('Overwriting', key );
localStorage.setItem( key, resp[key] );
updateFiles();
} else {
console.log( "add to obj", obj, key);
console.log( 'add to obj', obj, key);
obj[key] = localStorage[key];
}
done++;
if (done >= count) 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) {
console.log("checking", y);
console.log('checking', y);
obj[y] = window.localStorage.getItem(y);
if (y.indexOf(utils.getCacheFilePrefix()) !== 0) continue;
count++;

@ -1,5 +1,5 @@
require('es6-shim');
var app = require("./app.js");
var $ = require("jquery");
var app = require('./app.js');
var $ = require('jquery');
$(document).ready(function() { app.run(); });

@ -30,7 +30,7 @@ function UniversalDApp (contracts, options) {
this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511');
this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c');
} else if (options.mode !== 'web3') {
throw new Error("Either VM or Web3 mode must be selected");
throw new Error('Either VM or Web3 mode must be selected');
}
}
@ -50,7 +50,7 @@ UniversalDApp.prototype.getAccounts = function (cb) {
if (!this.vm) {
this.web3.eth.getAccounts(cb);
} else {
if (!this.accounts) return cb("No accounts?");
if (!this.accounts) return cb('No accounts?');
cb(null, Object.keys(this.accounts));
}
@ -68,11 +68,11 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
}
});
} else {
if (!this.accounts) return cb("No accounts?");
if (!this.accounts) return cb('No accounts?');
this.vm.stateManager.getAccountBalance(new Buffer(address, 'hex'), function (err, res) {
if (err) {
cb("Account not found");
cb('Account not found');
} else {
cb(null, new ethJSUtil.BN(res).toString(10));
}
@ -106,7 +106,7 @@ UniversalDApp.prototype.render = function () {
.append( $('<div class="call"/>').text('Call') );
this.$el.append( $('<div class="poweredBy" />')
.html("<a href='http://github.com/d11e9/universal-dapp'>Universal ÐApp</a> powered by The Blockchain") );
.html('<a href="http://github.com/d11e9/universal-dapp">Universal ÐApp</a> powered by The Blockchain') );
this.$el.append( $legend );
return this.$el;
@ -181,7 +181,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$instance.append( $close );
}
var context = self.options.vm ? 'memory' : 'blockchain';
var $title = $('<span class="title"/>').text( contract.name + " at " + (self.options.vm ? '0x' : '') + address.toString('hex') + ' (' + context + ')');
var $title = $('<span class="title"/>').text( contract.name + ' at ' + (self.options.vm ? '0x' : '') + address.toString('hex') + ' (' + context + ')');
$title.click(function(){
$instance.toggleClass('hide');
});
@ -507,10 +507,10 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) {
return cb(null, bytecode);
var m = bytecode.match(/__([^_]{1,36})__/);
if (!m)
return cb("Invalid bytecode format.");
return cb('Invalid bytecode format.');
var libraryName = m[1];
if (!this.getContractByName(libraryName))
return cb("Library " + libraryName + " not found.");
return cb('Library ' + libraryName + ' not found.');
var self = this;
this.deployLibrary(libraryName, function(err, address) {
if (err) return cb(err);
@ -545,7 +545,7 @@ UniversalDApp.prototype.deployLibrary = function(contractName, cb) {
};
UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) {
var address = prompt( "What Address is this contract at in the Blockchain? ie: '0xdeadbeaf...'" );
var address = prompt( 'What Address is this contract at in the Blockchain? ie: 0xdeadbeaf...' );
self.getInstanceInterface(contract, address, $output );
};

@ -1,11 +1,11 @@
// This mainly extracts the provider that might be
// supplied through mist.
var Web3 = require("web3");
var Web3 = require('web3');
if (typeof web3 !== 'undefined')
web3 = new Web3(web3.currentProvider);
else
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
module.exports = web3;

Loading…
Cancel
Save