Commit f738864d authored by chriseth's avatar chriseth

Merge pull request #51 from ethereum/use-standard-js

Use formatting according to 'istandard'
parents 7cd61b16 60ebbee3
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
}); });
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ var Renderer = require('./renderer'); ...@@ -4,7 +4,7 @@ var Renderer = require('./renderer');
var Base64 = require('js-base64').Base64; var Base64 = require('js-base64').Base64;
function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) { function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles) {
var renderer = new Renderer(editor, this, updateFiles); var renderer = new Renderer(editor, this, updateFiles);
var compileJSON; var compileJSON;
...@@ -18,22 +18,25 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -18,22 +18,25 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
var compileTimeout = null; var compileTimeout = null;
function onChange() { function onChange () {
var input = editor.getValue(); var input = editor.getValue();
if (input === "") { if (input === '') {
editor.setCacheFileContent(''); editor.setCacheFileContent('');
return; return;
} }
if (input === previousInput) if (input === previousInput) {
return; return;
}
previousInput = input; previousInput = input;
if (compileTimeout) window.clearTimeout(compileTimeout); if (compileTimeout) {
window.clearTimeout(compileTimeout);
}
compileTimeout = window.setTimeout(compile, 300); compileTimeout = window.setTimeout(compile, 300);
} }
editor.onChangeSetup(onChange); editor.onChangeSetup(onChange);
var compile = function(missingInputs) { var compile = function (missingInputs) {
editor.clearAnnotations(); editor.clearAnnotations();
sourceAnnotations = []; sourceAnnotations = [];
outputField.empty(); outputField.empty();
...@@ -42,7 +45,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -42,7 +45,7 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
var files = {}; var files = {};
files[editor.getCacheFile()] = input; files[editor.getCacheFile()] = input;
gatherImports(files, missingInputs, function(input, error) { gatherImports(files, missingInputs, function (input, error) {
outputField.empty(); outputField.empty();
if (input === null) { if (input === null) {
renderer.error(error); renderer.error(error);
...@@ -54,52 +57,52 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -54,52 +57,52 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
}; };
this.compile = compile; this.compile = compile;
this.addAnnotation = function(annotation) { this.addAnnotation = function (annotation) {
sourceAnnotations[sourceAnnotations.length] = annotation; sourceAnnotations[sourceAnnotations.length] = annotation;
editor.setAnnotations(sourceAnnotations); editor.setAnnotations(sourceAnnotations);
}; };
this.setCompileJSON = function() { this.setCompileJSON = function () {
compileJSON = function(source, optimize) { compilationFinished('{}'); }; compileJSON = function (source, optimize) { compilationFinished('{}'); };
}; };
function onCompilerLoaded(setVersionText) { function onCompilerLoaded (setVersionText) {
if (worker === null) { if (worker === null) {
var compile; var compile;
var missingInputs = []; var missingInputs = [];
if ('_compileJSONCallback' in Module) { if ('_compileJSONCallback' in Module) {
compilerAcceptsMultipleFiles = true; compilerAcceptsMultipleFiles = true;
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 {
var result = compile(source, optimize); var result = compile(source, optimize);
} catch (exception) { } catch (exception) {
result = JSON.stringify({error: 'Uncaught JavaScript exception:\n' + exception}); result = JSON.stringify({ error: 'Uncaught JavaScript exception:\n' + exception });
} }
compilationFinished(result, missingInputs); compilationFinished(result, missingInputs);
}; };
setVersionText(Module.cwrap("version", "string", [])()); setVersionText(Module.cwrap('version', 'string', [])());
} }
previousInput = ''; previousInput = '';
onChange(); onChange();
}; };
this.onCompilerLoaded = onCompilerLoaded; this.onCompilerLoaded = onCompilerLoaded;
function compilationFinished(result, missingInputs) { function compilationFinished (result, missingInputs) {
var data; var data;
var noFatalErrors = true; // ie warnings are ok var noFatalErrors = true; // ie warnings are ok
...@@ -112,26 +115,32 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -112,26 +115,32 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
if (data['error'] !== undefined) { if (data['error'] !== undefined) {
renderer.error(data['error']); renderer.error(data['error']);
if (utils.errortype(data['error']) !== 'warning') noFatalErrors = false; if (utils.errortype(data['error']) !== 'warning') {
noFatalErrors = false;
}
} }
if (data['errors'] != undefined) { if (data['errors'] !== undefined) {
data['errors'].forEach(function(err) { data['errors'].forEach(function (err) {
renderer.error(err); renderer.error(err);
if (utils.errortype(err) !== 'warning') noFatalErrors = false; if (utils.errortype(err) !== 'warning') {
noFatalErrors = false;
}
}); });
} }
if (missingInputs !== undefined && missingInputs.length > 0) if (missingInputs !== undefined && missingInputs.length > 0) {
compile(missingInputs); compile(missingInputs);
else if (noFatalErrors && !hidingRHP()) } else if (noFatalErrors && !hidingRHP()) {
renderer.contracts(data, editor.getValue()); renderer.contracts(data, editor.getValue());
}
} }
this.initializeWorker = function(version, setVersionText) { this.initializeWorker = function (version, setVersionText) {
if (worker !== null) if (worker !== null) {
worker.terminate(); worker.terminate();
}
worker = new Worker('worker.js'); worker = new Worker('worker.js');
worker.addEventListener('message', function(msg) { worker.addEventListener('message', function (msg) {
var data = msg.data; var data = msg.data;
switch (data.cmd) { switch (data.cmd) {
case 'versionLoaded': case 'versionLoaded':
...@@ -144,18 +153,17 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -144,18 +153,17 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
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); });
compileJSON = function(source, optimize) { compileJSON = function (source, optimize) {
worker.postMessage({cmd: 'compile', source: source, optimize: optimize}); worker.postMessage({cmd: 'compile', source: source, optimize: optimize});
}; };
worker.postMessage({cmd: 'loadVersion', data: 'https://ethereum.github.io/solc-bin/bin/' + version}); worker.postMessage({cmd: 'loadVersion', data: 'https://ethereum.github.io/solc-bin/bin/' + version});
}; };
function gatherImports(files, importHints, cb) { function gatherImports (files, importHints, cb) {
importHints = importHints || []; importHints = importHints || [];
if (!compilerAcceptsMultipleFiles) if (!compilerAcceptsMultipleFiles) {
{
cb(files[editor.getCacheFile()]); cb(files[editor.getCacheFile()]);
return; return;
} }
...@@ -166,12 +174,15 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -166,12 +174,15 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
reloop = false; reloop = false;
for (var fileName in files) { for (var fileName in files) {
var match; var match;
while (match = importRegex.exec(files[fileName])) while (match = importRegex.exec(files[fileName])) {
importHints.push(match[1]); importHints.push(match[1]);
}
} }
while (importHints.length > 0) { while (importHints.length > 0) {
var m = importHints.pop(); var m = importHints.pop();
if (m in files) continue; if (m in files) {
continue;
}
if (editor.hasFile(m)) { if (editor.hasFile(m)) {
files[m] = window.localStorage[utils.fileKey(m)]; files[m] = window.localStorage[utils.fileKey(m)];
reloop = true; reloop = true;
...@@ -182,27 +193,26 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles) ...@@ -182,27 +193,26 @@ function Compiler(editor, handleGithubCall, outputField, hidingRHP, updateFiles)
files[m] = cachedRemoteFiles[m]; files[m] = cachedRemoteFiles[m];
reloop = true; reloop = true;
} else if (githubMatch = /^(https?:\/\/)?(www.)?github.com\/([^\/]*\/[^\/]*)\/(.*)/.exec(m)) { } else if (githubMatch = /^(https?:\/\/)?(www.)?github.com\/([^\/]*\/[^\/]*)\/(.*)/.exec(m)) {
handleGithubCall(githubMatch[3], githubMatch[4], function(result) { handleGithubCall(githubMatch[3], githubMatch[4], function (result) {
if ('content' in result) if ('content' in result) {
{
var content = Base64.decode(result.content); var content = Base64.decode(result.content);
cachedRemoteFiles[m] = content; cachedRemoteFiles[m] = content;
files[m] = content; files[m] = content;
gatherImports(files, importHints, cb); gatherImports(files, importHints, cb);
} else {
cb(null, 'Unable to import "' + m + '"');
} }
else }).fail(function () {
cb(null, "Unable to import \"" + m + "\""); cb(null, 'Unable to import "' + m + '"');
}).fail(function(){
cb(null, "Unable to import \"" + m + "\"");
}); });
return; return;
} else { } else {
cb(null, "Unable to import \"" + m + "\""); cb(null, 'Unable to import "' + m + '"');
return; return;
} }
} }
} while (reloop); } while (reloop);
cb(JSON.stringify({'sources':files})); cb(JSON.stringify({ 'sources': files }));
} }
} }
......
...@@ -3,51 +3,52 @@ var utils = require('./utils'); ...@@ -3,51 +3,52 @@ var utils = require('./utils');
var ace = require('brace'); var ace = require('brace');
require('../mode-solidity.js'); require('../mode-solidity.js');
function Editor(loadingFromGist) { function Editor (loadingFromGist) {
this.newFile = function() { this.newFile = function () {
untitledCount = ''; untitledCount = '';
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) {
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
}
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
sessions[SOL_CACHE_FILE] = null; sessions[SOL_CACHE_FILE] = null;
this.setCacheFileContent(''); this.setCacheFileContent('');
}; };
this.setCacheFileContent = function(content) { this.setCacheFileContent = function (content) {
window.localStorage.setItem(SOL_CACHE_FILE, content); window.localStorage.setItem(SOL_CACHE_FILE, content);
}; };
this.setCacheFile = function(cacheFile) { this.setCacheFile = function (cacheFile) {
SOL_CACHE_FILE = utils.fileKey(cacheFile); SOL_CACHE_FILE = utils.fileKey(cacheFile);
}; };
this.getCacheFile = function() { this.getCacheFile = function () {
return utils.fileNameFromKey(SOL_CACHE_FILE); return utils.fileNameFromKey(SOL_CACHE_FILE);
}; };
this.cacheFileIsPresent = function() { this.cacheFileIsPresent = function () {
return !!SOL_CACHE_FILE; return !!SOL_CACHE_FILE;
}; };
this.setNextFile = function(fileKey) { this.setNextFile = function (fileKey) {
var index = this.getFiles().indexOf( fileKey ); var index = this.getFiles().indexOf(fileKey);
this.setCacheFile(this.getFiles()[ Math.max(0, index - 1)]); this.setCacheFile(this.getFiles()[ Math.max(0, index - 1) ]);
}; };
this.resetSession = function() { this.resetSession = function () {
editor.setSession( sessions[SOL_CACHE_FILE] ); editor.setSession(sessions[SOL_CACHE_FILE]);
editor.focus(); editor.focus();
}; };
this.hasFile = function(name) { this.hasFile = function (name) {
return this.getFiles().indexOf(utils.fileKey(name)) !== -1 return this.getFiles().indexOf(utils.fileKey(name)) !== -1
}; };
this.getFiles = function() { this.getFiles = function () {
var files = []; var files = [];
for (var f in localStorage ) { for (var f in localStorage) {
if (f.indexOf( utils.getCacheFilePrefix(), 0 ) === 0) { if (f.indexOf(utils.getCacheFilePrefix(), 0) === 0) {
files.push(f); files.push(f);
if (!sessions[f]) sessions[f] = newEditorSession(f); if (!sessions[f]) sessions[f] = newEditorSession(f);
} }
...@@ -55,7 +56,7 @@ function Editor(loadingFromGist) { ...@@ -55,7 +56,7 @@ function Editor(loadingFromGist) {
return files; return files;
} }
this.packageFiles = function() { this.packageFiles = function () {
var files = {}; var files = {};
var filesArr = this.getFiles(); var filesArr = this.getFiles();
...@@ -67,47 +68,47 @@ function Editor(loadingFromGist) { ...@@ -67,47 +68,47 @@ function Editor(loadingFromGist) {
return files; return files;
}; };
this.resize = function() { this.resize = function () {
editor.resize(); editor.resize();
var session = editor.getSession(); var session = editor.getSession();
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));
} }
} }
}; };
this.getValue = function() { this.getValue = function () {
return editor.getValue(); return editor.getValue();
}; };
this.clearAnnotations = function() { this.clearAnnotations = function () {
editor.getSession().clearAnnotations(); editor.getSession().clearAnnotations();
}; };
this.setAnnotations = function(sourceAnnotations) { this.setAnnotations = function (sourceAnnotations) {
editor.getSession().setAnnotations(sourceAnnotations); editor.getSession().setAnnotations(sourceAnnotations);
}; };
this.onChangeSetup = function(onChange) { this.onChangeSetup = function (onChange) {
editor.getSession().on('change', onChange); editor.getSession().on('change', onChange);
editor.on('changeSession', function(){ editor.on('changeSession', function () {
editor.getSession().on('change', onChange); editor.getSession().on('change', onChange);
onChange(); onChange();
}) })
}; };
this.handleErrorClick = function(errLine, errCol) { this.handleErrorClick = function (errLine, errCol) {
editor.focus(); editor.focus();
editor.gotoLine(errLine + 1, errCol - 1, true); editor.gotoLine(errLine + 1, errCol - 1, true);
}; };
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);
...@@ -115,13 +116,14 @@ function Editor(loadingFromGist) { ...@@ -115,13 +116,14 @@ function Editor(loadingFromGist) {
return s; return s;
} }
function setupStuff(files) { function setupStuff (files) {
var untitledCount = ''; var untitledCount = '';
if (!files.length || window.localStorage['sol-cache']) { if (!files.length || window.localStorage['sol-cache']) {
if(loadingFromGist) return; if (loadingFromGist) return;
// Backwards-compatibility // Backwards-compatibility
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) {
untitledCount = (untitledCount - 0) + 1; untitledCount = (untitledCount - 0) + 1;
}
SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount;
window.localStorage[SOL_CACHE_FILE] = window.localStorage['sol-cache'] || BALLOT_EXAMPLE; window.localStorage[SOL_CACHE_FILE] = window.localStorage['sol-cache'] || BALLOT_EXAMPLE;
window.localStorage.removeItem('sol-cache'); window.localStorage.removeItem('sol-cache');
...@@ -133,14 +135,14 @@ function Editor(loadingFromGist) { ...@@ -133,14 +135,14 @@ function Editor(loadingFromGist) {
sessions[files[x]] = newEditorSession(files[x]) sessions[files[x]] = newEditorSession(files[x])
} }
editor.setSession( sessions[SOL_CACHE_FILE] ); editor.setSession(sessions[SOL_CACHE_FILE]);
editor.resize(true); editor.resize(true);
} }
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());
......
var queryParams = require('./query-params'); var queryParams = require('./query-params');
function handleLoad(cb) { function handleLoad (cb) {
var params = queryParams.get(); var params = queryParams.get();
var loadingFromGist = false; var loadingFromGist = false;
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;
} }
} else { } else {
gistId = params['gist']; gistId = params['gist'];
loadingFromGist = !!gistId; loadingFromGist = !!gistId;
} }
if (loadingFromGist) cb(gistId); if (loadingFromGist) {
cb(gistId);
}
} }
return loadingFromGist; return loadingFromGist;
} }
function getGistId(str) { function getGistId (str) {
var idr = /[0-9A-Fa-f]{8,}/; var idr = /[0-9A-Fa-f]{8,}/;
var match = idr.exec(str); var match = idr.exec(str);
return match ? match[0] : null; return match ? match[0] : null;
......
function getQueryParams() { function getQueryParams () {
var qs = window.location.hash.substr(1); var qs = window.location.hash.substr(1);
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;
} }
function updateQueryParams(params) { function updateQueryParams (params) {
var currentParams = getQueryParams(); var currentParams = getQueryParams();
var keys = Object.keys(params); var keys = Object.keys(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);
} }
......
This diff is collapsed.
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) return; if (typeof chrome === 'undefined' || !chrome || !chrome.storage || !chrome.storage.sync) {
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) {
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) {
console.log( "updated cloud files with: ", obj, this, arguments); chrome.storage.sync.set(obj, function () {
}) 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++;
check(y); check(y);
} }
......
var SOL_CACHE_FILE_PREFIX = 'sol-cache-file-'; var SOL_CACHE_FILE_PREFIX = 'sol-cache-file-';
function getCacheFilePrefix() { function getCacheFilePrefix () {
return SOL_CACHE_FILE_PREFIX; return SOL_CACHE_FILE_PREFIX;
} }
function fileKey( name ) { function fileKey (name) {
return getCacheFilePrefix() + name; return getCacheFilePrefix() + name;
} }
function fileNameFromKey(key) { function fileNameFromKey (key) {
return key.replace( getCacheFilePrefix(), '' ); return key.replace(getCacheFilePrefix(), '');
} }
function errortype(message) { function errortype (message) {
return message.match(/^.*:[0-9]*:[0-9]* Warning: /) ? 'warning' : 'error'; return message.match(/^.*:[0-9]*:[0-9]* Warning: /) ? 'warning' : 'error';
} }
......
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 \ No newline at end of file
This diff is collapsed.
// 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