4 #include "util/html/sorted_table.h" 6 #include "absl/strings/str_join.h" 16 THFormatter(
const char* t) : token(t) {}
17 void operator()(
string* out, StringPiece str)
const {
18 absl::StrAppend(out,
"<", token,
">", str,
"</", token,
">");
22 const char kCdnPrefix[] =
"https://cdn.jsdelivr.net/gh/romange/gaia/util/html";
25 string SortedTable::HtmlStart() {
29 <meta charset="UTF-8"> 30 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/css/theme.bootstrap_4.min.css"> --> 31 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/css/theme.blue.min.css"> 32 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/css/jquery.tablesorter.pager.min.css"> 33 <link rel="stylesheet" href=")"; 34 result.append(kCdnPrefix); 35 result.append(R"(/style.css"> 36 <script src="//code.jquery.com/jquery-latest.min.js"></script> 37 <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/js/jquery.tablesorter.min.js"></script> 38 <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/js/jquery.tablesorter.widgets.min.js"></script> 39 <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.1/js/extras/jquery.tablesorter.pager.min.js"></script> 40 <script src=")").append(kCdnPrefix); 41 result.append(R"(/main.js"></script> 47 void SortedTable::StartTable(
const std::vector<StringPiece>& header,
string* dest) {
48 string col_names = absl::StrCat(
"\n", absl::StrJoin(header,
"\n", THFormatter{
"th"}),
"\n");
50 <table class="tablesorter" id="tablesorter"> 51 <thead class="thead-dark"> <!-- add class="thead-light" for a light header -->)"). 52 append(absl::StrCat("<tr>", col_names,
"</tr>",
"</thead><tfoot>\n"));
53 dest->append(absl::StrCat(
"<tr>", col_names));
54 dest->append(R
"(</tr> </tfoot> 58 void SortedTable::EndTable(std::string* dest) {
59 dest->append(
"</tbody></table>\n");
60 dest->append(R
"(<div class="ts-pager"> 62 <div class="btn-group btn-group-sm mx-1" role="group"> 63 <button type="button" class="btn btn-secondary first" title="first">⇤</button> 64 <button type="button" class="btn btn-secondary prev" title="previous">←</button> 65 <button type="button" class="btn btn-secondary next" title="next">→</button> 66 <button type="button" class="btn btn-secondary last" title="last">⇥</button> 68 <span class="pagedisplay"></span> 69 <select class="form-control-sm custom-select px-1 pagesize" title="Select page size"> 70 <option selected="selected" value="10">10</option> 71 <option value="20">20</option> 72 <option value="30">30</option> 73 <option value="all">All Rows</option> 75 <select class="form-control-sm custom-select px-4 mx-1 pagenum" title="Select page number"></select> 80 void SortedTable::Row(
const std::vector<StringPiece>& row, std::string* dest) {
81 absl::StrAppend(dest,
"<tr>\n", absl::StrJoin(row,
"\n", THFormatter{
"td"}),
"</tr>\n");