aboutsummaryrefslogtreecommitdiff
path: root/src/Main.elm
blob: 746df14fb0fdf2665e1ccb70cb4afc35911c4328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module Main
  ( main
  ) where

import Signal
import Html exposing (Html)
import Time exposing (..)
import Mouse
import Json.Encode exposing (Value)
import Keyboard
import Char
import Dict
import List
import Keyboard exposing (KeyCode)

import Model.Model exposing (..)
import Model.Position exposing (..)
import Model.TimerState exposing (..)
import Model.Id exposing (..)
import Update.Update exposing (..)
import View.View exposing (view)

main : Signal Html
main = Signal.map view model

model : Signal Model
model = Signal.foldp logUpdate (initialModel initialTime) input

input : Signal Action
input =
  Signal.mergeMany
    [ actions.signal
    , Signal.map DeltaTime (fps 30)
    , Signal.map KeyPressed keyPress
    ]

port ringingTimers : Signal Bool
port ringingTimers =
  Signal.map
    (\model ->
      model.timers
        |> Dict.toList
        |> List.map snd
        |> List.any (\timer -> timer.state == Ringing)
    )
    model
      |> Signal.dropRepeats

port keyPress : Signal KeyCode

port initialTime : Time