Commit 1a260c51 authored by Rob Stupay's avatar Rob Stupay Committed by yann300

updated for alert

parent 00b97a7b
...@@ -38,18 +38,5 @@ ...@@ -38,18 +38,5 @@
</head> </head>
<body> <body>
<script src="build/app.js"></script> <script src="build/app.js"></script>
<div id="modaldialog" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2></h2>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<span id="modal-footer-ok">OK</span><span id="modal-footer-cancel">Cancel</span>
</div>
</div>
</div>
</body> </body>
</html> </html>
/* global alert, confirm, Option, Worker, chrome */ /* global confirm, prompt, Option, Worker, chrome */
'use strict' 'use strict'
var async = require('async') var async = require('async')
...@@ -242,7 +242,7 @@ function run () { ...@@ -242,7 +242,7 @@ function run () {
success: function (response) { success: function (response) {
if (response.data) { if (response.data) {
if (!response.data.files) { if (!response.data.files) {
alert('Gist load error: ' + response.data.message) modalDialogCustom.alert('Gist load error: ' + response.data.message)
return return
} }
loadFiles(response.data.files) loadFiles(response.data.files)
...@@ -254,7 +254,7 @@ function run () { ...@@ -254,7 +254,7 @@ function run () {
// insert ballot contract if there are no files available // insert ballot contract if there are no files available
if (!loadingFromGist && Object.keys(filesProviders['browser'].list()).length === 0) { if (!loadingFromGist && Object.keys(filesProviders['browser'].list()).length === 0) {
if (!filesProviders['browser'].set(examples.ballot.name, examples.ballot.content)) { if (!filesProviders['browser'].set(examples.ballot.name, examples.ballot.content)) {
alert('Failed to store example contract in browser. Remix will not work properly. Please ensure Remix has access to LocalStorage. Safari in Private mode is known not to work.') modalDialogCustom.alert('Failed to store example contract in browser. Remix will not work properly. Please ensure Remix has access to LocalStorage. Safari in Private mode is known not to work.')
} }
} }
...@@ -612,9 +612,9 @@ function run () { ...@@ -612,9 +612,9 @@ function run () {
udapp.event.register('publishContract', this, function (contract) { udapp.event.register('publishContract', this, function (contract) {
publishOnSwarm(contract, function (err) { publishOnSwarm(contract, function (err) {
if (err) { if (err) {
alert('Failed to publish metadata: ' + err) modalDialogCustom.alert('Failed to publish metadata: ' + err)
} else { } else {
alert('Metadata published successfully') modalDialogCustom.alert('Metadata published successfully')
} }
}) })
}) })
......
...@@ -3,6 +3,7 @@ var yo = require('yo-yo') ...@@ -3,6 +3,7 @@ var yo = require('yo-yo')
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var Treeview = require('ethereum-remix').ui.TreeView var Treeview = require('ethereum-remix').ui.TreeView
var modalDialog = require('./modaldialog') var modalDialog = require('./modaldialog')
var modalDialogCustom = require('./modal-dialog-custom')
var EventManager = require('ethereum-remix').lib.EventManager var EventManager = require('ethereum-remix').lib.EventManager
...@@ -133,7 +134,7 @@ function fileExplorer (appAPI, files) { ...@@ -133,7 +134,7 @@ function fileExplorer (appAPI, files) {
var fileReader = new FileReader() var fileReader = new FileReader()
fileReader.onload = function (event) { fileReader.onload = function (event) {
var success = files.set(name, event.target.result) var success = files.set(name, event.target.result)
if (!success) alert('Failed to create file ' + name) if (!success) modalDialogCustom.alert('Failed to create file ' + name)
else events.trigger('focus', [name]) else events.trigger('focus', [name])
} }
fileReader.readAsText(file) fileReader.readAsText(file)
...@@ -219,12 +220,12 @@ function fileExplorer (appAPI, files) { ...@@ -219,12 +220,12 @@ function fileExplorer (appAPI, files) {
newPath[newPath.length - 1] = label.innerText newPath[newPath.length - 1] = label.innerText
newPath = newPath.join('/') newPath = newPath.join('/')
if (label.innerText.match(/(\/|:|\*|\?|"|<|>|\\|\||')/) !== null) { if (label.innerText.match(/(\/|:|\*|\?|"|<|>|\\|\||')/) !== null) {
alert('special characters are not allowsed') modalDialogCustom.alert('special characters are not allowsed')
label.innerText = textUnderEdit label.innerText = textUnderEdit
} else if (!files.exists(newPath)) { } else if (!files.exists(newPath)) {
files.rename(label.dataset.path, newPath, isFolder) files.rename(label.dataset.path, newPath, isFolder)
} else { } else {
alert('File already exists.') modalDialogCustom.alert('File already exists.')
label.innerText = textUnderEdit label.innerText = textUnderEdit
} }
} else label.innerText = textUnderEdit } else label.innerText = textUnderEdit
...@@ -253,7 +254,7 @@ function fileExplorer (appAPI, files) { ...@@ -253,7 +254,7 @@ function fileExplorer (appAPI, files) {
} }
} }
if (err) { if (err) {
alert(`couldn't rename - ${err}`) modalDialogCustom.alert(`could not rename - ${err}`)
label.innerText = textUnderEdit label.innerText = textUnderEdit
} else { } else {
textUnderEdit = label.innerText textUnderEdit = label.innerText
...@@ -305,7 +306,7 @@ function fileExplorer (appAPI, files) { ...@@ -305,7 +306,7 @@ function fileExplorer (appAPI, files) {
} }
function fileRenamedError (error) { function fileRenamedError (error) {
alert(error) modalDialogCustom.alert(error)
} }
function fileAdded (filepath) { function fileAdded (filepath) {
......
/* global alert */
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var yo = require('yo-yo') var yo = require('yo-yo')
var EventManager = require('ethereum-remix').lib.EventManager var EventManager = require('ethereum-remix').lib.EventManager
var FileExplorer = require('./file-explorer') var FileExplorer = require('./file-explorer')
var modalDialog = require('./modaldialog') var modalDialog = require('./modaldialog')
var modalDialogCustom = require('./modal-dialog-custom')
module.exports = filepanel module.exports = filepanel
...@@ -214,7 +215,7 @@ function filepanel (appAPI, filesProvider) { ...@@ -214,7 +215,7 @@ function filepanel (appAPI, filesProvider) {
function createNewFile () { function createNewFile () {
var newName = filesProvider['browser'].type + '/' + appAPI.createName('Untitled.sol') var newName = filesProvider['browser'].type + '/' + appAPI.createName('Untitled.sol')
if (!filesProvider['browser'].set(newName, '')) { if (!filesProvider['browser'].set(newName, '')) {
alert('Failed to create file ' + newName) modalDialogCustom.alert('Failed to create file ' + newName)
} else { } else {
appAPI.switchToFile(newName) appAPI.switchToFile(newName)
} }
......
...@@ -2,8 +2,6 @@ var modal = require('./modaldialog.js') ...@@ -2,8 +2,6 @@ var modal = require('./modaldialog.js')
var yo = require('yo-yo') var yo = require('yo-yo')
module.exports = { module.exports = {
alert: function (text) { alert: function (text) {
modal('', yo`<div>${text}</div>`, null, null) modal('', yo`<div>${text}</div>`, null, {label:null})
var cancel = document.getElementById('modal-footer-cancel')
cancel.style.display = 'none'
} }
} }
...@@ -97,14 +97,9 @@ module.exports = (title, content, ok, cancel) => { ...@@ -97,14 +97,9 @@ module.exports = (title, content, ok, cancel) => {
container.style.display = container.style.display === 'block' ? hide() : show() container.style.display = container.style.display === 'block' ? hide() : show()
function clickModalFooterListener (event) {
hide()
removeEventListener()
}
function okListener () { function okListener () {
hide() hide()
// if (ok && ok.fn) ok.fn() - what is ok.fn doing? if (ok && ok.fn) ok.fn()
removeEventListener() removeEventListener()
} }
...@@ -125,12 +120,10 @@ module.exports = (title, content, ok, cancel) => { ...@@ -125,12 +120,10 @@ module.exports = (title, content, ok, cancel) => {
function removeEventListener () { function removeEventListener () {
okDiv.removeEventListener('click', okListener) okDiv.removeEventListener('click', okListener)
cancelDiv.removeEventListener('click', cancelListener) cancelDiv.removeEventListener('click', cancelListener)
modal.removeEventListener('click', clickModalFooterListener)
} }
okDiv.addEventListener('click', okListener) okDiv.addEventListener('click', okListener)
cancelDiv.addEventListener('click', cancelListener) cancelDiv.addEventListener('click', cancelListener)
modalFooter.addEventListener('click', clickModalFooterListener)
} }
function html () { function html () {
......
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