Commit 36f754d1 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Make restart button configurable

parent ed6693ba
......@@ -15,6 +15,13 @@
</head>
<body>
<script type="text/javascript">
var getParameters = location.search.substring(1);
/* from http://stackoverflow.com/questions/8648892/convert-url-parameters-to-a-javascript-object */
getParameters = getParameters
? JSON.parse('{"' + getParameters.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
function(key, value) { return key===""?value:decodeURIComponent(value) })
: {};
console.log(JSON.stringify(getParameters));
var proto = window.location.protocol;
var mobileBrowser = /* http://stackoverflow.com/a/11381730/4400896 */
navigator.userAgent.match(/Android/i)
......@@ -24,10 +31,12 @@
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i);
var app = Elm.Main.fullscreen({
var appParameters = {
clickableHeader: (proto != "file:"),
showRestart: (proto == "file:"),
minimalInterface : (mobileBrowser != null),
});
};
var app = Elm.Main.fullscreen(appParameters);
app.ports.scrollIntoView.subscribe(
function(elem_id) {
var element = document.getElementById(elem_id);
......
......@@ -31,6 +31,7 @@ import Overlay
type alias Flags =
{ clickableHeader : Bool
, minimalInterface : Bool -- whether to show a more minimal 'mobile' version
, showRestart : Bool -- whether to show a restart-button
}
type alias Model =
......@@ -310,7 +311,7 @@ viewNavigation model =
[ HA.href "javascript: ;", HE.onClick msg ]
[MultiLang.text en de]
in
( if model.flags.minimalInterface
(( if model.flags.minimalInterface
then (::)
[ a main_page_url
[ img
......@@ -324,10 +325,18 @@ viewNavigation model =
]
]
else identity
)
[ [ Html.a [ HA.style
[(,) "font-weight" "bold" ] , HA.href "rails.html" ] [MultiLang.text "Restart" "Neu Starten"] ]
, [ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig"]
) <|
( if model.flags.showRestart
then (::)
[ Html.a
[ HA.style [(,) "font-weight" "bold" ]
, HA.href "rails.html"
]
[ MultiLang.text "Restart" "Neu Starten"]
]
else identity
) <|
[ [ link (ForRails RailPuzzle.undo) "Undo" "Rückgängig"]
, [ link resetCars "Reset All Cars" "Zurücksetzen" ]
, [ Html.span
[ HA.style [(,) "margin-right" "1em"] ]
......@@ -348,6 +357,7 @@ viewNavigation model =
]
, [ Html.map ForMultiLang <| MultiLang.viewSwitcher model.languageSwitcher ]
]
)
|> List.filter (not << List.isEmpty)
|> List.map (Html.li [])
|> Html.ul [ HA.id "navigationbar" ]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment