summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-10-01 11:34:38 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-10-01 11:34:38 +0200
commitb5bb4f45133e7d89fa85d185d13ec4c7c2ece887 (patch)
tree5cc99bb779e0ad64a253ee53de9c565fe98937ed
parent11533a168693bd31ed1b73ccb02e5b5062d53783 (diff)
downloadtacticians-extension-b5bb4f45133e7d89fa85d185d13ec4c7c2ece887.zip
tacticians-extension-b5bb4f45133e7d89fa85d185d13ec4c7c2ece887.tar.bz2
...
-rw-r--r--manifest.json4
-rw-r--r--src/background/src/ElmModule/Init.elm15
-rw-r--r--src/background/src/Main.elm3
-rw-r--r--www/script/battles.js8
-rw-r--r--www/script/init_background.js6
-rw-r--r--www/script/params.js2
6 files changed, 25 insertions, 13 deletions
diff --git a/manifest.json b/manifest.json
index 7e6c225..63af7cb 100644
--- a/manifest.json
+++ b/manifest.json
@@ -18,10 +18,10 @@
"browser_action": {
"default_icon": "images/to-favicon.svg",
"default_title": "TO - Active Battles",
- "default_popup": "www/index.html"
+ "default_popup": "www/popup.html"
},
"background": {
- "page": "www/index.html"
+ "page": "www/background.html"
}
}
diff --git a/src/background/src/ElmModule/Init.elm b/src/background/src/ElmModule/Init.elm
index 350a070..3320291 100644
--- a/src/background/src/ElmModule/Init.elm
+++ b/src/background/src/ElmModule/Init.elm
@@ -1,6 +1,7 @@
module ElmModule.Init exposing (init)
-- Elm -------------------------------------------------------------------------
+import Json.Decode
-- Extension -------------------------------------------------------------------
import Struct.Event
@@ -14,9 +15,17 @@ import Struct.Model
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-init : Struct.Flags.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
-init flags =
+init : String -> (Struct.Model.Type, (Cmd Struct.Event.Type))
+init encoded_flags =
(
- (Struct.Model.new flags),
+ (Struct.Model.new
+ (
+ case
+ (Json.Decode.decodeString (Struct.Flags.decoder) encoded_flags)
+ of
+ (Err _) -> (Struct.Flags.default)
+ (Ok flags) -> flags
+ )
+ ),
Cmd.none
)
diff --git a/src/background/src/Main.elm b/src/background/src/Main.elm
index 8140041..ffa21fa 100644
--- a/src/background/src/Main.elm
+++ b/src/background/src/Main.elm
@@ -4,14 +4,13 @@ import Html
-- Map -------------------------------------------------------------------
import Struct.Model
import Struct.Event
-import Struct.Flags
import ElmModule.Init
import ElmModule.Subscriptions
import ElmModule.View
import ElmModule.Update
-main : (Program Struct.Flags.Type Struct.Model.Type Struct.Event.Type)
+main : (Program String Struct.Model.Type Struct.Event.Type)
main =
(Html.programWithFlags
{
diff --git a/www/script/battles.js b/www/script/battles.js
index 0040795..4f691f8 100644
--- a/www/script/battles.js
+++ b/www/script/battles.js
@@ -8,7 +8,7 @@ tacticians_online.battles = new Object();
tacticians_online.battles.get =
function ()
{
- tacticians_online.app.battles_in.send(localStorage.getItem("battles"));
+ tacticians_online.app.results_in.send(localStorage.getItem("battles"));
}
tacticians_online.battles.set =
@@ -20,13 +20,13 @@ function (encoded_battles)
tacticians_online.battles.get_value =
function ()
{
- return localStorage.getItem("battles");
+ return (localStorage.getItem("battles") || "");
}
tacticians_online.battles.attach_to =
function (app)
{
- app.ports.get_battles.subscribe(tacticians_online.battles.get);
- app.ports.set_battles.subscribe(tacticians_online.battles.set);
+ app.ports.get_results.subscribe(tacticians_online.battles.get);
+ app.ports.set_results.subscribe(tacticians_online.battles.set);
}
diff --git a/www/script/init_background.js b/www/script/init_background.js
index 399ec21..a6bbdae 100644
--- a/www/script/init_background.js
+++ b/www/script/init_background.js
@@ -1,4 +1,8 @@
-tacticians_online.app = Elm.Main.fullscreen();
+tacticians_online.app =
+ Elm.Main.fullscreen
+ (
+ tacticians_online.params.get_value()
+ );
tacticians_online.params.attach_to(tacticians_online.app);
tacticians_online.battles.attach_to(tacticians_online.app);
diff --git a/www/script/params.js b/www/script/params.js
index 729cd56..b453b08 100644
--- a/www/script/params.js
+++ b/www/script/params.js
@@ -20,7 +20,7 @@ function (encoded_params)
tacticians_online.params.get_value =
function ()
{
- return localStorage.getItem("params");
+ return (localStorage.getItem("params") || "");
}
tacticians_online.params.attach_to =