+ render_tabmenu(prefix .. "/" .. selected_name, selected_node, level + 1)
+ end
+ end
+ end
+
+ local function render_submenu(prefix, node)
+ local childs = disp.node_childs(node)
+ if #childs > 0 then
+ write('<ul class="slide-menu">')
+
+ for i, r in ipairs(childs) do
+ local nnode = node.nodes[r]
+ local title = pcdata(striptags(translate(nnode.title)))
+
+ write('<li><a data-title="%s" href="%s">%s</a></li>' %{
+ title,
+ nodeurl(prefix, r, nnode.query),
+ title
+ })
+ end
+
+ write('</ul>')
+ end
+ end
+
+ local function render_topmenu()
+ local childs = disp.node_childs(cattree)
+ if #childs > 0 then
+ write('<ul class="nav">')
+
+ for i, r in ipairs(childs) do
+ local nnode = cattree.nodes[r]
+ local grandchildren = disp.node_childs(nnode)
+
+ if #grandchildren > 0 then
+ local title = pcdata(striptags(translate(nnode.title)))
+
+ write('<li class="slide"><a class="menu" data-title="%s" href="#">%s</a>' %{
+ title,
+ title
+ })
+
+ render_submenu(category .. "/" .. r, nnode)
+ write('</li>')
+ else
+ local title = pcdata(striptags(translate(nnode.title)))
+
+ write('<li><a data-title="%s" href="%s">%s</a></li>' %{
+ title,
+ nodeurl(category, r, nnode.query),
+ title
+ })
+ end
+ end
+
+ write('</ul>')
+ end
+ end
+
+ local function render_changes()
+ -- calculate the number of unsaved changes
+ if tree.nodes[category] and tree.nodes[category].ucidata then
+ local ucichanges = 0
+
+ for i, j in pairs(require("luci.model.uci").cursor():changes()) do
+ for k, l in pairs(j) do
+ for m, n in pairs(l) do
+ ucichanges = ucichanges + 1;
+ end
+ end
+ end
+
+ if ucichanges > 0 then
+ write('<a class="uci_change_indicator label notice" href="%s?redir=%s">%s: %d</a>' %{
+ url(category, 'uci/changes'),
+ http.urlencode(http.formvalue('redir') or table.concat(disp.context.request, "/")),
+ translate('Unsaved Changes'),
+ ucichanges
+ })