diff --git a/src/app/tabs/compileTab/compilerContainer.js b/src/app/tabs/compileTab/compilerContainer.js index d9803c9e56..738637368c 100644 --- a/src/app/tabs/compileTab/compilerContainer.js +++ b/src/app/tabs/compileTab/compilerContainer.js @@ -31,6 +31,15 @@ class CompilerContainer { this.listenToEvents() } + /** + * Update the compilation button with the name of the current file + */ + set currentFile(name) { + if (!this._view.compilationButton) return + const button = this.compilationButton(name.split('/').pop()) + yo.update(this._view.compilationButton, button) + } + listenToEvents () { this.editor.event.register('contentChanged', this.scheduleCompilation.bind(this)) this.editor.event.register('sessionSwitched', this.scheduleCompilation.bind(this)) @@ -80,6 +89,20 @@ class CompilerContainer { }) } + /************** + * SUBCOMPONENT + */ + compilationButton(name) { + console.log({name}) + return yo` +
+ +
` + } + + render () { this.compileTabLogic.compiler.event.register('compilerLoaded', (version) => this.setVersionText(version)) this.fetchAllVersion((allversions, selectedVersion) => { @@ -90,7 +113,6 @@ class CompilerContainer { this._view.warnCompilationSlow = yo`` this._view.compileIcon = yo`` - this._view.compileButton = yo`
${this._view.compileIcon} Start to compile (Ctrl-S)
` this._view.autoCompile = yo`` this._view.hideWarningsBox = yo`` if (this.data.autoCompile) this._view.autoCompile.setAttribute('checked', '') @@ -100,37 +122,47 @@ class CompilerContainer { if (this.compileTabLogic.optimize) this._view.optimize.setAttribute('checked', '') this._view.versionSelector = yo` - ` this._view.version = yo`` + this._view.compilationButton = this.compilationButton() + this._view.compileContainer = yo` -
-
- Current version: ${this._view.version} -
- ${this._view.versionSelector} -
-
-
-
- ${this._view.autoCompile} - -
-
-
${this._view.optimize}
- -
-
- ${this._view.hideWarningsBox} - -
+
+ + +
+
-
-
` + ${this._view.versionSelector} + + ${this._view.compilationButton} + + +
+ Compiler Configuration + +
+ ` return this._view.compileContainer } @@ -160,14 +192,18 @@ class CompilerContainer { _updateVersionSelector () { this._view.versionSelector.innerHTML = '' - this._view.versionSelector.appendChild(yo``) - this.data.allversions.forEach(build => this._view.versionSelector.appendChild(yo``)) + this.data.allversions.forEach(build => { + const option = build.path === this.data.selectedVersion + ? yo`` + : yo`` + this._view.versionSelector.appendChild(option) + }) this._view.versionSelector.removeAttribute('disabled') this.queryParams.update({ version: this.data.selectedVersion }) - var url + let url if (this.data.selectedVersion === 'builtin') { - var location = window.document.location - location = location.protocol + '//' + location.host + '/' + location.pathname + let location = window.document.location + location = `${location.protocol}//${location.host}/${location.pathname}` if (location.endsWith('index.html')) location = location.substring(0, location.length - 10) if (!location.endsWith('/')) location += '/' url = location + 'soljson.js' @@ -177,7 +213,7 @@ class CompilerContainer { } url = `${this.data.baseurl}/${this.data.selectedVersion}` } - var isFirefox = typeof InstallTrigger !== 'undefined' + const isFirefox = typeof InstallTrigger !== 'undefined' if (document.location.protocol !== 'file:' && Worker !== undefined && isFirefox) { // Workers cannot load js on "file:"-URLs and we get a // "Uncaught RangeError: Maximum call stack size exceeded" error on Chromium,