Skip to content

Commit

Permalink
Standard: use single quotes for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jun 5, 2016
1 parent 0bbbb23 commit 4fb1947
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 80 deletions.
2 changes: 1 addition & 1 deletion background.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
50 changes: 25 additions & 25 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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',
Expand All @@ -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' );
}
});
Expand All @@ -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');
});

Expand All @@ -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();
});
});
Expand All @@ -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) );
Expand All @@ -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();
Expand Down Expand Up @@ -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();
});
});
Expand All @@ -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));
}
});
Expand All @@ -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();
Expand All @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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) {
Expand All @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/app/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)

function onChange() {
var input = editor.getValue();
if (input === "") {
if (input === '') {
editor.setCacheFileContent('');
return;
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/app/gist-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/app/query-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down
34 changes: 17 additions & 17 deletions src/app/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]*):)? /);
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 4fb1947

Please sign in to comment.