Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xx-coin-game-ui
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
archives
xx-coin-game-ui
Commits
8ea8334a
Commit
8ea8334a
authored
4 years ago
by
Sydney Anne Erickson
Browse files
Options
Downloads
Patches
Plain Diff
Remove progress bar and print client message to screen
parent
3deaef1b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.go
+8
-24
8 additions, 24 deletions
main.go
with
8 additions
and
24 deletions
main.go
+
8
−
24
View file @
8ea8334a
...
...
@@ -4,16 +4,11 @@ import (
"github.com/dtylman/gowd"
"gitlab.com/elixxir/client/interfaces/contact"
"gitlab.com/elixxir/client/single"
"io/ioutil"
"os"
"fmt"
"time"
"github.com/dtylman/gowd/bootstrap"
"gitlab.com/elixxir/client/api"
"gitlab.com/elixxir/client/interfaces/params"
jww
"github.com/spf13/jwalterweatherman"
)
var
password
string
...
...
@@ -67,11 +62,8 @@ func main() {
// happens when the 'start' button is clicked
func
btnClicked
(
sender
*
gowd
.
Element
,
event
*
gowd
.
EventElement
)
{
// adds a text and progress bar to the body
sender
.
SetText
(
"Working..."
)
text
:=
body
.
AddElement
(
gowd
.
NewStyledText
(
"Working..."
,
gowd
.
BoldText
))
progressBar
:=
bootstrap
.
NewProgressBar
()
body
.
AddElement
(
progressBar
.
Element
)
// adds test to the body
text
:=
body
.
AddElement
(
gowd
.
NewStyledText
(
"Sending message..."
,
gowd
.
BoldText
))
// makes the body stop responding to user events
body
.
Disable
()
...
...
@@ -82,31 +74,23 @@ func btnClicked(sender *gowd.Element, event *gowd.EventElement) {
//send the message
message
:=
fmt
.
Sprintf
(
"%s:%s"
,
ethAddr
,
sendText
)
// Inline function to print message from client to page, callback for upcoming function
replyFunc
:=
func
(
payload
[]
byte
,
err
error
){
if
err
!=
nil
{
body
.
AddHTML
(
fmt
.
Sprintf
(
"<textarea readonly style
\"
width:100%;
\"
>{}</textarea>"
,
err
.
Error
()),
nil
)
}
else
{
body
.
AddHTML
(
fmt
.
Sprintf
(
"<textarea readonly style
\"
width:100%;
\"
>{}</textarea>"
,
string
(
payload
)),
nil
)
}
}
err
:=
singleMngr
.
TransmitSingleUse
(
botContact
,
[]
byte
(
message
),
"xxCoinGame"
,
10
,
replyFunc
,
30
*
time
.
Second
)
// clean up - remove the added elements
defer
func
()
{
sender
.
SetText
(
"Start"
)
body
.
RemoveElement
(
text
)
body
.
RemoveElement
(
progressBar
.
Element
)
body
.
Enable
()
}()
// render the progress bar
for
i
:=
0
;
i
<=
123
;
i
++
{
progressBar
.
SetValue
(
i
,
123
)
text
.
SetText
(
fmt
.
Sprintf
(
"Working %v"
,
i
))
time
.
Sleep
(
time
.
Millisecond
*
20
)
// this will cause the body to be refreshed
body
.
Render
()
}
body
.
AddHTML
(
`<textarea readonly style="width:100%;">Client output would go here</textarea>`
,
nil
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment