Skip to content

Commit

Permalink
fixed issue with initial game state; added custom index.html file wit…
Browse files Browse the repository at this point in the history
…h <meta> tags and supplemental css; added init.js for elm app initialization; changed compilation output to dist/app.js
  • Loading branch information
charukiewicz committed May 28, 2019
1 parent ca5581a commit 23f6e68
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
elm-stuff
*.swp
dist
10 changes: 10 additions & 0 deletions index.html
@@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="./dist/app.js"></script>
<script src="./init.js"></script>
<link rel="stylesheet" type="text/css" href="./styles.css"/>
<meta name="viewport" content="width=device-width, initial-scale=0.7, maximum-scale=1.0, user-scalable=0"/>
<meta name="theme-color" content="#17233c"/>
</head>
<body></body>
</html>
11 changes: 11 additions & 0 deletions init.js
@@ -0,0 +1,11 @@
function domReady(fn) {
document.addEventListener("DOMContentLoaded", fn);
if (document.readyState === "interactive" || document.readyState === "complete" ) {
fn();
}
}

(domReady( function() {
var node = document.querySelector('body');
Elm.Main.init({node:node});
} ));
11 changes: 7 additions & 4 deletions src/Main.elm
Expand Up @@ -152,11 +152,14 @@ update msg model =
|> List.map (\cat -> Dict.get cat model.wordList)
|> List.filterMap identity
|> List.concat

randGen =
Random.int 1 <| List.length words
in
{ model
| randGen = Just <| Random.int 1 <| List.length words
| randGen = Just <| randGen
}
|> with (Task.perform identity <| Task.succeed StartGame)
|> with (Random.generate NextRoundWithRand randGen)

StartGame ->
{ model
Expand Down Expand Up @@ -286,7 +289,7 @@ controlDisplay model =
, spacing 10
, Font.size 40
]
[ row
[ wrappedRow
[ spacing 10
, width fill
]
Expand All @@ -299,7 +302,7 @@ controlDisplay model =
(model.gameMode == Just TimedWord)
(SetGameMode TimedWord)
]
, row
, wrappedRow
[ spacing 10, centerY ]
[ Input.text
[ Background.color (rgb255 23 35 60)
Expand Down
8 changes: 8 additions & 0 deletions styles.css
@@ -0,0 +1,8 @@
body {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}
2 changes: 1 addition & 1 deletion watch
Expand Up @@ -6,6 +6,6 @@ while read -r directory events filename; do
echo ""
echo "----------------------------------"
echo ""
elm make src/Main.elm --debug
elm make src/Main.elm --output ./dist/app.js
fi
done

0 comments on commit 23f6e68

Please sign in to comment.