summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-09-13 16:51:08 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-09-13 16:51:08 +0200
commit9ec5806bc721734923ff4c93f7ef1f97a6a03248 (patch)
treec80b737a8bf0cc6e311c4fe7256f68e7ea8e158a /src/ElmModule
Starting an browser extension for TO...
Diffstat (limited to 'src/ElmModule')
-rw-r--r--src/ElmModule/Init.elm18
-rw-r--r--src/ElmModule/Subscriptions.elm17
-rw-r--r--src/ElmModule/Update.elm38
-rw-r--r--src/ElmModule/View.elm64
4 files changed, 137 insertions, 0 deletions
diff --git a/src/ElmModule/Init.elm b/src/ElmModule/Init.elm
new file mode 100644
index 0000000..705cff7
--- /dev/null
+++ b/src/ElmModule/Init.elm
@@ -0,0 +1,18 @@
+module ElmModule.Init exposing (init)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Event
+import Struct.Flags
+import Struct.Model
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+init : Struct.Flags.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
+init flags = (Struct.Model.new flags)
diff --git a/src/ElmModule/Subscriptions.elm b/src/ElmModule/Subscriptions.elm
new file mode 100644
index 0000000..e9b557e
--- /dev/null
+++ b/src/ElmModule/Subscriptions.elm
@@ -0,0 +1,17 @@
+module ElmModule.Subscriptions exposing (..)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Model
+import Struct.Event
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+subscriptions : Struct.Model.Type -> (Sub Struct.Event.Type)
+subscriptions model = Sub.none
diff --git a/src/ElmModule/Update.elm b/src/ElmModule/Update.elm
new file mode 100644
index 0000000..18b2077
--- /dev/null
+++ b/src/ElmModule/Update.elm
@@ -0,0 +1,38 @@
+module ElmModule.Update exposing (update)
+
+-- Elm -------------------------------------------------------------------------
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Event
+import Struct.Model
+
+import Update.HandleServerReply
+import Update.SelectTab
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+update : (
+ Struct.Event.Type ->
+ Struct.Model.Type ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+update event model =
+ let
+ new_model = (Struct.Model.clear_error model)
+ in
+ case event of
+ Struct.Event.None -> (model, Cmd.none)
+
+ (Struct.Event.Failed err) ->
+ (
+ (Struct.Model.invalidate err new_model),
+ Cmd.none
+ )
+
+ (Struct.Event.ServerReplied result) ->
+ (Update.HandleServerReply.apply_to model result)
diff --git a/src/ElmModule/View.elm b/src/ElmModule/View.elm
new file mode 100644
index 0000000..0d6a321
--- /dev/null
+++ b/src/ElmModule/View.elm
@@ -0,0 +1,64 @@
+module ElmModule.View exposing (view)
+
+-- Elm -------------------------------------------------------------------------
+import Html
+import Html.Attributes
+
+-- Shared ----------------------------------------------------------------------
+import Util.Html
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Error
+import Struct.Event
+import Struct.Model
+import Struct.Player
+
+import View.BattleListing
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+view : Struct.Model.Type -> (Html.Html Struct.Event.Type)
+view model =
+ (Html.div
+ [
+ (Html.Attributes.class "fullscreen-module")
+ ]
+ [
+ (Html.main_
+ [
+ ]
+ [
+ (View.BattleListing.get_html
+ "Campaigns"
+ "main-menu-campaigns"
+ (Struct.Player.get_campaigns model.player)
+ ),
+ (View.BattleListing.get_html
+ "Invasions"
+ "main-menu-invasions"
+ (Struct.Player.get_invasions model.player)
+ ),
+ (View.BattleListing.get_html
+ "Events"
+ "main-menu-events"
+ (Struct.Player.get_events model.player)
+ )
+ ]
+ ),
+ (
+ case model.error of
+ Nothing -> (Util.Html.nothing)
+ (Just err) ->
+ (Html.div
+ []
+ [
+ (Html.text (Struct.Error.to_string err))
+ ]
+ )
+ )
+ ]
+ )