Commit a6c01737 authored by ninabreznik's avatar ninabreznik Committed by yann300

Add onclick functions to file-panel, remove file-tab and move all connected APIs etc. to file-panel

parent dedbdae9
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -150,5 +150,8 @@
"test": "standard; npm run csslint; node test/index.js",
"test-browser": "npm-run-all -lpr selenium downloadsolc make-mock-compiler serve browsertest",
"watch": "watchify src/index.js -dv -p browserify-reload -o build/app.js"
},
"dependencies": {
"minixhr": "^3.2.2"
}
}
......@@ -328,6 +328,9 @@ function run () {
},
setText: function (text) {
editor.setText(text)
},
packageFiles: (cb) => {
packageFiles(cb)
}
}
var filePanel = new FilePanel(FilePanelAPI, filesProviders)
......@@ -543,9 +546,6 @@ function run () {
executionContextProvider: () => {
return executionContext.getProvider()
},
packageFiles: (cb) => {
packageFiles(cb)
},
getContracts: () => {
if (compiler.lastCompilationResult && compiler.lastCompilationResult.data) {
return compiler.lastCompilationResult.data.contracts
......
var csjs = require('csjs-inject')
var yo = require('yo-yo')
var minixhr = require('minixhr') // simple and small cross-browser XMLHttpRequest (XHR)
var $ = require('jquery')
var EventManager = require('ethereum-remix').lib.EventManager
var FileExplorer = require('../files/file-explorer')
var modalDialog = require('../ui/modaldialog')
var modalDialogCustom = require('../ui/modal-dialog-custom')
var QueryParams = require('./query-params')
var queryParams = new QueryParams()
module.exports = filepanel
......@@ -132,10 +135,10 @@ function filepanel (appAPI, filesProvider) {
</label>
</span>
` : ''}
<span class="${css.gist}">
<span class="${css.gist}" title="Publish all open files to an anonymous github gist" onclick=${() => publishToGist(appAPI)}>
<i class="fa fa-github"></i>
</span>
<span class="${css.copyFiles}">
<span class="${css.copyFiles}" title="Copy all files to another instance of Browser-solidity" onclick=${copyFiles}>
<i class="fa fa-files-o" aria-hidden="true"></i>
</span>
<span onclick=${connectToLocalhost} class="${css.connectToLocalhost}">
......@@ -274,4 +277,62 @@ function filepanel (appAPI, filesProvider) {
}})
}
}
// ------------------ gist publish --------------
function publishToGist () {
if (confirm('Are you sure you want to publish all your files anonymously as a public gist on github.com?')) {
appAPI.packageFiles((error, packaged) => {
if (error) {
console.log(error)
} else {
var description = 'Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. \n Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=' + queryParams.get().version + '&optimize=' + queryParams.get().optimize + '&gist='
console.log(packaged)
minixhr({
url: 'https://api.github.com/gists',
method: 'POST',
data: JSON.stringify({
description: description,
public: true,
files: packaged
})
}, cb)
function cb(data) {
if (data instanceof Error) {
console.log('fail', data.message)
modalDialogCustom.alert('Failed to create gist: ' + (data || 'Unknown transport error'))
} else {
data = JSON.parse(data)
if (data.html_url && confirm('Created a gist at ' + data.html_url + ' Would you like to open it in a new window?')) {
window.open(data.html_url, '_blank')
}
}
}
}
})
}
}
// ------------------ copy files --------------
function copyFiles () {
var target = prompt(
'To which other browser-solidity instance do you want to copy over all files?',
'https://ethereum.github.io/browser-solidity/'
)
if (target === null) {
return
}
appAPI.packageFiles((error, packaged) => {
if (error) {
console.log(error)
} else {
$('<iframe/>', {
src: target,
style: 'display:none;',
load: function () { this.contentWindow.postMessage(['loadFiles', packaged], '*') }
}).appendTo('body')
}
})
}
}
......@@ -6,7 +6,6 @@ var runTab = require('../tabs/run-tab')
var settingsTab = require('../tabs/settings-tab')
var analysisTab = require('../tabs/analysis-tab')
var debuggerTab = require('../tabs/debugger-tab')
var filesTab = require('../tabs/files-tab')
var supportTab = require('../tabs/support-tab')
// -------------- styling ----------------------
......@@ -68,7 +67,6 @@ function RighthandPanel (appAPI, events, opts) {
<li class="compileView" title="Compile">Compile</li>
<li class="runView" title="Run">Run</li>
<li class="settingsView" title="Settings">Settings</li>
<li class="publishView" title="Publish" >Files</li>
<li class="debugView" title="Debugger">Debugger</li>
<li class="staticanalysisView" title="Static Analysis">Analysis</li>
<li class="supportView" title="Help and support">Support</li>
......@@ -92,7 +90,6 @@ function RighthandPanel (appAPI, events, opts) {
settingsTab(optionViews, appAPI, events, opts)
analysisTab(optionViews, appAPI, events, opts)
debuggerTab(optionViews, appAPI, events, opts)
filesTab(optionViews, appAPI, events, opts)
supportTab(optionViews, appAPI, events, opts)
self.render = function () { return self._view.element }
......
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