Introduce JS for improved back button behaviour #121
|
@ -1079,7 +1079,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "golgi"
|
name = "golgi"
|
||||||
version = "0.1.4"
|
version = "0.1.4"
|
||||||
source = "git+https://git.coopcloud.tech/golgi-ssb/golgi#ca4c1114ddf328b818144c5a1af0187b1357e9be"
|
source = "git+https://git.coopcloud.tech/golgi-ssb/golgi.git#ca4c1114ddf328b818144c5a1af0187b1357e9be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"async-stream 0.3.3",
|
"async-stream 0.3.3",
|
||||||
|
@ -2331,7 +2331,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peach-web"
|
name = "peach-web"
|
||||||
version = "0.6.17"
|
version = "0.6.18"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "peach-web"
|
name = "peach-web"
|
||||||
version = "0.6.17"
|
version = "0.6.18"
|
||||||
authors = ["Andrew Reid <gnomad@cryptolab.net>", "Max Fowler <max@mfowler.info>"]
|
authors = ["Andrew Reid <gnomad@cryptolab.net>", "Max Fowler <max@mfowler.info>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "peach-web is a web application which provides a web interface for monitoring and interacting with the PeachCloud device. This allows administration of the single-board computer (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related plugins."
|
description = "peach-web is a web application which provides a web interface for monitoring and interacting with the PeachCloud device. This allows administration of the single-board computer (ie. Raspberry Pi) running PeachCloud, as well as the ssb-server and related plugins."
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
use maud::{html, PreEscaped, DOCTYPE};
|
use maud::{html, PreEscaped, DOCTYPE};
|
||||||
|
|
||||||
|
/// JavaScript event listener for the back button on the top navigation bar of
|
||||||
|
/// the UI.
|
||||||
|
///
|
||||||
|
/// When the button is clicked, prevent the default behaviour and invoke
|
||||||
|
/// the history API to load the previous URL (page) in the history list.
|
||||||
|
fn js_back_button_script() -> PreEscaped<String> {
|
||||||
|
html! {
|
||||||
|
(PreEscaped("
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
document.getElementById('backButton').onclick = function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
history.back();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Base template builder.
|
/// Base template builder.
|
||||||
///
|
///
|
||||||
/// Takes an HTML body as input and splices it into the base template.
|
/// Takes an HTML body as input and splices it into the base template.
|
||||||
|
@ -14,6 +34,7 @@ pub fn build_template(body: PreEscaped<String>, theme: String) -> PreEscaped<Str
|
||||||
meta name="viewport" content="width=devide-width, initial-scale=1.0";
|
meta name="viewport" content="width=devide-width, initial-scale=1.0";
|
||||||
link rel="stylesheet" href="/css/peachcloud.css";
|
link rel="stylesheet" href="/css/peachcloud.css";
|
||||||
link rel="stylesheet" href="/css/_variables.css";
|
link rel="stylesheet" href="/css/_variables.css";
|
||||||
|
(js_back_button_script())
|
||||||
title { "PeachCloud" }
|
title { "PeachCloud" }
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn build_template(
|
||||||
html! {
|
html! {
|
||||||
(PreEscaped("<!-- Top navigation bar -->"))
|
(PreEscaped("<!-- Top navigation bar -->"))
|
||||||
nav class="nav-bar" {
|
nav class="nav-bar" {
|
||||||
a class="nav-item" href=[back] title="Back" {
|
a id="backButton" class="nav-item" href=[back] title="Back" {
|
||||||
img class="icon-medium nav-icon-left icon-active" src="/icons/back.svg" alt="Back";
|
img class="icon-medium nav-icon-left icon-active" src="/icons/back.svg" alt="Back";
|
||||||
}
|
}
|
||||||
h1 class="nav-title" { (title) }
|
h1 class="nav-title" { (title) }
|
||||||
|
|
Loading…
Reference in New Issue