Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
zlu
zlu.me
Commits
0e8a0264
Commit
0e8a0264
authored
Jul 18, 2016
by
zlu
🤸🏿
Browse files
Generate restaurant picker
parent
d1989152
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8349 additions
and
0 deletions
+8349
-0
rand_restaurant.elm
rand_restaurant.elm
+46
-0
rand_restaurant.html
rand_restaurant.html
+8303
-0
No files found.
rand_restaurant.elm
0 → 100644
View file @
0e8a0264
import
Html
exposing
(
..
)
import
Html
.
Events
exposing
(
onClick
)
import
Html
.
App
as
App
import
Random
import
Array
main
=
App
.
program
{
init
=
init
,
view
=
view
,
update
=
update
,
subscriptions
=
subscriptions
}
type
alias
Model
=
{
dieFace
:
Int
}
type
Msg
=
Roll
|
NewFace
Int
init
:
(
Model
,
Cmd
Msg
)
init
=
(
Model
1
,
Cmd
.
none
)
update
:
Msg
->
Model
->
(
Model
,
Cmd
Msg
)
update
msg
model
=
case
msg
of
Roll
->
(
model
,
Random
.
generate
NewFace
(
Random
.
int
0
(
Array
.
length
choices
)))
NewFace
newFace
->
(
Model
newFace
,
Cmd
.
none
)
view
:
Model
->
Html
Msg
view
model
=
div
[]
[
h1
[]
[
Html
.
text
(
Maybe
.
withDefault
"
Cannot decide, roll again"
(
Array
.
get
model
.
dieFace
choices
))
]
,
button
[
onClick
Roll
]
[
Html
.
text
"
Roll"
]
]
subscriptions
:
Model
->
Sub
Msg
subscriptions
model
=
Sub
.
none
choices
=
Array
.
fromList
[
"
Ceara"
,
"
Burger Bros"
,
"
Boamesa"
,
"
Vila Lobos"
,
"
Graveyard Hotdogs"
]
rand_restaurant.html
0 → 100644
View file @
0e8a0264
This diff is collapsed.
Click to expand it.
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