summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-09-28 15:42:55 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-09-28 15:42:55 +0200
commitfc06ceae1de311f3aa6383fc9c37f87506005459 (patch)
tree34c8e79acbd4e9e131f3e5adaa69444043778fd1
parent55f01ce3978f12eafe7e726ee52133169c84b2bc (diff)
downloadtacticians-extension-fc06ceae1de311f3aa6383fc9c37f87506005459.zip
tacticians-extension-fc06ceae1de311f3aa6383fc9c37f87506005459.tar.bz2
...
-rw-r--r--src/background/src/ElmModule/Subscriptions.elm7
-rw-r--r--src/background/src/ElmModule/Update.elm13
-rw-r--r--src/background/src/Struct/Event.elm7
-rw-r--r--src/background/src/Update/AddPlayer.elm1
-rw-r--r--src/background/src/Update/RefreshBattles.elm1
-rw-r--r--src/background/src/Update/StoreParams.elm2
-rw-r--r--src/shared/Action/Ports.elm12
-rw-r--r--www/script/battles.js7
-rw-r--r--www/script/params.js14
9 files changed, 35 insertions, 29 deletions
diff --git a/src/background/src/ElmModule/Subscriptions.elm b/src/background/src/ElmModule/Subscriptions.elm
index e9b557e..77ca1ad 100644
--- a/src/background/src/ElmModule/Subscriptions.elm
+++ b/src/background/src/ElmModule/Subscriptions.elm
@@ -2,7 +2,9 @@ module ElmModule.Subscriptions exposing (..)
-- Elm -------------------------------------------------------------------------
--- Main Menu -------------------------------------------------------------------
+-- Extension -------------------------------------------------------------------
+import Action.Ports
+
import Struct.Model
import Struct.Event
@@ -14,4 +16,5 @@ import Struct.Event
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
subscriptions : Struct.Model.Type -> (Sub Struct.Event.Type)
-subscriptions model = Sub.none
+subscriptions model =
+ (Action.Ports.params_in (\s -> (Struct.Event.ReadParams s)))
diff --git a/src/background/src/ElmModule/Update.elm b/src/background/src/ElmModule/Update.elm
index 9e162fe..aac12f6 100644
--- a/src/background/src/ElmModule/Update.elm
+++ b/src/background/src/ElmModule/Update.elm
@@ -2,14 +2,12 @@ module ElmModule.Update exposing (update)
-- Elm -------------------------------------------------------------------------
--- Main Menu -------------------------------------------------------------------
+-- Extension -------------------------------------------------------------------
import Struct.Event
import Struct.Model
-import Update.AddPlayer
import Update.HandleServerReply
import Update.RefreshBattles
-import Update.StoreParams
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
@@ -30,17 +28,10 @@ update event model =
case event of
Struct.Event.None -> (model, Cmd.none)
- (Struct.Event.SetUsername str) -> (model, Cmd.none)
- (Struct.Event.SetID str) -> (model, Cmd.none)
- (Struct.Event.SetURLPrefix str) -> (model, Cmd.none)
- (Struct.Event.SetFrequency val) -> (model, Cmd.none)
+ (Struct.Event.ReadParams (int, str)) -> (model, Cmd.none)
Struct.Event.ShouldRefresh -> (Update.RefreshBattles.apply_to model)
- Struct.Event.StoreParams -> (Update.StoreParams.apply_to model)
-
- Struct.Event.AddPlayer -> (Update.AddPlayer.apply_to model)
-
(Struct.Event.Failed err) ->
(
(Struct.Model.invalidate err new_model),
diff --git a/src/background/src/Struct/Event.elm b/src/background/src/Struct/Event.elm
index eafd812..2b8bf0e 100644
--- a/src/background/src/Struct/Event.elm
+++ b/src/background/src/Struct/Event.elm
@@ -13,13 +13,8 @@ import Struct.ServerReply
type Type =
None
| Failed Struct.Error.Type
- | AddPlayer
+ | ReadParams (Int, String)
| ShouldRefresh
- | SetUsername String
- | SetID String
- | SetURLPrefix String
- | SetFrequency Int
- | StoreParams
| ServerReplied (Result Http.Error (List Struct.ServerReply.Type))
attempted : (Result.Result err val) -> Type
diff --git a/src/background/src/Update/AddPlayer.elm b/src/background/src/Update/AddPlayer.elm
index ed9da4a..3d7c777 100644
--- a/src/background/src/Update/AddPlayer.elm
+++ b/src/background/src/Update/AddPlayer.elm
@@ -5,7 +5,6 @@ import Array
-- Extension -------------------------------------------------------------------
import Struct.Event
-import Struct.Flags
import Struct.Model
import Struct.Player
diff --git a/src/background/src/Update/RefreshBattles.elm b/src/background/src/Update/RefreshBattles.elm
index 2ff739f..513a295 100644
--- a/src/background/src/Update/RefreshBattles.elm
+++ b/src/background/src/Update/RefreshBattles.elm
@@ -7,7 +7,6 @@ import Array
import Comm.GetBattles
import Struct.Event
-import Struct.Flags
import Struct.Model
--------------------------------------------------------------------------------
diff --git a/src/background/src/Update/StoreParams.elm b/src/background/src/Update/StoreParams.elm
index f369be8..3472c13 100644
--- a/src/background/src/Update/StoreParams.elm
+++ b/src/background/src/Update/StoreParams.elm
@@ -24,7 +24,7 @@ apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
apply_to model =
(
model,
- (Action.Ports.store_params
+ (Action.Ports.set_params
(
(Struct.Flags.get_frequency model.flags),
(Json.Encode.encode
diff --git a/src/shared/Action/Ports.elm b/src/shared/Action/Ports.elm
index 460defc..70d5183 100644
--- a/src/shared/Action/Ports.elm
+++ b/src/shared/Action/Ports.elm
@@ -1,5 +1,11 @@
port module Action.Ports exposing (..)
-port read_params : () -> (Cmd msg)
-port store_params : (Int, String) -> (Cmd msg)
-port store_results : (String) -> (Cmd msg)
+port get_params : () -> (Cmd msg)
+port params_in : ((Int, String) -> msg) -> (Sub msg)
+port set_params : (Int, String) -> (Cmd msg)
+
+port get_results : () -> (Cmd msg)
+port results_in : (String -> msg) -> (Sub msg)
+port set_results : (String) -> (Cmd msg)
+
+port set_signal : (Bool) -> (Cmd msg)
diff --git a/www/script/battles.js b/www/script/battles.js
index dc2ce5a..5e90959 100644
--- a/www/script/battles.js
+++ b/www/script/battles.js
@@ -17,6 +17,13 @@ function (encoded_battles)
localStorage.setItem("battles", encoded_battles);
}
+tacticians_online.battles.read_battles =
+function ()
+{
+ tacticians_online.app.battles_in.send(tacticians_online.battles.get());
+}
+
+
tacticians_online.battles.attach_to =
function (app)
{
diff --git a/www/script/params.js b/www/script/params.js
index 329d180..14d2674 100644
--- a/www/script/params.js
+++ b/www/script/params.js
@@ -66,7 +66,7 @@ function (players)
localStorage.setItem("players", tacticians_online.params.private.players);
}
-tacticians_online.params.store_params =
+tacticians_online.params.set_params =
function (params)
{
var [frequency, players] = params;
@@ -74,17 +74,23 @@ function (params)
tacticians_online.params.set_players(players);
}
-tacticians_online.params.get_params =
+tacticians_online.params.js_get =
function ()
{
return {get_frequency(), get_players()};
}
+tacticians_online.params.get =
+function ()
+{
+ tacticians_online.app.params_in.send(tacticians_online.params.js_get());
+}
+
tacticians_online.params.attach_to =
function (app)
{
- app.ports.get_params.subscribe(tacticians_online.params.get_params);
- app.ports.store_params.subscribe(tacticians_online.params.store_params);
+ app.ports.get_params.subscribe(tacticians_online.params.get);
+ app.ports.set_params.subscribe(tacticians_online.params.set);
app.ports.reset_params.subscribe(tacticians_online.params.reset);
}