| summaryrefslogtreecommitdiff |
diff options
| -rw-r--r-- | src/background/src/Action/Ports.elm | 4 | ||||
| -rw-r--r-- | src/background/src/ElmModule/View.elm | 54 | ||||
| -rw-r--r-- | src/background/src/View/Header.elm | 79 | ||||
| -rw-r--r-- | src/background/src/View/Player.elm | 97 | ||||
| -rw-r--r-- | www/background.html | 11 | ||||
| -rw-r--r-- | www/popup.html (renamed from www/index.html) | 5 | ||||
| -rw-r--r-- | www/script/battles.js | 26 | ||||
| -rw-r--r-- | www/script/init_background.js | 5 | ||||
| -rw-r--r-- | www/script/init_popup.js | 5 | ||||
| -rw-r--r-- | www/script/load.js | 12 | ||||
| -rw-r--r-- | www/script/params.js | 8 |
11 files changed, 61 insertions, 245 deletions
diff --git a/src/background/src/Action/Ports.elm b/src/background/src/Action/Ports.elm index 4d83077..9222b08 100644 --- a/src/background/src/Action/Ports.elm +++ b/src/background/src/Action/Ports.elm @@ -1,4 +1,4 @@ port module Action.Ports exposing (..) -port store_params : (Int, String) -> (Cmd msg) -port reset_params : () -> (Cmd msg) +port read_params : () -> (Cmd msg) +port store_results : (String) -> (Cmd msg) diff --git a/src/background/src/ElmModule/View.elm b/src/background/src/ElmModule/View.elm index 946bf8e..32a139f 100644 --- a/src/background/src/ElmModule/View.elm +++ b/src/background/src/ElmModule/View.elm @@ -1,20 +1,13 @@ module ElmModule.View exposing (view) -- Elm ------------------------------------------------------------------------- -import Array - -import Html -import Html.Events -import Html.Attributes -- Extension ------------------------------------------------------------------- import Util.Html -import Struct.Error import Struct.Event import Struct.Model -import View.Player -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -23,49 +16,4 @@ import View.Player -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- view : Struct.Model.Type -> (Html.Html Struct.Event.Type) -view model = - (Html.div - [ - (Html.Attributes.class "fullscreen-module") - ] - [ - ( - case model.error of - Nothing -> (Util.Html.nothing) - (Just err) -> - (Html.div - [] - [ - (Html.text (Struct.Error.to_string err)) - ] - ) - ), - (Html.div - [ - ] - (List.map (View.Player.get_html) (Array.toList model.players)) - ), - (Html.div - [ - ] - [ - (Html.button - [ - (Html.Events.onClick Struct.Event.AddPlayer) - ] - [ - (Html.text "Add Player") - ] - ), - (Html.button - [ - (Html.Events.onClick Struct.Event.StoreParams) - ] - [ - (Html.text "Save Params") - ] - ) - ] - ) - ] - ) +view model = (Util.Html.nothing) diff --git a/src/background/src/View/Header.elm b/src/background/src/View/Header.elm deleted file mode 100644 index fd8e693..0000000 --- a/src/background/src/View/Header.elm +++ /dev/null @@ -1,79 +0,0 @@ -module View.Header exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Map ------------------------------------------------------------------- -import Struct.Event - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -link_html : String -> String -> Bool -> (Html.Html Struct.Event.Type) -link_html src label is_active = - (Html.a - [ - (Html.Attributes.href src) - ] - [ - ( - if (is_active) - then (Html.text label) - else (Html.s [] [(Html.text label)]) - ) - ] - ) - -navigation_html : (Html.Html Struct.Event.Type) -navigation_html = - (Html.nav - [] - [ - (link_html "/about.html" "About" True), - (link_html "/news/" "News" False), - (link_html "/community/" "Community" False), - (link_html "/login/?action=disconnect" "Disconnect" True) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : (Html.Html Struct.Event.Type) -get_html = - (Html.header - [] - [ - (Html.div - [ - (Html.Attributes.class "main-server-logo") - ] - [ - (Html.a - [ - (Html.Attributes.href "http://127.0.0.1") - ] - [ - (Html.img - [ - (Html.Attributes.src "/asset/svg/to-logo-no-bg.svg") - ] - [ - ] - ) - ] - ) - ] - ), - (Html.div - [ - (Html.Attributes.class "main-server-version") - ] - [ - (Html.text "Latest Dev. Build (Mon, 10 Sep 2018 10:30:17 +0000)") - ] - ), - (navigation_html) - ] - ) diff --git a/src/background/src/View/Player.elm b/src/background/src/View/Player.elm deleted file mode 100644 index 07dc292..0000000 --- a/src/background/src/View/Player.elm +++ /dev/null @@ -1,97 +0,0 @@ -module View.Player exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes --- import Html.Events - --- Extension ------------------------------------------------------------------- -import Struct.BattleSummary -import Struct.Event -import Struct.Player - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_item_html : ( - String -> - String -> - Struct.BattleSummary.Type -> - (Html.Html Struct.Event.Type) - ) -get_item_html query_url additional_class item = - (Html.a - [ - (Html.Attributes.class additional_class), - (Html.Attributes.href - ( - query_url - ++ "/battle/?id=" - ++ (Struct.BattleSummary.get_id item) - ) - ) - ] - [ - (Html.div - [ - (Html.Attributes.class "battle-summary-name") - ] - [ - (Html.text (Struct.BattleSummary.get_name item)) - ] - ), - (Html.div - [ - (Html.Attributes.class "battle-summary-date") - ] - [ - (Html.text (Struct.BattleSummary.get_last_edit item)) - ] - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Player.Type -> (Html.Html Struct.Event.Type) -get_html player = - let - query_url = (Struct.Player.get_query_url player) - in - (Html.div - [ - (Html.Attributes.class "player-summary") - ] - [ - (Html.div - [ - (Html.Attributes.class "player-summary-listing-header") - ] - [ - (Html.text (Struct.Player.get_username player)) - ] - ), - (Html.div - [ - (Html.Attributes.class "player-summary-listing-body") - ] - ( - (List.map - (get_item_html query_url "campaign-link") - (Struct.Player.get_campaigns player) - ) - ++ - (List.map - (get_item_html query_url "invasion-link") - (Struct.Player.get_invasions player) - ) - ++ - (List.map - (get_item_html query_url "event-link") - (Struct.Player.get_events player) - ) - ) - ) - ] - ) diff --git a/www/background.html b/www/background.html new file mode 100644 index 0000000..fd648a2 --- /dev/null +++ b/www/background.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> + <head> + </head> + <body> + <script src="/www/script/params.js"></script> + <script src="/www/script/battles.js"></script> + <script src="/www/script/main_background.js"></script> + <script src="/www/script/init_background.js"></script> + </body> +</html> diff --git a/www/index.html b/www/popup.html index 10a422b..0cf3b15 100644 --- a/www/index.html +++ b/www/popup.html @@ -5,7 +5,8 @@ </head> <body> <script src="/www/script/params.js"></script> - <script src="/www/script/main.js"></script> - <script src="/www/script/load.js"></script> + <script src="/www/script/battles.js"></script> + <script src="/www/script/main_popup.js"></script> + <script src="/www/script/init_popup.js"></script> </body> </html> diff --git a/www/script/battles.js b/www/script/battles.js new file mode 100644 index 0000000..dc2ce5a --- /dev/null +++ b/www/script/battles.js @@ -0,0 +1,26 @@ +/******************************************************************************/ +/** Battles Management ********************************************************/ +/******************************************************************************/ +var tacticians_online = tacticians_online || new Object(); + +tacticians_online.battles = new Object(); + +tacticians_online.battles.get = +function () +{ + return localStorage.getItem("battles"); +} + +tacticians_online.battles.set = +function (encoded_battles) +{ + localStorage.setItem("battles", encoded_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); +} + diff --git a/www/script/init_background.js b/www/script/init_background.js new file mode 100644 index 0000000..09fa501 --- /dev/null +++ b/www/script/init_background.js @@ -0,0 +1,5 @@ +tacticians_online.params.load(); + +tacticians_online.app = Elm.Main.fullscreen(); + +tacticians_online.params.attach_to(tacticians_online.app); diff --git a/www/script/init_popup.js b/www/script/init_popup.js new file mode 100644 index 0000000..09fa501 --- /dev/null +++ b/www/script/init_popup.js @@ -0,0 +1,5 @@ +tacticians_online.params.load(); + +tacticians_online.app = Elm.Main.fullscreen(); + +tacticians_online.params.attach_to(tacticians_online.app); diff --git a/www/script/load.js b/www/script/load.js deleted file mode 100644 index c09570b..0000000 --- a/www/script/load.js +++ /dev/null @@ -1,12 +0,0 @@ -tacticians_online.params.load(); - -tacticians_online.app = - Elm.Main.fullscreen - ( - { - frequency: tacticians_online.params.get_frequency(), - players: tacticians_online.params.get_players() - } - ); - -tacticians_online.params.attach_to(tacticians_online.app); diff --git a/www/script/params.js b/www/script/params.js index de42e93..329d180 100644 --- a/www/script/params.js +++ b/www/script/params.js @@ -74,9 +74,17 @@ function (params) tacticians_online.params.set_players(players); } +tacticians_online.params.get_params = +function () +{ + return {get_frequency(), get_players()}; +} + 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.reset_params.subscribe(tacticians_online.params.reset); } + |


