Port the frontend.
Enable ethernet connection.
This commit is contained in:
parent
08c904ba12
commit
29b952303a
9 changed files with 94 additions and 56 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.swp
|
|
@ -31,8 +31,8 @@ config :nerves_firmware_ssh,
|
|||
node_name = if Mix.env() != :prod, do: "firmware"
|
||||
|
||||
config :nerves_init_gadget,
|
||||
ifname: "usb0",
|
||||
address_method: :dhcpd,
|
||||
ifname: "eth0",
|
||||
address_method: :dhcp,
|
||||
mdns_domain: "nerves.local",
|
||||
node_name: node_name,
|
||||
node_host: :mdns_domain
|
||||
|
|
5
ui/lib/signal_morse.ex
Normal file
5
ui/lib/signal_morse.ex
Normal file
|
@ -0,0 +1,5 @@
|
|||
defmodule Ui.SignalMorse do
|
||||
def signal do
|
||||
IO.puts("bleep bloop")
|
||||
end
|
||||
end
|
|
@ -2,6 +2,37 @@ defmodule UiWeb.PageController do
|
|||
use UiWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
render(conn, "index.html")
|
||||
conn
|
||||
|> send_resp(201, "")
|
||||
end
|
||||
|
||||
def instructions(conn, _params) do
|
||||
conn
|
||||
|> render(:instructions)
|
||||
end
|
||||
|
||||
def morse(conn, _params) do
|
||||
conn
|
||||
|> render(:morse)
|
||||
end
|
||||
|
||||
def start(conn, _params) do
|
||||
now = System.system_time(:second)
|
||||
|
||||
case get_start_time() do
|
||||
start_time when start_time + 35 <= now ->
|
||||
System.put_env("MORSE_START_TIME", Integer.to_string(now))
|
||||
Ui.SignalMorse.signal()
|
||||
text(conn, "Done.")
|
||||
_ ->
|
||||
text(conn, "It is still in progress...")
|
||||
end
|
||||
end
|
||||
|
||||
defp get_start_time() do
|
||||
case System.get_env("MORSE_START_TIME") do
|
||||
nil -> 0
|
||||
start_time -> String.to_integer(start_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,10 +17,15 @@ defmodule UiWeb.Router do
|
|||
pipe_through :browser
|
||||
|
||||
get "/", PageController, :index
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
# scope "/api", UiWeb do
|
||||
# pipe_through :api
|
||||
# end
|
||||
get "/ZZZZ", PageController, :instructions
|
||||
get "/morse", PageController, :instructions
|
||||
get "/esrom", PageController, :instructions
|
||||
|
||||
get "/0B13", PageController, :morse
|
||||
get "/OB13", PageController, :morse
|
||||
get "/seinlamp", PageController, :morse
|
||||
|
||||
get "/start", PageController, :start
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,22 +4,10 @@
|
|||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Ui · Phoenix Framework</title>
|
||||
<title>Esrom Geocache</title>
|
||||
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<section class="container">
|
||||
<nav role="navigation">
|
||||
<ul>
|
||||
<li><a href="https://hexdocs.pm/phoenix/overview.html">Get Started</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
<a href="http://phoenixframework.org/" class="phx-logo">
|
||||
<img src="<%= Routes.static_path(@conn, "/images/phoenix.png") %>" alt="Phoenix Framework Logo"/>
|
||||
</a>
|
||||
</section>
|
||||
</header>
|
||||
<main role="main" class="container">
|
||||
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
|
||||
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<section class="phx-hero">
|
||||
<h1><%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
|
||||
<p>A productive web framework that<br/>does not compromise speed or maintainability.</p>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<article class="column">
|
||||
<h2>Resources</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://hexdocs.pm/phoenix/overview.html">Guides & Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/phoenixframework/phoenix">Source</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/phoenixframework/phoenix/blob/v1.4/CHANGELOG.md">v1.4 Changelog</a>
|
||||
</li>
|
||||
</ul>
|
||||
</article>
|
||||
<article class="column">
|
||||
<h2>Help</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://elixirforum.com/c/phoenix-forum">Forum</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://webchat.freenode.net/?channels=elixir-lang">#elixir-lang on Freenode IRC</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/elixirphoenix">Twitter @elixirphoenix</a>
|
||||
</li>
|
||||
</ul>
|
||||
</article>
|
||||
</section>
|
2
ui/lib/ui_web/templates/page/instructions.html.eex
Normal file
2
ui/lib/ui_web/templates/page/instructions.html.eex
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>Welcome geocacher, you will need to go to the first coordinate and start from there.</p>
|
||||
<p>Good luck!</p>
|
41
ui/lib/ui_web/templates/page/morse.html.eex
Normal file
41
ui/lib/ui_web/templates/page/morse.html.eex
Normal file
|
@ -0,0 +1,41 @@
|
|||
<h1>Welcome to <a href="https://www.geocaching.com/geocache/GC7C642_esrom">Esrom</a>!</h1>
|
||||
<h2>en:<br>Push the Start button below to get <span style="color:red">UVW</span><span style="color:blue">XYZ</span>. You can find the geocache at N 52° 40.<span style="color:red">UVW</span>' E 004° 53.<span style="color:blue">XYZ</span>'</h2>
|
||||
<h2>nl:<br>Druk op de Start knop hieronder om <span style="color:red">UVW</span><span style="color:blue">XYZ</span> te vinden. Je kunt dan de geocache vinden op N 52° 40.<span style="color:red">UVW</span>' E 004° 53.<span style="color:blue">XYZ</span>'</h2>
|
||||
|
||||
<div id="buttonwrap">
|
||||
<input onclick="start()" value="Start" type="button" class="button">
|
||||
<p id="response"></p>
|
||||
</div>
|
||||
|
||||
<a href="http://www.geochecker.com/index.php?code=d9dbdc4542a4911a5f81a51bc9312a35&action=check&wp=47433743363432&name=4573726f6d">en: check your coordinate on GeoChecker.com nl: controleer je coördinaat op GeoChecker.</a>
|
||||
<input type="button" onclick="givehint()" value="Click here for a hint!" id="stupidbutton">
|
||||
<div id="givehint" style="visibility:hidden">
|
||||
<p>en: Position yourself on the bridge. Watch carefully around to windows of houses, remember this is a nightly geocache. During daytime it is quite hard to see, but not impossible. After pushing the button, it takes 3
|
||||
seconds to start. The whole process takes about 35 sec. During the process it cannot be stopped nor restarted. You can start it all over again as much as you like. In case you are really stuck, you could try to contact me via WhatsApp on number +31 6 41633689. Best of luck to you!</p>
|
||||
<p>nl: Ga op de brug staan. Kijk goed om je heen naar ramen van woningen en realiseer je dat dit een een nachtcache is. Overdag is het slecht te zien, maar niet onmogelijk. Na het indrukken van de knop duurt het 3 seconden
|
||||
voordat het begint. Het hele proces duurt ongeveer 35 sec. Het proces kan niet gestopt of herstart worden. Je kunt het zo vaak starten als je wilt. Als het helemaal niet lukt zou je me kunnen proberen te bereiken via WhatsApp nummer 06-41633689. Veel plezier!</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var responseP = document.getElementById("response");
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
responseP.innerHTML = this.responseText;
|
||||
}
|
||||
};
|
||||
|
||||
function start() {
|
||||
responseP.innerHTML = "Starting...";
|
||||
xhttp.open("GET", "/start", true);
|
||||
xhttp.send();
|
||||
setTimeout(function() {
|
||||
responseP.innerHTML = "Started.";
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function givehint() {
|
||||
document.getElementById("givehint").style.visibility = "visible";
|
||||
}
|
||||
</script>
|
Loading…
Reference in a new issue