diff --git a/index.html b/index.html index 04e2d46a11..3a47efc214 100644 --- a/index.html +++ b/index.html @@ -35,13 +35,9 @@ - - - -
diff --git a/package.json b/package.json index dd182ac399..149d720ec3 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "private": true, "semistandard": { "ignore": [ - "assets/js/", "build/", "src/mode-solidity.js", "nightwatch.js", diff --git a/src/app/editor.js b/src/app/editor.js index e698565ee3..0110b69896 100644 --- a/src/app/editor.js +++ b/src/app/editor.js @@ -1,7 +1,8 @@ -/* global BALLOT_EXAMPLE, FileReader */ +/* global FileReader */ 'use strict'; var utils = require('./utils'); +var examples = require('./example-contracts'); var ace = require('brace'); require('../mode-solidity.js'); @@ -169,16 +170,10 @@ function Editor (loadingFromGist, storage) { } function setupStuff (files) { - var untitledCount = ''; if (files.length === 0) { if (loadingFromGist) return; - // Backwards-compatibility - while (storage.exists(SOL_CACHE_UNTITLED + untitledCount)) { - untitledCount = (untitledCount - 0) + 1; - } - SOL_CACHE_FILE = SOL_CACHE_UNTITLED + untitledCount; - files.push(SOL_CACHE_FILE); - storage.set(SOL_CACHE_FILE, BALLOT_EXAMPLE); // defined in assets/js/ballot.sol.js + files.push(utils.fileKey(examples.ballot.name)); + storage.set(utils.fileKey(examples.ballot.name), examples.ballot.content); } SOL_CACHE_FILE = files[0]; diff --git a/assets/js/ballot.sol.js b/src/app/example-contracts.js similarity index 60% rename from assets/js/ballot.sol.js rename to src/app/example-contracts.js index b48675cf46..78c9c2773e 100644 --- a/assets/js/ballot.sol.js +++ b/src/app/example-contracts.js @@ -1,30 +1,4 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2014, 2015, the individual contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -var multi = function (func) { return func.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; }; - -var BALLOT_EXAMPLE = multi(function () { /*pragma solidity ^0.4.0; +var ballot = `pragma solidity ^0.4.0; contract Ballot { struct Voter { @@ -88,5 +62,8 @@ contract Ballot { winningProposal = proposal; } } -} -*/}); +}`; + +module.exports = { + ballot: { name: 'ballot.sol', content: ballot } +}; diff --git a/test-browser/mockcompiler/requests.js b/test-browser/mockcompiler/requests.js index 4d293b4087..af6cd883e7 100644 --- a/test-browser/mockcompiler/requests.js +++ b/test-browser/mockcompiler/requests.js @@ -1,12 +1,12 @@ module.exports = { 'testSimpleContract': { 'sources': { - 'Untitled1': 'contract test1 {} contract test2 {}' + 'Untitled': 'contract test1 {} contract test2 {}' } }, 'ballot': { 'sources': { - 'Untitled1': `pragma solidity ^0.4.0; + 'Untitled': `pragma solidity ^0.4.0; contract Ballot { struct Voter { diff --git a/test-browser/tests/ballot.js b/test-browser/tests/ballot.js index ffa302fa7c..564798a4ed 100644 --- a/test-browser/tests/ballot.js +++ b/test-browser/tests/ballot.js @@ -14,7 +14,7 @@ function runTests (browser, testData) { .waitForElementVisible('.newFile', 10000); browser.assert.notEqual(testData, null); // TODO add Ballot tests. -> setValue('#input textarea', ... ) is not working properly with that contract. - /* testBallot(browser, testData.ballot.sources.Untitled1, function () { + /* testBallot(browser, testData.ballot.sources.Untitled, function () { browser.end(); });*/ } diff --git a/test-browser/tests/simpleContract.js b/test-browser/tests/simpleContract.js index 887d6a3d35..bf61abdb24 100644 --- a/test-browser/tests/simpleContract.js +++ b/test-browser/tests/simpleContract.js @@ -13,7 +13,7 @@ function runTests (browser, testData) { .url('http://127.0.0.1:8080/#version=builtin') .waitForElementVisible('.newFile', 10000); browser.assert.notEqual(testData, null); - testSimpleContract(browser, testData.testSimpleContract.sources.Untitled1, function () { + testSimpleContract(browser, testData.testSimpleContract.sources.Untitled, function () { browser.end(); }); }