Commit 4fb1947c authored by Alex Beregszaszi's avatar Alex Beregszaszi

Standard: use single quotes for strings

parent 0bbbb237
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) {
......
...@@ -12,8 +12,8 @@ var Compiler = require('./app/compiler'); ...@@ -12,8 +12,8 @@ var Compiler = require('./app/compiler');
// parent will send the message upon the "load" event. // parent will send the message upon the "load" event.
var filesToLoad = null; var filesToLoad = null;
var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later var loadFilesCallback = function(files) { filesToLoad = files; }; // will be replaced later
window.addEventListener("message", function(ev) { window.addEventListener('message', function(ev) {
if (typeof ev.data === typeof [] && ev.data[0] === "loadFiles") { if (typeof ev.data === typeof [] && ev.data[0] === 'loadFiles') {
loadFilesCallback(ev.data[1]); loadFilesCallback(ev.data[1]);
} }
}, false); }, false);
...@@ -47,7 +47,7 @@ var run = function() { ...@@ -47,7 +47,7 @@ var run = function() {
// ------------------ query params (hash) ---------------- // ------------------ query params (hash) ----------------
function syncQueryParams() { function syncQueryParams() {
$('#optimize').attr( 'checked', (queryParams.get().optimize === "true") ); $('#optimize').attr( 'checked', (queryParams.get().optimize === 'true') );
} }
window.onhashchange = syncQueryParams; window.onhashchange = syncQueryParams;
...@@ -64,7 +64,7 @@ var run = function() { ...@@ -64,7 +64,7 @@ var run = function() {
success: function(response) { success: function(response) {
if (response.data) { if (response.data) {
if (!response.data.files) { if (!response.data.files) {
alert( "Gist load error: " + response.data.message ); alert( 'Gist load error: ' + response.data.message );
return; return;
} }
loadFiles(response.data.files); loadFiles(response.data.files);
...@@ -107,10 +107,10 @@ var run = function() { ...@@ -107,10 +107,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=';
$.ajax({ $.ajax({
url: 'https://api.github.com/gists', url: 'https://api.github.com/gists',
...@@ -121,7 +121,7 @@ var run = function() { ...@@ -121,7 +121,7 @@ var run = function() {
files: files files: files
}) })
}).done(function(response) { }).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' ); window.open( response.html_url, '_blank' );
} }
}); });
...@@ -130,14 +130,14 @@ var run = function() { ...@@ -130,14 +130,14 @@ var run = function() {
$('#copyOver').click(function(){ $('#copyOver').click(function(){
var target = prompt( var target = prompt(
"To which other browser-solidity instance do you want to copy over all files?", 'To which other browser-solidity instance do you want to copy over all files?',
"https://ethereum.github.io/browser-solidity/" 'https://ethereum.github.io/browser-solidity/'
); );
if (target === null) if (target === null)
return; return;
var files = editor.packageFiles(); var files = editor.packageFiles();
var iframe = $('<iframe/>', {src: target, style: "display:none;", load: function() { var iframe = $('<iframe/>', {src: target, style: 'display:none;', load: function() {
this.contentWindow.postMessage(["loadFiles", files], "*"); this.contentWindow.postMessage(['loadFiles', files], '*');
}}).appendTo('body'); }}).appendTo('body');
}); });
...@@ -150,7 +150,7 @@ var run = function() { ...@@ -150,7 +150,7 @@ var run = function() {
editor.newFile(); editor.newFile();
updateFiles(); 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(); reAdjust();
}); });
}); });
...@@ -176,7 +176,7 @@ var run = function() { ...@@ -176,7 +176,7 @@ var run = function() {
$fileNameInputEl.off('blur'); $fileNameInputEl.off('blur');
$fileNameInputEl.off('keyup'); $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) ); var content = window.localStorage.getItem( utils.fileKey(originalName) );
window.localStorage[utils.fileKey( newName )] = content; window.localStorage[utils.fileKey( newName )] = content;
window.localStorage.removeItem( utils.fileKey( originalName) ); window.localStorage.removeItem( utils.fileKey( originalName) );
...@@ -194,7 +194,7 @@ var run = function() { ...@@ -194,7 +194,7 @@ var run = function() {
ev.preventDefault(); ev.preventDefault();
var name = $(this).parent().find('.name').text(); 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 ) ); window.localStorage.removeItem( utils.fileKey( name ) );
editor.setNextFile(utils.fileKey(name)); editor.setNextFile(utils.fileKey(name));
updateFiles(); updateFiles();
...@@ -282,20 +282,20 @@ var run = function() { ...@@ -282,20 +282,20 @@ var run = function() {
$scrollerLeft.fadeIn('fast'); $scrollerLeft.fadeIn('fast');
} else { } else {
$scrollerLeft.fadeOut('fast'); $scrollerLeft.fadeOut('fast');
$filesEl.animate({left: getLeftPosi() + "px"},'slow'); $filesEl.animate({left: getLeftPosi() + 'px'},'slow');
} }
} }
$scrollerRight.click(function() { $scrollerRight.click(function() {
var delta = (getLeftPosi() - FILE_SCROLL_DELTA); var delta = (getLeftPosi() - FILE_SCROLL_DELTA);
$filesEl.animate({left: delta + "px"},'slow',function(){ $filesEl.animate({left: delta + 'px'},'slow',function(){
reAdjust(); reAdjust();
}); });
}); });
$scrollerLeft.click(function() { $scrollerLeft.click(function() {
var delta = Math.min( (getLeftPosi() + FILE_SCROLL_DELTA), 0 ); var delta = Math.min( (getLeftPosi() + FILE_SCROLL_DELTA), 0 );
$filesEl.animate({left: delta + "px"},'slow',function(){ $filesEl.animate({left: delta + 'px'},'slow',function(){
reAdjust(); reAdjust();
}); });
}); });
...@@ -309,7 +309,7 @@ var run = function() { ...@@ -309,7 +309,7 @@ var run = function() {
$('option', '#versionSelector').remove(); $('option', '#versionSelector').remove();
$.each(soljsonSources, function(i, file) { $.each(soljsonSources, function(i, file) {
if (file) { if (file) {
var version = file.replace(/soljson-(.*).js/, "$1"); var version = file.replace(/soljson-(.*).js/, '$1');
$('#versionSelector').append(new Option(version, file)); $('#versionSelector').append(new Option(version, file));
} }
}); });
...@@ -320,7 +320,7 @@ var run = function() { ...@@ -320,7 +320,7 @@ var run = function() {
// ----------------- resizeable ui --------------- // ----------------- resizeable ui ---------------
var EDITOR_SIZE_CACHE_KEY = "editor-size-cache"; var EDITOR_SIZE_CACHE_KEY = 'editor-size-cache';
var dragging = false; var dragging = false;
$('#dragbar').mousedown(function(e){ $('#dragbar').mousedown(function(e){
e.preventDefault(); e.preventDefault();
...@@ -334,15 +334,15 @@ var run = function() { ...@@ -334,15 +334,15 @@ var run = function() {
}).prependTo('body'); }).prependTo('body');
$(document).mousemove(function(e){ $(document).mousemove(function(e){
ghostbar.css("left",e.pageX+2); ghostbar.css('left',e.pageX+2);
}); });
}); });
var $body = $('body'); var $body = $('body');
function setEditorSize (delta) { function setEditorSize (delta) {
$('#righthand-panel').css("width", delta); $('#righthand-panel').css('width', delta);
$('#editor').css("right", delta); $('#editor').css('right', delta);
onResize(); onResize();
} }
...@@ -402,7 +402,7 @@ var run = function() { ...@@ -402,7 +402,7 @@ var run = function() {
// ----------------- compiler ---------------------- // ----------------- compiler ----------------------
function handleGithubCall(root, path, cb) { 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); return $.getJSON('https://api.github.com/repos/' + root + '/contents/' + path, cb);
} }
...@@ -413,7 +413,7 @@ var run = function() { ...@@ -413,7 +413,7 @@ var run = function() {
} }
var loadVersion = function(version) { var loadVersion = function(version) {
setVersionText("(loading)"); setVersionText('(loading)');
queryParams.update({version: version}); queryParams.update({version: version});
var isFirefox = typeof InstallTrigger !== 'undefined'; var isFirefox = typeof InstallTrigger !== 'undefined';
if (document.location.protocol !== 'file:' && Worker !== undefined && isFirefox) { if (document.location.protocol !== 'file:' && Worker !== undefined && isFirefox) {
...@@ -427,7 +427,7 @@ var run = function() { ...@@ -427,7 +427,7 @@ var run = function() {
var newScript = document.createElement('script'); var newScript = document.createElement('script');
newScript.type = 'text/javascript'; newScript.type = 'text/javascript';
newScript.src = 'https://ethereum.github.io/solc-bin/bin/' + version; 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() { var check = window.setInterval(function() {
if (!Module) return; if (!Module) return;
window.clearInterval(check); window.clearInterval(check);
......
...@@ -20,7 +20,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -20,7 +20,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
function onChange() { function onChange() {
var input = editor.getValue(); var input = editor.getValue();
if (input === "") { if (input === '') {
editor.setCacheFileContent(''); editor.setCacheFileContent('');
return; return;
} }
...@@ -72,17 +72,17 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -72,17 +72,17 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
var missingInputsCallback = Module.Runtime.addFunction(function(path, contents, error) { var missingInputsCallback = Module.Runtime.addFunction(function(path, contents, error) {
missingInputs.push(Module.Pointer_stringify(path)); 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) { compile = function(input, optimize) {
missingInputs.length = 0; missingInputs.length = 0;
return compileInternal(input, optimize, missingInputsCallback); return compileInternal(input, optimize, missingInputsCallback);
}; };
} else if ('_compileJSONMulti' in Module) { } else if ('_compileJSONMulti' in Module) {
compilerAcceptsMultipleFiles = true; compilerAcceptsMultipleFiles = true;
compile = Module.cwrap("compileJSONMulti", "string", ["string", "number"]); compile = Module.cwrap('compileJSONMulti', 'string', ['string', 'number']);
} else { } else {
compilerAcceptsMultipleFiles = false; compilerAcceptsMultipleFiles = false;
compile = Module.cwrap("compileJSON", "string", ["string", "number"]); compile = Module.cwrap('compileJSON', 'string', ['string', 'number']);
} }
compileJSON = function(source, optimize, cb) { compileJSON = function(source, optimize, cb) {
try { try {
...@@ -92,7 +92,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -92,7 +92,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
} }
compilationFinished(result, missingInputs); compilationFinished(result, missingInputs);
}; };
setVersionText(Module.cwrap("version", "string", [])()); setVersionText(Module.cwrap('version', 'string', [])());
} }
previousInput = ''; previousInput = '';
onChange(); onChange();
...@@ -191,13 +191,13 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -191,13 +191,13 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
gatherImports(files, importHints, cb); gatherImports(files, importHints, cb);
} }
else else
cb(null, "Unable to import \"" + m + "\""); cb(null, 'Unable to import "' + m + '"');
}).fail(function(){ }).fail(function(){
cb(null, "Unable to import \"" + m + "\""); cb(null, 'Unable to import "' + m + '"');
}); });
return; return;
} else { } else {
cb(null, "Unable to import \"" + m + "\""); cb(null, 'Unable to import "' + m + '"');
return; return;
} }
} }
......
...@@ -73,7 +73,7 @@ function Editor(loadingFromGist) { ...@@ -73,7 +73,7 @@ function Editor(loadingFromGist) {
session.setUseWrapMode(document.querySelector('#editorWrap').checked); session.setUseWrapMode(document.querySelector('#editorWrap').checked);
if(session.getUseWrapMode()) { if(session.getUseWrapMode()) {
var characterWidth = editor.renderer.characterWidth; 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) { if(contentWidth > 0) {
session.setWrapLimit(parseInt(contentWidth / characterWidth, 10)); session.setWrapLimit(parseInt(contentWidth / characterWidth, 10));
...@@ -107,7 +107,7 @@ function Editor(loadingFromGist) { ...@@ -107,7 +107,7 @@ function Editor(loadingFromGist) {
}; };
function newEditorSession(filekey) { 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.setUndoManager(new ace.UndoManager());
s.setTabSize(4); s.setTabSize(4);
s.setUseSoftTabs(true); s.setUseSoftTabs(true);
...@@ -140,7 +140,7 @@ function Editor(loadingFromGist) { ...@@ -140,7 +140,7 @@ function Editor(loadingFromGist) {
var SOL_CACHE_UNTITLED = utils.getCacheFilePrefix() + 'Untitled'; var SOL_CACHE_UNTITLED = utils.getCacheFilePrefix() + 'Untitled';
var SOL_CACHE_FILE = null; var SOL_CACHE_FILE = null;
var editor = ace.edit("input"); var editor = ace.edit('input');
var sessions = {}; var sessions = {};
setupStuff(this.getFiles()); setupStuff(this.getFiles());
......
...@@ -6,7 +6,7 @@ function handleLoad(cb) { ...@@ -6,7 +6,7 @@ function handleLoad(cb) {
if (typeof params['gist'] !== undefined) { if (typeof params['gist'] !== undefined) {
var gistId; var gistId;
if (params['gist'] === '') { 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 !== '') { if (str !== '') {
gistId = getGistId( str ); gistId = getGistId( str );
loadingFromGist = !!gistId; loadingFromGist = !!gistId;
......
...@@ -4,14 +4,14 @@ function getQueryParams() { ...@@ -4,14 +4,14 @@ function getQueryParams() {
if (window.location.search.length > 0) { if (window.location.search.length > 0) {
// use legacy query params instead of hash // use legacy query params instead of hash
window.location.hash = window.location.search.substr(1); window.location.hash = window.location.search.substr(1);
window.location.search = ""; window.location.search = '';
} }
var params = {}; var params = {};
var parts = qs.split("&"); var parts = qs.split('&');
for (var x in parts) { for (var x in parts) {
var keyValue = parts[x].split("="); var keyValue = parts[x].split('=');
if (keyValue[0] !== "") params[keyValue[0]] = keyValue[1]; if (keyValue[0] !== '') params[keyValue[0]] = keyValue[1];
} }
return params; return params;
} }
...@@ -22,10 +22,10 @@ function updateQueryParams(params) { ...@@ -22,10 +22,10 @@ function updateQueryParams(params) {
for (var x in keys) { for (var x in keys) {
currentParams[keys[x]] = params[keys[x]]; currentParams[keys[x]] = params[keys[x]];
} }
var queryString = "#"; var queryString = '#';
var updatedKeys = Object.keys(currentParams); var updatedKeys = Object.keys(currentParams);
for( var y in updatedKeys) { for( var y in updatedKeys) {
queryString += updatedKeys[y] + "=" + currentParams[updatedKeys[y]] + "&"; queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&';
} }
window.location.hash = queryString.slice(0, -1); window.location.hash = queryString.slice(0, -1);
} }
......
...@@ -13,7 +13,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -13,7 +13,7 @@ function Renderer(editor, compiler, updateFiles) {
// Forcing all of this setup into its own scope. // Forcing all of this setup into its own scope.
(function(){ (function(){
function executionContextChange (ev) { 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; $vmToggle.get(0).checked = true;
executionContext = 'vm'; executionContext = 'vm';
} else { } else {
...@@ -50,7 +50,7 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -50,7 +50,7 @@ function Renderer(editor, compiler, updateFiles) {
function renderError(message) { function renderError(message) {
var type = utils.errortype(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); var $error = $('<div class="sol ' + type + '"><div class="close"><i class="fa fa-close"></i></div></div>').prepend($pre);
$('#output').append( $error ); $('#output').append( $error );
var err = message.match(/^([^:]*):([0-9]*):(([0-9]*):)? /); var err = message.match(/^([^:]*):([0-9]*):(([0-9]*):)? /);
...@@ -228,30 +228,30 @@ function Renderer(editor, compiler, updateFiles) { ...@@ -228,30 +228,30 @@ function Renderer(editor, compiler, updateFiles) {
}; };
function gethDeploy(contractName, jsonInterface, bytecode){ function gethDeploy(contractName, jsonInterface, bytecode){
var code = ""; var code = '';
var funABI = getConstructorInterface(JSON.parse(jsonInterface)); 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(" + jsonInterface.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) {
code += "\n " + inp.name + ","; code += '\n ' + inp.name + ',';
}); });
code += "\n {"+ code += '\n {'+
"\n from: web3.eth.accounts[0], "+ '\n from: web3.eth.accounts[0], '+
"\n data: '"+bytecode+"', "+ '\n data: \''+bytecode+'\', '+
"\n gas: 3000000"+ '\n gas: 3000000'+
"\n }, function(e, contract){"+ '\n }, function(e, contract){'+
"\n console.log(e, contract);"+ '\n console.log(e, contract);'+
"\n if (typeof contract.address !== 'undefined') {"+ '\n if (typeof contract.address !== \'undefined\') {'+
"\n console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);" + '\n console.log(\'Contract mined! address: \' + contract.address + \' transactionHash: \' + contract.transactionHash);' +
"\n }" + '\n }' +
"\n })"; '\n })';
return code; return code;
......
...@@ -13,24 +13,24 @@ function StorageHandler(updateFiles) { ...@@ -13,24 +13,24 @@ function StorageHandler(updateFiles) {
function check(key){ function check(key){
chrome.storage.sync.get( key, function(resp){ chrome.storage.sync.get( key, function(resp){
console.log("comparing to cloud", key, 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.")) { 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('Overwriting', key );
localStorage.setItem( key, resp[key] ); localStorage.setItem( key, resp[key] );
updateFiles(); updateFiles();
} else { } else {
console.log( "add to obj", obj, key); console.log( 'add to obj', obj, key);
obj[key] = localStorage[key]; obj[key] = localStorage[key];
} }
done++; done++;
if (done >= count) chrome.storage.sync.set( obj, function(){ 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) { for (var y in window.localStorage) {
console.log("checking", y); console.log('checking', y);
obj[y] = window.localStorage.getItem(y); obj[y] = window.localStorage.getItem(y);
if (y.indexOf(utils.getCacheFilePrefix()) !== 0) continue; if (y.indexOf(utils.getCacheFilePrefix()) !== 0) continue;
count++; count++;
......
require('es6-shim'); require('es6-shim');
var app = require("./app.js"); var app = require('./app.js');
var $ = require("jquery"); var $ = require('jquery');
$(document).ready(function() { app.run(); }); $(document).ready(function() { app.run(); });
\ No newline at end of file
...@@ -30,7 +30,7 @@ function UniversalDApp (contracts, options) { ...@@ -30,7 +30,7 @@ function UniversalDApp (contracts, options) {
this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511'); this.addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511');
this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c'); this.addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c');
} else if (options.mode !== 'web3') { } 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) { ...@@ -50,7 +50,7 @@ UniversalDApp.prototype.getAccounts = function (cb) {
if (!this.vm) { if (!this.vm) {
this.web3.eth.getAccounts(cb); this.web3.eth.getAccounts(cb);
} else { } else {
if (!this.accounts) return cb("No accounts?"); if (!this.accounts) return cb('No accounts?');
cb(null, Object.keys(this.accounts)); cb(null, Object.keys(this.accounts));
} }
...@@ -68,11 +68,11 @@ UniversalDApp.prototype.getBalance = function (address, cb) { ...@@ -68,11 +68,11 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
} }
}); });
} else { } 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) { this.vm.stateManager.getAccountBalance(new Buffer(address, 'hex'), function (err, res) {
if (err) { if (err) {
cb("Account not found"); cb('Account not found');
} else { } else {
cb(null, new ethJSUtil.BN(res).toString(10)); cb(null, new ethJSUtil.BN(res).toString(10));
} }
...@@ -106,7 +106,7 @@ UniversalDApp.prototype.render = function () { ...@@ -106,7 +106,7 @@ UniversalDApp.prototype.render = function () {
.append( $('<div class="call"/>').text('Call') ); .append( $('<div class="call"/>').text('Call') );
this.$el.append( $('<div class="poweredBy" />') 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 ); this.$el.append( $legend );
return this.$el; return this.$el;
...@@ -181,7 +181,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar ...@@ -181,7 +181,7 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar
$instance.append( $close ); $instance.append( $close );
} }
var context = self.options.vm ? 'memory' : 'blockchain'; 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(){ $title.click(function(){
$instance.toggleClass('hide'); $instance.toggleClass('hide');
}); });
...@@ -507,10 +507,10 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) { ...@@ -507,10 +507,10 @@ UniversalDApp.prototype.linkBytecode = function(contractName, cb) {
return cb(null, bytecode); return cb(null, bytecode);
var m = bytecode.match(/__([^_]{1,36})__/); var m = bytecode.match(/__([^_]{1,36})__/);
if (!m) if (!m)
return cb("Invalid bytecode format."); return cb('Invalid bytecode format.');
var libraryName = m[1]; var libraryName = m[1];
if (!this.getContractByName(libraryName)) if (!this.getContractByName(libraryName))
return cb("Library " + libraryName + " not found."); return cb('Library ' + libraryName + ' not found.');
var self = this; var self = this;
this.deployLibrary(libraryName, function(err, address) { this.deployLibrary(libraryName, function(err, address) {
if (err) return cb(err); if (err) return cb(err);
...@@ -545,7 +545,7 @@ UniversalDApp.prototype.deployLibrary = function(contractName, cb) { ...@@ -545,7 +545,7 @@ UniversalDApp.prototype.deployLibrary = function(contractName, cb) {
}; };
UniversalDApp.prototype.clickContractAt = function ( self, $output, contract ) { 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 ); self.getInstanceInterface(contract, address, $output );
}; };
......
// This mainly extracts the provider that might be // This mainly extracts the provider that might be
// supplied through mist. // supplied through mist.
var Web3 = require("web3"); var Web3 = require('web3');
if (typeof web3 !== 'undefined') if (typeof web3 !== 'undefined')
web3 = new Web3(web3.currentProvider); web3 = new Web3(web3.currentProvider);
else else
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
module.exports = web3; module.exports = web3;
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