applications/luci-olsr: Fix rowstyle, make html valid
authorManuel Munz <freifunk@somakoma.de>
Sun, 13 Nov 2011 12:34:09 +0000 (12:34 +0000)
committerManuel Munz <freifunk@somakoma.de>
Sun, 13 Nov 2011 12:34:09 +0000 (12:34 +0000)
applications/luci-olsr/luasrc/view/status-olsr/hna.htm
applications/luci-olsr/luasrc/view/status-olsr/interfaces.htm
applications/luci-olsr/luasrc/view/status-olsr/mid.htm
applications/luci-olsr/luasrc/view/status-olsr/neighbors.htm
applications/luci-olsr/luasrc/view/status-olsr/routes.htm
applications/luci-olsr/luasrc/view/status-olsr/smartgw.htm
applications/luci-olsr/luasrc/view/status-olsr/topology.htm

index 9e29edf64f921faa41915d27766982025c001dd7..bde1f009b54b50f71389664a76fb8df9787d2d2c 100644 (file)
@@ -41,7 +41,7 @@ local i = 1
                        </td>
                </tr>
 
                        </td>
                </tr>
 
-               <% if i == 1 then i = 0 elseif i == 0 then i = 1 end
+               <% i = ((i % 2) + 1)
                end %>
        </table>
 </fieldset>
                end %>
        </table>
 </fieldset>
index 2d3ff876ab2b889cc183bc66d8f6413b48b5f692..17090ff4aa7d7e88b604a3fcd1d488d4e2bc2031 100644 (file)
@@ -47,7 +47,7 @@ local i = 1
                        <td class="cbi-section-table-cell"><%=iface.Mask%></td>
                        <td class="cbi-section-table-cell"><%=iface["Dst-Adress"]%></td>
                </tr>
                        <td class="cbi-section-table-cell"><%=iface.Mask%></td>
                        <td class="cbi-section-table-cell"><%=iface["Dst-Adress"]%></td>
                </tr>
-               <% if i == 1 then i = 0 elseif i == 0 then i = 1 end
+               <% i = ((i % 2) + 1)
                end %>
        </table>
 </fieldset>
                end %>
        </table>
 </fieldset>
index 1af864d852442c4b447f5b9ea45ea33a66fa1f33..48823b5bc1335c11e44f2d403b91aefd46b853a9 100644 (file)
@@ -35,7 +35,7 @@ local i = 1
                        <td class="cbi-section-table-cell"><%=mid.Aliases%></td>
                </tr>
 
                        <td class="cbi-section-table-cell"><%=mid.Aliases%></td>
                </tr>
 
-               <% if i == 1 then i = 0 elseif i == 0 then i = 1 end
+               <% i = ((i % 2) + 1)
                end %>
        </table>
 </fieldset>
                end %>
        </table>
 </fieldset>
index 4eff933c9421617bc2df6fd24126f0029eeaf2d0..029f585473931752f078e87d95ba98c3ff4686f8 100644 (file)
@@ -14,11 +14,10 @@ You may obtain a copy of the License at
 
 <%
 local olsrtools = require "luci.tools.olsr"
 
 <%
 local olsrtools = require "luci.tools.olsr"
+local i = 1
 
 if luci.http.formvalue("status") == "1" then
        local rv = {}
 
 if luci.http.formvalue("status") == "1" then
        local rv = {}
-       local i = 1
-
        for k, link in ipairs(links) do
                link.Cost = tonumber(link.Cost) or 0
                local color = olsrtools.etx_color(link.Cost)
        for k, link in ipairs(links) do
                link.Cost = tonumber(link.Cost) or 0
                local color = olsrtools.etx_color(link.Cost)
@@ -36,10 +35,8 @@ if luci.http.formvalue("status") == "1" then
                        nlq = link.NLQ,
                        cost = string.format("%.3f", link.Cost),
                        color = color,
                        nlq = link.NLQ,
                        cost = string.format("%.3f", link.Cost),
                        color = color,
-                       rs = i,
                        dfgcolor = defaultgw_color
                        }
                        dfgcolor = defaultgw_color
                        }
-                       if i == 1 then i = 0 elseif i == 0 then i = 1 end
        end
        luci.http.prepare_content("application/json")
        luci.http.write_json(rv)
        end
        luci.http.prepare_content("application/json")
        luci.http.write_json(rv)
@@ -64,9 +61,9 @@ end
                                        var neigh = info[idx];
 
                                        s += String.format(
                                        var neigh = info[idx];
 
                                        s += String.format(
-                                               '<tr class="cbi-section-table-row cbi-rowstyle-%s">' +
+                                               '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
                                                        '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
                                                        '<td class="cbi-section-table-cell" style="background-color:%s"><a href="http://%s/cgi-bin-status.html">%s</a></td>',
-                                               neigh.rs, neigh.dfgcolor, neigh.rip, neigh.rip
+                                               neigh.dfgcolor, neigh.rip, neigh.rip
                                                );
                                        if (neigh.hn) {
                                                s += String.format(                                     
                                                );
                                        if (neigh.hn) {
                                                s += String.format(                                     
@@ -105,16 +102,17 @@ end
        <legend><%:Overview of currently established OLSR connections%></legend>
 
        <table class="cbi-section-table">
        <legend><%:Overview of currently established OLSR connections%></legend>
 
        <table class="cbi-section-table">
-               <tr class="cbi-section-table-titles">
-                       <th class="cbi-section-table-cell"><%:Neighbour IP%></th>
-                       <th class="cbi-section-table-cell"><%:Hostname%></th>
-                       <th class="cbi-section-table-cell"><%:Local interface IP%></th>
-                       <th class="cbi-section-table-cell"><%:Device%></th>
-                       <th class="cbi-section-table-cell">LQ</th>
-                       <th class="cbi-section-table-cell">NLQ</th>
-                       <th class="cbi-section-table-cell">ETX</th>
-               </tr>
-
+               <thead>
+                       <tr class="cbi-section-table-titles">
+                               <th class="cbi-section-table-cell"><%:Neighbour IP%></th>
+                               <th class="cbi-section-table-cell"><%:Hostname%></th>
+                               <th class="cbi-section-table-cell"><%:Local interface IP%></th>
+                               <th class="cbi-section-table-cell"><%:Device%></th>
+                               <th class="cbi-section-table-cell">LQ</th>
+                               <th class="cbi-section-table-cell">NLQ</th>
+                               <th class="cbi-section-table-cell">ETX</th>
+                       </tr>
+               </thead>
        
                <tbody id="olsr_neigh_table">
                <%      local i = 1
        
                <tbody id="olsr_neigh_table">
                <%      local i = 1
@@ -138,7 +136,7 @@ end
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
                </tr>
                <% 
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", link.Cost)%></td>
                </tr>
                <% 
-                       if i == 1 then i = 0 elseif i == 0 then i = 1 end
+                       i = ((i % 2) + 1)
                end %>
                </tbody>
        </table>
                end %>
                </tbody>
        </table>
index 5281f7083416fde170369336973db6ffb1055aa0..e32b696d58a82a992bd52a3bad9cc4b31d6de52a 100644 (file)
@@ -27,9 +27,7 @@ if luci.http.formvalue("status") == "1" then
                        metric = route.Metric,
                        etx = tonumber(route.ETX),
                        color = olsrtools.etx_color(tonumber(route.ETX)),
                        metric = route.Metric,
                        etx = tonumber(route.ETX),
                        color = olsrtools.etx_color(tonumber(route.ETX)),
-                       rs = i
                }
                }
-               if i == 1 then i = 0 elseif i == 0 then i = 1 end       
        end
        luci.http.prepare_content("application/json")
        luci.http.write_json(rv)
        end
        luci.http.prepare_content("application/json")
        luci.http.write_json(rv)
@@ -56,11 +54,11 @@ XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
                                        var route = info[idx];
 
                                        s += String.format(
                                        var route = info[idx];
 
                                        s += String.format(
-                                               '<tr class="cbi-section-table-row cbi-rowstyle-%s">' +
+                                               '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' +
                                                        '<td class="cbi-section-table-cell">%s</td>' +
                                                        '<td class="cbi-section-table-cell">' +
                                                                '<a href="http://%s/cgi-bin-status.html">%s</a>',
                                                        '<td class="cbi-section-table-cell">%s</td>' +
                                                        '<td class="cbi-section-table-cell">' +
                                                                '<a href="http://%s/cgi-bin-status.html">%s</a>',
-                                                               route.rs, route.dest, route.gw, route.gw
+                                                               route.dest, route.gw, route.gw
                                                )
 
                                        if (route.hostname)
                                                )
 
                                        if (route.hostname)
@@ -94,13 +92,15 @@ XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
 
 <table class="cbi-section-table">
 <legend><%:Overview of currently known routes to other OLSR nodes%></legend>
 
 <table class="cbi-section-table">
-       <tr class="cbi-section-table-titles">
-               <th class="cbi-section-table-cell"><%:Announced network%></th>
-               <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
-               <th class="cbi-section-table-cell"><%:Interface%></th>
-               <th class="cbi-section-table-cell"><%:Metric%></th>
-               <th class="cbi-section-table-cell">ETX</th>
-       </tr>
+       <thead>
+               <tr class="cbi-section-table-titles">
+                       <th class="cbi-section-table-cell"><%:Announced network%></th>
+                       <th class="cbi-section-table-cell"><%:OLSR gateway%></th>
+                       <th class="cbi-section-table-cell"><%:Interface%></th>
+                       <th class="cbi-section-table-cell"><%:Metric%></th>
+                       <th class="cbi-section-table-cell">ETX</th>
+               </tr>
+       </thead>
 
        <tbody id="olsrd_routes">
 
 
        <tbody id="olsrd_routes">
 
@@ -121,7 +121,7 @@ XHR.poll(20, '<%=REQUEST_URI%>', { status: 1 },
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
                </tr>
        <% 
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=string.format("%.3f", tonumber(route.ETX) or 0)%></td>
                </tr>
        <% 
-       if i == 1 then i = 0 elseif i == 0 then i = 1 end
+               i = ((i % 2) + 1)
        end %>
        </tbody>
 </table>
        end %>
        </tbody>
 </table>
index 60f43b7f86982a5319878924c0df8b13bf2682f1..7fa8730423706cffd80c0305b3081e6c2bf19c6b 100644 (file)
@@ -57,7 +57,7 @@ end)
                                <td class="cbi-section-table-cell"><%=gw.Prefix%></td>
                        </tr>
 
                                <td class="cbi-section-table-cell"><%=gw.Prefix%></td>
                        </tr>
 
-                       <% if i == 1 then i = 0 elseif i == 0 then i = 1 end
+                       <% i = ((i % 2) + 1)
                        end %>
                </table>
        </fieldset>
                        end %>
                </table>
        </fieldset>
index b4221bb80d40acbae36457e70590616444f198ae..d0e85280e21bde9cb73dd2c286b8b5b91003863a 100644 (file)
@@ -45,7 +45,7 @@ local olsrtools = require "luci.tools.olsr"
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=cost%></td>
                </tr>
 
                        <td class="cbi-section-table-cell" style="background-color:<%=color%>"><%=cost%></td>
                </tr>
 
-               <%      if i == 1 then i = 0 elseif i == 0 then i = 1 end 
+               <%      i = ((i % 2) + 1)
                end %>
        </table>
 </fieldset>
                end %>
        </table>
 </fieldset>