Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lavaclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Will Billingsley
lavaclient
Commits
99f95d08
Commit
99f95d08
authored
6 years ago
by
Will Billingsley
Browse files
Options
Downloads
Patches
Plain Diff
Added stage 0 to collect names
parent
00f43fc8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/lavamaze/Routing.scala
+2
-2
2 additions, 2 deletions
src/main/scala/lavamaze/Routing.scala
src/main/scala/lavamaze/Stage0.scala
+118
-0
118 additions, 0 deletions
src/main/scala/lavamaze/Stage0.scala
with
120 additions
and
2 deletions
src/main/scala/lavamaze/Routing.scala
+
2
−
2
View file @
99f95d08
...
@@ -15,7 +15,7 @@ object Routing extends ElementComponent(<.div()) {
...
@@ -15,7 +15,7 @@ object Routing extends ElementComponent(<.div()) {
case
object
Stage7R
extends
Route
case
object
Stage7R
extends
Route
case
object
Stage8R
extends
Route
case
object
Stage8R
extends
Route
var
route
:
Route
=
Stage1R
var
route
:
Route
=
HomeRoute
def
routeTo
(
r
:
Route
)
=
{
def
routeTo
(
r
:
Route
)
=
{
route
=
r
route
=
r
...
@@ -23,7 +23,7 @@ object Routing extends ElementComponent(<.div()) {
...
@@ -23,7 +23,7 @@ object Routing extends ElementComponent(<.div()) {
}
}
def
render
:
VNode
=
route
match
{
def
render
:
VNode
=
route
match
{
case
HomeRoute
=>
Headers
.
stageHeader
(
1
,
"Hello"
)
case
HomeRoute
=>
Stage0
.
node
case
Stage1R
=>
Stage1
.
node
case
Stage1R
=>
Stage1
.
node
case
Stage2R
=>
Stage2
.
node
case
Stage2R
=>
Stage2
.
node
case
Stage3R
=>
Stage3
.
node
case
Stage3R
=>
Stage3
.
node
...
...
This diff is collapsed.
Click to expand it.
src/main/scala/lavamaze/Stage0.scala
0 → 100644
+
118
−
0
View file @
99f95d08
package
lavamaze
import
com.wbillingsley.veautiful.
{<,
^}
import
org.scalajs.dom
import
org.scalajs.dom.raw.
{
HTMLInputElement
,
HTMLTextAreaElement
}
import
scala.concurrent.Future
import
scala.scalajs.js
import
scala.concurrent.ExecutionContext.Implicits.global
object
Stage0
{
import
Headers._
var
reachedGoal
=
false
var
team
:
String
=
""
var
names
:
String
=
""
var
school
:
String
=
""
var
user
:
String
=
""
def
setUser
(
e
:
dom.Event
)
=
e
.
target
match
{
case
u
:
HTMLInputElement
=>
user
=
u
.
value
}
def
setNames
(
e
:
dom.Event
)
=
e
.
target
match
{
case
u
:
HTMLTextAreaElement
=>
names
=
u
.
value
}
def
setSchool
(
e
:
dom.Event
)
=
e
.
target
match
{
case
u
:
HTMLInputElement
=>
school
=
u
.
value
}
def
setTeam
(
e
:
dom.Event
)
=
e
.
target
match
{
case
u
:
HTMLInputElement
=>
team
=
u
.
value
}
def
csvify
(
s
:
String
)
=
{
"\""
+
s
.
replace
(
"\""
,
"\"\""
)
+
"\""
}
def
submit
()
=
{
import
dom.ext.Ajax
val
data
=
Seq
(
new
js
.
Date
().
toISOString
(),
user
,
names
,
school
).
map
(
csvify
).
mkString
(
","
)
val
url
=
"students"
Ajax
.
post
(
url
,
data
)
.
recoverWith
{
case
x
:
Throwable
=>
x
.
printStackTrace
();
Future
.
failed
(
x
)
}
.
foreach
{
_
=>
reachedGoal
=
true
Routing
.
afterAttach
()
}
}
def
node
()
=
{
println
(
s
"Rendering stage 0"
)
<.
div
(
stageHeader
(
0
,
"It's a lavaly day today"
),
hgutter
,
split
(
card
(
"Welcome to the maze..."
)(
cardText
(
<.
p
(
"First, we need to know who you are for security reasons"
),
<.
div
(^.
cls
:=
"form-group"
,
<(
"label"
)(
"Username"
),
<(
"input"
)(^(
"type"
)
:=
"text"
,
^.
cls
:=
"form-control"
,
^.
on
(
"input"
)
==>
setUser
,
^(
"placeholder"
)
:=
"The one you logged in with"
)
),
<.
div
(^.
cls
:=
"form-group"
,
<(
"label"
)(
"Names"
),
<(
"textarea"
)(^(
"rows"
)
:=
"2"
,
^.
cls
:=
"form-control"
,
^.
on
(
"input"
)
==>
setNames
,
^(
"placeholder"
)
:=
"Your real names"
)
),
<.
div
(^.
cls
:=
"form-group"
,
<(
"label"
)(
"School"
),
<(
"input"
)(^(
"type"
)
:=
"text"
,
^.
cls
:=
"form-control"
,
^.
on
(
"input"
)
==>
setSchool
,
^(
"placeholder"
)
:=
"Your school"
)
),
<.
div
(^.
cls
:=
"form-group"
,
<(
"label"
)(
"Username"
),
<(
"input"
)(^(
"type"
)
:=
"text"
,
^.
cls
:=
"form-control"
,
^.
on
(
"input"
)
==>
setTeam
,
^(
"placeholder"
)
:=
"eg, Jumping jellybeans"
)
),
<.
button
(^.
cls
:=
"btn btn-primary"
,
^.
onClick
-->
submit
,
"Save"
)
)
)
)(
<.
div
(
if
(
reachedGoal
)
{
<.
div
(
<.
p
(^.
cls
:=
"congrats"
,
s
"Welcome, $team"
),
<.
p
(
"Time to get coding..."
),
<(
"div"
,
"stage0"
)(^.
cls
:=
"btn-group"
,
<.
button
(^.
cls
:=
"btn btn-outline-primary"
,
^.
onClick
-->
Routing
.
routeTo
(
Routing
.
Stage1R
),
"Stage 1"
)
)
)
}
else
<(
"div"
,
"stage0"
)(^.
cls
:=
"btn-group"
,
<.
button
(^.
cls
:=
"btn btn-outline-light"
,
^.
onClick
-->
next
,
"Stage 1"
)
)
)
)
)
}
def
next
()
:
Unit
=
{
Routing
.
routeTo
(
Routing
.
Stage2R
)
}
}
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