Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
da31a6a8
Commit
da31a6a8
authored
May 27, 2016
by
chriseth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #33 from redsquirrel/set-provider
Setting web3 provider when web3 context is toggled
parents
56963616
9a273198
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
.gitignore
.gitignore
+1
-0
app.js
src/app.js
+13
-7
No files found.
.gitignore
View file @
da31a6a8
.vscode
.vscode
build
node_modules
node_modules
src/app.js
View file @
da31a6a8
...
@@ -243,22 +243,28 @@ var run = function() {
...
@@ -243,22 +243,28 @@ var run = function() {
$vmToggle
.
on
(
'change'
,
executionContextChange
);
$vmToggle
.
on
(
'change'
,
executionContextChange
);
$web3Toggle
.
on
(
'change'
,
executionContextChange
);
$web3Toggle
.
on
(
'change'
,
executionContextChange
);
$web3endpoint
.
on
(
'change'
,
function
()
{
$web3endpoint
.
on
(
'change'
,
function
()
{
var
endpoint
=
$web3endpoint
.
val
();
setProviderFromEndpoint
();
if
(
endpoint
==
'ipc'
)
if
(
executionContext
==
'web3'
)
compile
();
web3
.
setProvider
(
new
web3
.
providers
.
IpcProvider
());
else
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
endpoint
));
compile
();
});
});
function
executionContextChange
(
ev
)
{
function
executionContextChange
(
ev
)
{
if
(
ev
.
target
.
value
==
'web3'
&&
!
confirm
(
"Are you sure you want to connect to a local ethereum node?"
)
)
{
if
(
ev
.
target
.
value
==
'web3'
&&
!
confirm
(
"Are you sure you want to connect to a local ethereum node?"
)
)
{
$vmToggle
.
get
(
0
).
checked
=
true
;
$vmToggle
.
get
(
0
).
checked
=
true
;
executionContext
=
'vm'
;
executionContext
=
'vm'
;
}
else
executionContext
=
ev
.
target
.
value
;
}
else
{
executionContext
=
ev
.
target
.
value
;
setProviderFromEndpoint
();
}
compile
();
compile
();
}
}
function
setProviderFromEndpoint
()
{
var
endpoint
=
$web3endpoint
.
val
();
if
(
endpoint
==
'ipc'
)
web3
.
setProvider
(
new
web3
.
providers
.
IpcProvider
());
else
web3
.
setProvider
(
new
web3
.
providers
.
HttpProvider
(
endpoint
));
}
// ------------------ gist publish --------------
// ------------------ gist publish --------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment