From dfd41911963eaa7dea40d18e38e5ac2a066ccd46 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Tue, 12 Apr 2016 13:41:11 +0800 Subject: [PATCH] autorefresh version of index page added --- main.cpp | 5 +++++ src/page.h | 7 ++++--- src/templates/css/style.css | 21 +++++++++++++++++++++ src/templates/header.html | 4 +++- src/templates/index.html | 12 ++++++++++-- 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index ffa6b45..0546462 100644 --- a/main.cpp +++ b/main.cpp @@ -47,6 +47,11 @@ int main() { return xmrblocks.index(); }); + CROW_ROUTE(app, "/autorefresh") + ([&]() { + bool refresh_page {true}; + return xmrblocks.index(refresh_page); + }); CROW_ROUTE(app, "/css/style.css") ([&]() { diff --git a/src/page.h b/src/page.h index f4ae838..da3c500 100644 --- a/src/page.h +++ b/src/page.h @@ -51,7 +51,7 @@ namespace xmreg { } string - index() + index(bool refresh_page = false) { //get current server timestamp time_t server_timestamp = std::time(nullptr); @@ -61,9 +61,10 @@ namespace xmreg { // initalise page tempate map with basic info about blockchain mstch::map context { - {"height", fmt::format("{:d}", height)}, + {"refresh", refresh_page}, + {"height", fmt::format("{:d}", height)}, {"server_timestamp", xmreg::timestamp_to_str(server_timestamp)}, - {"blocks", mstch::array()} + {"blocks", mstch::array()} }; // number of last blocks to show diff --git a/src/templates/css/style.css b/src/templates/css/style.css index 5197f82..7189e3e 100644 --- a/src/templates/css/style.css +++ b/src/templates/css/style.css @@ -2,8 +2,29 @@ tr { font-family: "Lucida Console", Monaco, monospace; font-size : 12px; height: 22px; + color: black; } td { text-align: center; +} + +a:link { + text-decoration: none; + color: black; +} + +a:visited { + text-decoration: none; + color: black; +} + +a:hover { + text-decoration: underline; + color: black; +} + +a:active { + text-decoration: none; + color: black; } \ No newline at end of file diff --git a/src/templates/header.html b/src/templates/header.html index 04818e5..762b672 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -2,7 +2,9 @@ - + {{#refresh}} + + {{/refresh}} Hidden Monero Explorer diff --git a/src/templates/index.html b/src/templates/index.html index e6601c1..8dd554a 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,6 +1,14 @@ -

Hidden Monero blockchain explorer

-

Current height: {{height}} | Server time {{server_timestamp}}

+

Hidden Monero Blockchain Explorer

+

+ Current height: {{height}} | Server time {{server_timestamp}} | + {{#refresh}} + Autorefresh ON (15 s) + {{/refresh}} + {{^refresh}} + Autorefresh OFF + {{/refresh}} +