Commit c9f4197f authored by chriseth's avatar chriseth

Merge pull request #82 from ethereum/codestyle-formatting-v2

Codestyle formatting (Part 2)
parents 09690338 e50fb57e
language: node_js language: node_js
node_js: node_js:
- stable - stable
script: npm run build script: npm run lint && npm run build
deploy: deploy:
provider: script provider: script
script: ci/deploy_from_travis.sh script: ci/deploy_from_travis.sh
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
"description": "Minimalistic browser-based Solidity IDE", "description": "Minimalistic browser-based Solidity IDE",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "mkdir -p build; browserify src/index.js -o build/app.js" "build": "mkdir -p build; browserify src/index.js -o build/app.js",
"lint": "semistandard"
}, },
"devDependencies": { "devDependencies": {
"brace": "^0.8.0", "brace": "^0.8.0",
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
"ethereumjs-vm": "^1.4.0", "ethereumjs-vm": "^1.4.0",
"jquery": "^2.2.0", "jquery": "^2.2.0",
"js-base64": "^2.1.9", "js-base64": "^2.1.9",
"semistandard": "^7.0.0",
"web3": "^0.15.3", "web3": "^0.15.3",
"webworkify": "^1.2.1" "webworkify": "^1.2.1"
}, },
...@@ -35,5 +37,12 @@ ...@@ -35,5 +37,12 @@
"url": "https://github.com/ethereum/browser-solidity/issues" "url": "https://github.com/ethereum/browser-solidity/issues"
}, },
"homepage": "https://github.com/ethereum/browser-solidity#readme", "homepage": "https://github.com/ethereum/browser-solidity#readme",
"private": true "private": true,
"semistandard": {
"ignore": [
"assets/js/",
"build/",
"src/mode-solidity.js"
]
}
} }
...@@ -7,11 +7,13 @@ module.exports = function (self) { ...@@ -7,11 +7,13 @@ module.exports = function (self) {
var data = e.data; var data = e.data;
switch (data.cmd) { switch (data.cmd) {
case 'loadVersion': case 'loadVersion':
delete Module; delete window.Module;
version = null; version = null;
compileJSON = null; compileJSON = null;
importScripts(data.data); self.importScripts(data.data);
var Module = window.Module;
version = Module.cwrap('version', 'string', []); version = Module.cwrap('version', 'string', []);
if ('_compileJSONCallback' in Module) { if ('_compileJSONCallback' in Module) {
var compileJSONInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']); var compileJSONInternal = Module.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']);
...@@ -26,7 +28,7 @@ module.exports = function (self) { ...@@ -26,7 +28,7 @@ module.exports = function (self) {
} else { } else {
compileJSON = Module.cwrap('compileJSON', 'string', ['string', 'number']); compileJSON = Module.cwrap('compileJSON', 'string', ['string', 'number']);
} }
postMessage({ self.postMessage({
cmd: 'versionLoaded', cmd: 'versionLoaded',
data: version(), data: version(),
acceptsMultipleFiles: ('_compileJSONMulti' in Module) acceptsMultipleFiles: ('_compileJSONMulti' in Module)
...@@ -34,7 +36,7 @@ module.exports = function (self) { ...@@ -34,7 +36,7 @@ module.exports = function (self) {
break; break;
case 'compile': case 'compile':
missingInputs.length = 0; missingInputs.length = 0;
postMessage({cmd: 'compiled', data: compileJSON(data.source, data.optimize), missingInputs: missingInputs}); self.postMessage({cmd: 'compiled', data: compileJSON(data.source, data.optimize), missingInputs: missingInputs});
break; break;
} }
}, false); }, false);
......
...@@ -73,6 +73,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -73,6 +73,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
if (worker === null) { if (worker === null) {
var compile; var compile;
var missingInputs = []; var missingInputs = [];
var Module = window.Module;
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) {
...@@ -146,7 +147,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -146,7 +147,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
}; };
function loadInternal (url, setVersionText) { function loadInternal (url, setVersionText) {
Module = null; delete window.Module;
// Set a safe fallback until the new one is loaded // Set a safe fallback until the new one is loaded
compileJSON = function (source, optimize) { compilationFinished('{}'); }; compileJSON = function (source, optimize) { compilationFinished('{}'); };
...@@ -155,7 +156,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles ...@@ -155,7 +156,7 @@ function Compiler (editor, handleGithubCall, outputField, hidingRHP, updateFiles
newScript.src = url; newScript.src = url;
document.getElementsByTagName('head')[0].appendChild(newScript); document.getElementsByTagName('head')[0].appendChild(newScript);
var check = window.setInterval(function () { var check = window.setInterval(function () {
if (!Module) { if (!window.Module) {
return; return;
} }
window.clearInterval(check); window.clearInterval(check);
......
...@@ -5,8 +5,9 @@ var Web3 = require('web3'); ...@@ -5,8 +5,9 @@ var Web3 = require('web3');
var injectedProvider; var injectedProvider;
if (typeof web3 !== 'undefined') { var web3;
injectedProvider = web3.currentProvider; if (typeof window.web3 !== 'undefined') {
injectedProvider = window.web3.currentProvider;
web3 = new Web3(injectedProvider); web3 = new Web3(injectedProvider);
} else { } else {
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')); web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
......
/* global chrome, confirm, localStorage */ /* global chrome, confirm */
var utils = require('./utils'); var utils = require('./utils');
...@@ -17,11 +17,11 @@ function StorageHandler (updateFiles) { ...@@ -17,11 +17,11 @@ function StorageHandler (updateFiles) {
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 "' + utils.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 "' + utils.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]); window.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] = window.localStorage[key];
} }
done++; done++;
if (done >= count) { if (done >= count) {
......
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