diff --git a/src/app.js b/src/app.js index f033514446..d7e0ce5f01 100644 --- a/src/app.js +++ b/src/app.js @@ -698,28 +698,12 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // ---------------- Righthand-panel -------------------- var rhpAPI = { - config: config, setEditorSize (delta) { $('#righthand-panel').css('width', delta) self._view.centerpanel.style.right = delta + 'px' document.querySelector(`.${css.dragbar2}`).style.right = delta + 'px' onResize() }, - getAccounts: (cb) => { - udapp.getAccounts(cb) - }, - getSource: (fileName) => { - return compiler.getSource(fileName) - }, - editorContent: () => { - return editor.get(editor.current()) - }, - currentFile: () => { - return config.get('currentFile') - }, - visitContracts: (cb) => { - compiler.visitContracts(cb) - }, switchFile: function (path) { fileManager.switchFile(path) }, @@ -775,7 +759,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org udapp: udapp, udappUI: udappUI, compiler: compiler, - renderer: renderer + renderer: renderer, + editor: editor, + config: config } self._components.righthandpanel = new RighthandPanel(rhpAPI, rhpEvents, rhpOpts) diff --git a/src/app/editor/editor.js b/src/app/editor/editor.js index fd96b107a5..a67e5dd4de 100644 --- a/src/app/editor/editor.js +++ b/src/app/editor/editor.js @@ -170,17 +170,25 @@ function Editor (opts = {}) { } /** - * returns the content of the specified session @arg path - * if @arg path is not provided, the content of the current editing session is returned + * returns the content of the current session + * + * @return {String} content of the file referenced by @arg path + */ + this.currentContent = function () { + return this.get(this.current()) + } + + /** + * returns the content of the session targeted by @arg path + * if @arg path is null, the content of the current session is returned * - * @param {String} path - path of th file in edition * @return {String} content of the file referenced by @arg path */ this.get = function (path) { if (!path || currentSession === path) { return editor.getValue() } else if (sessions[path]) { - sessions[path].getValue() + return sessions[path].getValue() } } @@ -188,8 +196,7 @@ function Editor (opts = {}) { * returns the path of the currently editing file * returns `undefined` if no session is being editer * - * @param {String} path - path of th file in edition - * @return {String} content of the file referenced by @arg path + * @return {String} path of the current session */ this.current = function () { if (editor.getSession() === emptySession) { diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index b83f06ea14..901f6b91e9 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -36,7 +36,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) { var compileTimeout = null function scheduleCompilation () { - if (!appAPI.config.get('autoCompile')) { + if (!opts.config.get('autoCompile')) { return } @@ -59,16 +59,16 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) { // ----------------- autoCompile ----------------- var autoCompileInput = compileContainer.querySelector('#autoCompile') var autoCompile = false - if (appAPI.config.exists('autoCompile')) { - autoCompile = appAPI.config.get('autoCompile') + if (opts.config.exists('autoCompile')) { + autoCompile = opts.config.get('autoCompile') } - appAPI.config.set('autoCompile', autoCompile) + opts.config.set('autoCompile', autoCompile) if (autoCompile) { autoCompileInput.setAttribute('checked', autoCompile) } autoCompileInput.addEventListener('change', function () { - appAPI.config.set('autoCompile', autoCompileInput.checked) + opts.config.set('autoCompile', autoCompileInput.checked) }) // REGISTER EVENTS @@ -156,7 +156,7 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) { } if (!error) { if (data.contracts) { - appAPI.visitContracts((contract) => { + opts.compiler.visitContracts((contract) => { opts.renderer.error(contract.name, $(errorContainer), {type: 'success'}) }) } @@ -190,8 +190,8 @@ function compileTab (appAPI = {}, appEvents = {}, opts = {}) { contractNames.innerHTML = '' if (success) { contractNames.removeAttribute('disabled') - appAPI.visitContracts((contract) => { - contractsDetails[contract.name] = parseContracts(contract.name, contract.object, appAPI.getSource(contract.file)) + opts.compiler.visitContracts((contract) => { + contractsDetails[contract.name] = parseContracts(contract.name, contract.object, opts.compiler.getSource(contract.file)) var contractName = yo` `) }) } else { diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 176c0b7a9a..b00267d417 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -56,16 +56,16 @@ module.exports = class SettingsTab { // Gist settings var gistAccessToken = yo`` - var token = self._api.config.get('settings/gist-access-token') + var token = self._opts.config.get('settings/gist-access-token') if (token) gistAccessToken.value = token - var gistAddToken = yo` { self._api.config.set('settings/gist-access-token', gistAccessToken.value); tooltip('Access token saved') }} value="Save" type="button">` - var gistRemoveToken = yo` { gistAccessToken.value = ''; self._api.config.set('settings/gist-access-token', ''); tooltip('Access token removed') }} value="Remove" type="button">` - self._view.gistToken = yo`