Commit 6dcb1f45 authored by Thorsten Wißmann's avatar Thorsten Wißmann 🐧
Browse files

Don't make header clickable in local mode

parent 8deb1632
......@@ -25,11 +25,13 @@ $(TARGET): src/Main.elm $(SRC) elm-package.json
clean:
rm -f $(TARGET)
#INSTALL_SSH=uber:html/p/rails/
#INSTALL_HTTP=http://thorsten-wissmann.de/p/rails/
INSTALL_SSH_UBER=uber:html/p/rails/
INSTALL_HTTP_UBER=http://thorsten-wissmann.de/p/rails/
INSTALL_SSH=i8:web/rails/
INSTALL_HTTP=https://www8.cs.fau.de/ext/thorsten/rails
install: $(CSS) rails.html $(IMG) $(wildcard *.js)
rsync -Pravdtze ssh $^ $(INSTALL_SSH)
rsync -Pravdtze ssh $^ $(INSTALL_SSH_UBER)
@echo $(INSTALL_HTTP_UBER)/rails.html
@echo $(INSTALL_HTTP)/rails.html
......@@ -14,7 +14,11 @@
</head>
<body>
<script type="text/javascript">
var app = Elm.Main.fullscreen();
var proto = window.location.protocol;
console.log(proto);
var app = Elm.Main.fullscreen({
clickableHeader: (proto != "file:"),
});
app.ports.scrollIntoView.subscribe(
function(elem_id) {
var element = document.getElementById(elem_id);
......@@ -43,6 +47,37 @@
a.click();
document.body.removeChild(a);
});
app.ports.svgScreenshot.subscribe(
function(name) {
var svg = document.getElementsByClassName('railPuzzle')[0];
var cssText = "";
for (var style_idx = 0; style_idx < document.styleSheets.length ; style_idx ++) {
var cssRules = document.styleSheets[style_idx].cssRules;
for (var i = 0; i < cssRules.length ; i ++) {
cssText = cssText + cssRules[i].cssText + "\n";
}
}
var cdata = document.createTextNode(cssText);
var style = document.createElement("style");
style.setAttribute("type", "text/css");
style.appendChild(cdata);
var defs = document.createElement("defs");
defs.appendChild(style);
svg.insertBefore(defs, svg.firstChild);
/* from http://stackoverflow.com/a/20194533/4400896 */
var svgSource =
'<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
+ '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'
+ svg.outerHTML;
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([svgSource], {encoding:"UTF-8",type:"image/svg+xml;charset=UTF-8"}));
a.download = name + ".svg";
/* a.download = 'test.txt'; */
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
});
</script>
</body>
</html>
......
......@@ -28,6 +28,10 @@ import Shunt
import RailPuzzle.History as RPHist
import MultiLang
type alias Flags =
{ clickableHeader : Bool
}
type alias Model =
{ rails : RailPuzzle.Model
, network_index : Int -- the index of the rail network in the RailExample.db
......@@ -36,6 +40,7 @@ type alias Model =
, queries : Array (List Int) -- queries to solve for the current puzzle
, smv : NuSmvInput.Model
, languageSwitcher : MultiLang.Model
, flags : Flags
}
type Msg
......@@ -47,7 +52,7 @@ type Msg
| NextPuzzle
main =
Html.program
Html.programWithFlags
{ init = init
, view = view
, update = update
......@@ -57,7 +62,7 @@ main =
initial_network_index : Int
initial_network_index = 1 - 1
init =
init flags =
let
ex = RailExample.by_idx initial_network_index
initial_query =
......@@ -83,6 +88,7 @@ init =
, queries = Array.fromList ex.queries
, query_index = 0
, languageSwitcher = MultiLang.init
, flags = flags
}
, Cmd.none
)
......@@ -211,18 +217,26 @@ updateRails : (RailPuzzle.Model -> RailPuzzle.Model) -> Model -> Model
updateRails updater m =
{ m | rails = updater m.rails }
viewHeader : Html Msg
viewHeader =
viewHeader : Bool -> Html Msg
viewHeader clickableHeader =
let
main_page_url =
if clickableHeader
then [ HA.href "/" ]
else []
in
div
[ HA.id "tmpl_header" ]
[ img
[ HA.class "tcs_logo"
, HA.src "logo.png"
] []
, a
[ HA.href "/"
, HA.class "tmpl_header_logo_txt"
[ a
main_page_url
[
img
[ HA.class "tcs_logo"
, HA.src "logo.png"
] []
]
, a
([ HA.class "tmpl_header_logo_txt" ] ++ main_page_url)
[ text "Theoretische Informatik" ]
, img
[ HA.class "fau_logo"
......@@ -303,7 +317,7 @@ view : Model -> Html Msg
view model =
div [HA.class <| MultiLang.class model.languageSwitcher]
[ div [ HA.id "pagewrap" ]
[ viewHeader
[ viewHeader model.flags.clickableHeader
, viewNavigation model
, div [HA.classList
[ ("taskOrCongrats", True)
......
......@@ -41,6 +41,7 @@ type Msg
| ShowSmvFile
| DownloadSmvFile
| StickToBottom Bool
| Screenshot
init : (Model, RPCmd.Command)
init =
......@@ -99,6 +100,11 @@ update msg model =
DownloadSmvFile ->
re ()
|> Maybe.map Ports.downloadPlainText
Screenshot ->
model.rail_example
|> Maybe.map (\x ->
Ports.svgScreenshot x.name
)
_ ->
Nothing
)
......@@ -163,6 +169,9 @@ update msg model =
DownloadSmvFile ->
plain model
Screenshot ->
plain model
nextTraceCommand : Int -> Model -> Model
nextTraceCommand delta model =
case (model.validated_trace) of
......@@ -383,6 +392,11 @@ viewSmvOptions model =
, Html.text "Stick to the bottom"
]
]
--, Html.div []
-- [ Html.button
-- [ HE.onClick Screenshot
-- ] [Html.text "Screenshot"]
-- ]
]
, Html.td [HA.class "traceInput" ]
[ Html.textarea
......
......@@ -9,6 +9,12 @@ port scrollIntoViewString : String -> Cmd msg
-}
port scrollIntoView : String -> Cmd msg
{-|
Make a screenshot of the rail network as an svg file.
The parameter is the basic filename (without the file extension)
-}
port svgScreenshot : String -> Cmd msg
port stringInNewTab : String -> Cmd msg
{-|
......
......@@ -161,7 +161,7 @@ inglenook_422 =
, [ RT.Further, RT.Further, RT.Choose 1, RT.Choose 0, RT.Further ]
]
, queries = []
, rotation = -20
, rotation = 0
}
inglenook_533 =
......@@ -185,7 +185,7 @@ inglenook_533 =
, [ RT.Further, RT.Further, RT.Further, RT.Choose 1, RT.Choose 0, RT.Further, RT.Further ]
]
, queries = []
, rotation = -20
, rotation = 0
}
merge_sort n =
......
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