From 067d7dc9f708d5ebeda1072fb6dc82e960de0d81 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 28 May 2018 14:57:54 +0200 Subject: treewide: convert HTML tables to div Mostly convert HTML tables to div based markup to allow for easier styling in the future. Also change JS accessor code accordingly. Signed-off-by: Jo-Philipp Wich --- .../luci-app-upnp/luasrc/view/upnp_status.htm | 70 +++++++++------------- 1 file changed, 28 insertions(+), 42 deletions(-) (limited to 'applications/luci-app-upnp/luasrc') diff --git a/applications/luci-app-upnp/luasrc/view/upnp_status.htm b/applications/luci-app-upnp/luasrc/view/upnp_status.htm index 89fdb5e218..1e09225793 100644 --- a/applications/luci-app-upnp/luasrc/view/upnp_status.htm +++ b/applications/luci-app-upnp/luasrc/view/upnp_status.htm @@ -4,8 +4,8 @@ function(x) { var tb = document.getElementById('upnp_status_table'); - if (tb && (idx < tb.rows.length)) - tb.rows[0].parentNode.removeChild(tb.rows[idx]); + if (tb && (idx + 1 < tb.childNodes.length)) + tb.removeChild(tb.childNodes[idx + 1]); } ); } @@ -17,35 +17,21 @@ if (st && tb) { /* clear all rows */ - while( tb.rows.length > 1 ) - tb.deleteRow(1); + while (tb.firstElementChild !== tb.lastElementChild) + tb.removeChild(tb.lastElementChild); - for( var i = 0; i < st.length; i++ ) - { - var tr = tb.insertRow(-1); - tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1); + for (var i = 0; i < st.length; i++) + tb.appendChild(E('
'.format((i % 2) + 1), [ + E('
', st[i].proto), + E('
', st[i].extport), + E('
', st[i].intaddr), + E('
', st[i].intport), + E('
', st[i].descr), + E(''.format(st[i].num)) + ])); - tr.insertCell(-1).innerHTML = st[i].proto; - tr.insertCell(-1).innerHTML = st[i].extport; - tr.insertCell(-1).innerHTML = st[i].intaddr; - tr.insertCell(-1).innerHTML = st[i].intport; - tr.insertCell(-1).innerHTML = st[i].descr; - - tr.insertCell(-1).innerHTML = String.format( - '', - st[i].num - ); - } - - if( tb.rows.length == 1 ) - { - var tr = tb.insertRow(-1); - tr.className = 'cbi-section-table-row'; - - var td = tr.insertCell(-1); - td.colSpan = 5; - td.innerHTML = '
<%:There are no active redirects.%>
'; - } + if (tb.firstElementChild === tb.lastElementChild) + tb.appendChild(E('

<%:There are no active redirects.%>
')); } } ); @@ -53,17 +39,17 @@
<%:Active UPnP Redirects%> - - - - - - - - - - - - -
<%:Protocol%><%:External Port%><%:Client Address%><%:Client Port%><%:Description%> 

<%:Collecting data...%>
+
+
+
<%:Protocol%>
+
<%:External Port%>
+
<%:Client Address%>
+
<%:Client Port%>
+
<%:Description%>
+
 
+
+
+

<%:Collecting data...%>
+
+
-- cgit v1.2.3