summaryrefslogtreecommitdiff
blob: 9b667ac77881336a85b2b0e3e343aa6c9c1eaec2 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
module View.BattleListing exposing (get_html)

-- Elm -------------------------------------------------------------------------
import Html
import Html.Attributes
-- import Html.Events

-- Map -------------------------------------------------------------------
import Struct.BattleSummary
import Struct.Event

--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
get_item_html : Struct.BattleSummary.Type -> (Html.Html Struct.Event.Type)
get_item_html item =
   (Html.a
      [
         (Html.Attributes.href
            (
               "/battle/?id="
               ++ (Struct.BattleSummary.get_id item)
            )
         ),
         (
            if (Struct.BattleSummary.is_players_turn item)
            then
               (Html.Attributes.class "main-menu-battle-summary-is-active")
            else
               (Html.Attributes.class "main-menu-battle-summary-is-inactive")
         )
      ]
      [
         (Html.div
            [
               (Html.Attributes.class "main-menu-battle-summary-name")
            ]
            [
               (Html.text (Struct.BattleSummary.get_name item))
            ]
         ),
         (Html.div
            [
               (Html.Attributes.class "main-menu-battle-summary-date")
            ]
            [
               (Html.text (Struct.BattleSummary.get_last_edit item))
            ]
         )
      ]
   )

--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
get_html : (
      String ->
      String ->
      (List Struct.BattleSummary.Type) ->
      (Html.Html Struct.Event.Type)
   )
get_html name class battle_summaries =
   (Html.div
      [
         (Html.Attributes.class class),
         (Html.Attributes.class "main-menu-battle-listing")
      ]
      [
         (Html.div
            [
               (Html.Attributes.class "main-menu-battle-listing-header")
            ]
            [
               (Html.text name)
            ]
         ),
         (Html.div
            [
               (Html.Attributes.class "main-menu-battle-listing-body")
            ]
            (List.map (get_item_html) battle_summaries)
         ),
         (Html.div
            [
               (Html.Attributes.class "main-menu-battle-listing-add-new")
            ]
            [
               (Html.text "New")
            ]
         )
      ]
   )