diff --git a/ajaxui/ajaxui.c b/ajaxui/ajaxui.c
index 88d435bc..f452694a 100644
--- a/ajaxui/ajaxui.c
+++ b/ajaxui/ajaxui.c
@@ -56,6 +56,63 @@ const char *ajax_tabnames[] = {
[AJAX_TAB_ABOUT] = "About",
};
+/**
+ * AJAX table header
+ */
+void
+ajax_table_header(http_connection_t *hc, tcp_queue_t *tq,
+ const char *names[], int weights[],
+ int scrollbar, int columnsizes[])
+{
+ int n = 0, i, tw = 0;
+ while(names[n]) {
+ tw += weights[n];
+ n++;
+ }
+
+ for(i = 0; i < n; i++)
+ columnsizes[i] = 100 * weights[i] / tw;
+
+ if(scrollbar)
+ tcp_qprintf(tq, "
");
+
ajax_box_begin(&tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes");
- /* List of muxes */
-
- tcp_qprintf(&tq, "
");
-
- tcp_qprintf(&tq, "
"
- "Freq.
");
- tcp_qprintf(&tq, "
%s
",
- "Status");
- tcp_qprintf(&tq, "
%s
",
- "State");
- tcp_qprintf(&tq, "
%s
",
- "Name");
- tcp_qprintf(&tq, "
%s
",
- "Services");
- tcp_qprintf(&tq, "
");
-
-
- tcp_qprintf(&tq, "
",
+ tcp_qprintf(&tq, "
",
tda->tda_identifier);
- tcp_qprintf(&tq, "
");
-
-
ajax_js(&tq,
"new Ajax.Updater('dvbmuxlist%s', "
@@ -557,11 +538,17 @@ ajax_adaptermuxlist(http_connection_t *hc, const char *remain, void *opaque)
th_dvb_mux_instance_t *tdmi;
tcp_queue_t tq;
th_dvb_adapter_t *tda;
- char buf[50];
+ char buf[50], buf2[500], buf3[20];
const char *txt;
int fetype, n;
th_transport_t *t;
- int o = 1;
+ int o = 1, v;
+ int csize[10];
+ int nmuxes = 0;
+
+ int displines = 21;
+
+ const char *cells[10];
if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL)
return HTTP_STATUS_NOT_FOUND;
@@ -570,27 +557,44 @@ ajax_adaptermuxlist(http_connection_t *hc, const char *remain, void *opaque)
tcp_init_queue(&tq, -1);
- if(LIST_FIRST(&tda->tda_muxes) == NULL) {
+ /* List of muxes */
+
+ LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link)
+ nmuxes++;
+
+ ajax_table_header(hc, &tq,
+ (const char *[])
+ {"Freq", "Status", "State", "Name", "Services", NULL},
+ (int[]){3,3,2,4,2},
+ nmuxes > displines,
+ csize);
+
+ tcp_qprintf(&tq, "
");
+
+ v = displines;
+ if(nmuxes < displines)
+ v = nmuxes;
+
+ tcp_qprintf(&tq, "
",
+ tda->tda_identifier, v * 14);
+
+ if(nmuxes == 0) {
tcp_qprintf(&tq, "
"
"No muxes configured
");
} else LIST_FOREACH(tdmi, &tda->tda_muxes, tdmi_adapter_link) {
- tcp_qprintf(&tq, "
", o ? " style=\"background: #fff\"" : "");
- o = !o;
-
tdmi_displayname(tdmi, buf, sizeof(buf));
- tcp_qprintf(&tq, "
");
- tcp_qprintf(&tq, "
", tdmi->tdmi_identifier, buf);
-
- tcp_qprintf(&tq, "
%s
",
- dvb_mux_status(tdmi));
+ snprintf(buf2, sizeof(buf2),
+ "
%s", tdmi->tdmi_identifier, buf);
+ cells[0] = buf2;
+ cells[1] = dvb_mux_status(tdmi);
+
switch(tdmi->tdmi_state) {
case TDMI_IDLE: txt = "Idle"; break;
case TDMI_IDLESCAN: txt = "Scanning"; break;
@@ -598,24 +602,26 @@ ajax_adaptermuxlist(http_connection_t *hc, const char *remain, void *opaque)
default: txt = "???"; break;
}
- tcp_qprintf(&tq, "
%s
",
- txt);
-
+ cells[2] = txt;
+
txt = tdmi->tdmi_network;
if(txt == NULL)
txt = "Unknown";
- tcp_qprintf(&tq, "
%s
",
- txt);
+ cells[3] = txt;
n = 0;
LIST_FOREACH(t, &tdmi->tdmi_transports, tht_mux_link)
n++;
- tcp_qprintf(&tq, "
%d
", n);
+ snprintf(buf3, sizeof(buf3), "%d", n);
+ cells[4] = buf3;
+ cells[5] = NULL;
+
+ ajax_table_row(&tq, cells, csize, &o);
- tcp_qprintf(&tq, "
");
}
+ tcp_qprintf(&tq, "
");
http_output_queue(hc, &tq, "text/html; charset=UTF-8", 0);
return 0;