diff --git a/src/app.js b/src/app.js index 12a2cd4f89..e7d9e81249 100644 --- a/src/app.js +++ b/src/app.js @@ -594,6 +594,10 @@ function run () { }, resetDapp: (contracts) => { udapp.reset(contracts, transactionContextAPI) + }, + setOptimize: (optimize, runCompilation) => { + compiler.setOptimize(optimize) + if (runCompilation) runCompiler() } } var rhpEvents = { @@ -1014,17 +1018,6 @@ function run () { } } - // set default - $('#optimize').attr('checked', (queryParams.get().optimize === 'true')) - compiler.setOptimize(document.querySelector('#optimize').checked) - - document.querySelector('#optimize').addEventListener('change', function () { - var optimize = document.querySelector('#optimize').checked - queryParams.update({ optimize: optimize }) - compiler.setOptimize(optimize) - runCompiler() - }) - // ----------------- version selector------------- // clear and disable the version selector diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index ab88e1b3f0..9269477eab 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -1,4 +1,5 @@ var yo = require('yo-yo') +var QueryParams = require('../../lib/query-params') // -------------- styling ---------------------- var csjs = require('csjs-inject') @@ -28,6 +29,8 @@ function SettingsTab (container, appAPI, appEvents, opts) { if (typeof container === 'string') container = document.querySelector(container) if (!container) throw new Error('no container given') + var queryParams = new QueryParams() + var el = yo`
@@ -47,5 +50,20 @@ function SettingsTab (container, appAPI, appEvents, opts) {
` + + var optimize = el.querySelector('#optimize') + if ((queryParams.get().optimize === 'true')) { + optimize.setAttribute('checked', true) + appAPI.setOptimize(true, false) + } else { + appAPI.setOptimize(false, false) + } + + optimize.addEventListener('change', function () { + var optimize = this.checked + queryParams.update({ optimize: optimize }) + appAPI.setOptimize(optimize, true) + }) + container.appendChild(el) }