-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It turns out files under `extra-source-files` are not found at compile time (`file-embed`) unless they're in `rsc` (and not as symlinks), and known to Git (staging makes a difference, which confused me for a while, e.g. in georgefst/hello-hs@fa41589).
- Loading branch information
Showing
8 changed files
with
32,630 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ dist*/ | |
elm-stuff*/ | ||
.ghc.environment.* | ||
cabal.project.local* | ||
haskell/rsc | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
body { | ||
/*TODO this may be redundant (except on iOS?) since we also disable scaling via the `viewport` meta tag */ | ||
touch-action: none | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
body { | ||
background-color: rgb(207, 231, 247); | ||
overflow: hidden; | ||
padding: 0; | ||
margin: 0; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
body { | ||
height: 100vh; | ||
background-position: center center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
font-family: Helvetica, Arial, sans-serif; | ||
} | ||
|
||
form { | ||
padding: 0.5em; | ||
text-align: center; | ||
font-size: 5vw; | ||
} | ||
|
||
input { | ||
font-size: inherit; | ||
} | ||
|
||
.colours { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.colour { | ||
flex-grow: 1; | ||
margin: 3vh; | ||
height: 10vh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const attr = s => document.currentScript.attributes.getNamedItem(s).value | ||
|
||
const params = new URLSearchParams(window.location.search) | ||
const username = params.get("username") | ||
|
||
const wsAddress = "ws://" + location.hostname + ":" + attr("wsPort") + "?" + params | ||
const ws = new WebSocket(wsAddress) | ||
ws.onclose = event => { | ||
console.log(event) | ||
alert("Connection lost. See console for details.") | ||
} | ||
|
||
const layouts = JSON.parse(attr("layouts")) | ||
const encoding = JSON.parse(attr("encoding")) | ||
|
||
ws.onopen = _event => { | ||
// Elm | ||
elmInitialised = false | ||
const app = Elm.Main.init({ | ||
flags: { | ||
username, layouts, encoding, | ||
supportsFullscreen: document.documentElement.requestFullscreen != null | ||
} | ||
}) | ||
//TODO this (waiting for an initialisation message) | ||
// is all just a workaround for the fact that Elm has no built-in way of signalling that 'init' has finished | ||
app.ports.initPort.subscribe(() => { | ||
elmInitialised = true | ||
dispatchEvent(new Event("elmInit")) | ||
}) | ||
|
||
// fullscreen | ||
app.ports.fullscreenPort.subscribe(() => { | ||
document.documentElement.requestFullscreen() | ||
}) | ||
document.onfullscreenchange = _event => { | ||
app.ports.fullscreenChangePort.send( | ||
!(document.fullscreenElement == null) | ||
) | ||
} | ||
|
||
// update messages | ||
app.ports.sendUpdatePortJSON.subscribe(message => ws.send(JSON.stringify(message))) | ||
app.ports.sendUpdatePortBinary.subscribe(message => ws.send(Uint8Array.from(message))) | ||
ws.addEventListener("message", event => { | ||
const send = () => app.ports.receiveUpdatePort.send(JSON.parse(event.data)) | ||
if (elmInitialised) { | ||
send() | ||
} else { | ||
addEventListener("elmInit", () => { | ||
setTimeout(send, 0) | ||
}) | ||
} | ||
}) | ||
|
||
// reset form | ||
app.ports.resetFormPort.subscribe(id => document.getElementById(id).reset()) | ||
|
||
// audio | ||
app.ports.audioPort.subscribe(url => { | ||
audio = new Audio(url) | ||
audio.play() | ||
}) | ||
|
||
// vibration | ||
app.ports.vibratePort.subscribe(intervals => { | ||
window.navigator.vibrate(intervals) | ||
}) | ||
|
||
// logging | ||
app.ports.logPort.subscribe(console.log) | ||
} |