Add links in histogram of powertrails

master
Tomasz Golinski 2022-07-13 19:52:55 +02:00
rodzic 5cc8291488
commit 3d5887218b
3 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -78,7 +78,8 @@ void show_histogram(const pPowertrails& tt, const std::string& caption, bool htm
std::map<std::string, int> histogram;
for (auto el : tt) {
histogram[el.second->name] = 100 * el.second->found / el.second->caches.size();
std::string link = "<a href=\"https://opencaching.pl/powerTrail.php?ptAction=showSerie&ptrail=" + std::to_string(el.second->number) + "\">" + el.second->name + "</a>";
histogram[link] = 100 * el.second->found / el.second->caches.size();
}
show_histogram(histogram, caption, html, sort_by_val);
@ -110,7 +111,7 @@ void show_histogram(const std::map<std::string, int>& data, const std::string& c
std::cout << "<h2>" << caption << "</h2>\n";
std::cout << "<div class=\"histogram " << string_mangle(caption) << "\">\n";
for (auto own : pairs) {
htmlencode(own.first);
if (!own.first.starts_with("<a href=")) htmlencode(own.first);
if (own.first.empty()) own.first = "[unknown]";
if (i < HIST_MAX)
@ -323,7 +324,7 @@ void header_html() {
std::cout << "<html lang=\"en\">\n";
std::cout << " <head>\n";
std::cout << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=13\">\n";
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=14\">\n";
std::cout << " <title>Geocaching stats</title>\n";
std::cout << "</head>\n";
std::cout << "<body>\n";

Wyświetl plik

@ -167,14 +167,13 @@ td.dt_null {
.bar > .text {
font-weight: 600;
display: flex;
display: block;
align-items: center;
height: 40px;
width: 200px;
background-color: white;
position: absolute;
left: 0;
justify-content: flex-end;
text-align: right;
}

Wyświetl plik

@ -117,6 +117,9 @@ void PowertrailDB::read_from_json(std::string file) {
Debug(1) << "Cache file: " << file << " corrupted.";
std::exit(EXIT_FAILURE);
}
for (auto& p: data)
p.second.number = p.first;
};
void PowertrailDB::save_to_json(std::string file) {