autorefresh version of index page added

master
moneroexamples 9 years ago
parent 516a66b376
commit dfd4191196

@ -47,6 +47,11 @@ int main() {
return xmrblocks.index(); return xmrblocks.index();
}); });
CROW_ROUTE(app, "/autorefresh")
([&]() {
bool refresh_page {true};
return xmrblocks.index(refresh_page);
});
CROW_ROUTE(app, "/css/style.css") CROW_ROUTE(app, "/css/style.css")
([&]() { ([&]() {

@ -51,7 +51,7 @@ namespace xmreg {
} }
string string
index() index(bool refresh_page = false)
{ {
//get current server timestamp //get current server timestamp
time_t server_timestamp = std::time(nullptr); time_t server_timestamp = std::time(nullptr);
@ -61,6 +61,7 @@ namespace xmreg {
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"refresh", refresh_page},
{"height", fmt::format("{:d}", height)}, {"height", fmt::format("{:d}", height)},
{"server_timestamp", xmreg::timestamp_to_str(server_timestamp)}, {"server_timestamp", xmreg::timestamp_to_str(server_timestamp)},
{"blocks", mstch::array()} {"blocks", mstch::array()}

@ -2,8 +2,29 @@ tr {
font-family: "Lucida Console", Monaco, monospace; font-family: "Lucida Console", Monaco, monospace;
font-size : 12px; font-size : 12px;
height: 22px; height: 22px;
color: black;
} }
td { td {
text-align: center; 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;
}

@ -2,7 +2,9 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<!--<meta http-equiv="refresh" content="60">--> {{#refresh}}
<meta http-equiv="refresh" content="15">
{{/refresh}}
<title>Hidden Monero Explorer</title> <title>Hidden Monero Explorer</title>
<link rel="stylesheet" type="text/css" href="/css/style.css"> <link rel="stylesheet" type="text/css" href="/css/style.css">
</head> </head>

@ -1,6 +1,14 @@
<h1>Hidden Monero blockchain explorer</h1> <h1>Hidden Monero Blockchain Explorer</h1>
<h2>Current height: {{height}} | Server time {{server_timestamp}}</h2> <h2>
Current height: {{height}} | Server time {{server_timestamp}} |
{{#refresh}}
<a href="/">Autorefresh ON (15 s)</a>
{{/refresh}}
{{^refresh}}
<a href="/autorefresh">Autorefresh OFF</a>
{{/refresh}}
</h2>
<div> <div>
<ul> <ul>
<table> <table>

Loading…
Cancel
Save