From 92eecedc8a52b0ba814daddb5167449a2ebb7f26 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 1 Dec 2019 21:13:14 +0100 Subject: [PATCH] luci-theme-material: render menu on client side Signed-off-by: Jo-Philipp Wich --- .../htdocs/luci-static/material/js/script.js | 2 + .../luasrc/view/themes/material/footer.htm | 20 +- .../luasrc/view/themes/material/header.htm | 259 +++++++++--------- 3 files changed, 134 insertions(+), 147 deletions(-) diff --git a/themes/luci-theme-material/htdocs/luci-static/material/js/script.js b/themes/luci-theme-material/htdocs/luci-static/material/js/script.js index 755191f335..ae39d00751 100755 --- a/themes/luci-theme-material/htdocs/luci-static/material/js/script.js +++ b/themes/luci-theme-material/htdocs/luci-static/material/js/script.js @@ -18,6 +18,7 @@ * Licensed to the public under the Apache License 2.0 */ +document.addEventListener('luci-loaded', function(ev) { (function ($) { $(".main > .loading").fadeOut(); @@ -216,3 +217,4 @@ } })(jQuery); +}); diff --git a/themes/luci-theme-material/luasrc/view/themes/material/footer.htm b/themes/luci-theme-material/luasrc/view/themes/material/footer.htm index 544866ddee..2f9f096bc1 100644 --- a/themes/luci-theme-material/luasrc/view/themes/material/footer.htm +++ b/themes/luci-theme-material/luasrc/view/themes/material/footer.htm @@ -18,27 +18,11 @@ Licensed to the public under the Apache License 2.0 -%> -<% - local ver = require "luci.version" - local disp = require "luci.dispatcher" - local request = disp.context.path - local category = request[1] - local tree = disp.node() - local categories = disp.node_childs(tree) -%> +<% local ver = require "luci.version" %> diff --git a/themes/luci-theme-material/luasrc/view/themes/material/header.htm b/themes/luci-theme-material/luasrc/view/themes/material/header.htm index 76eeec05eb..5595b14e49 100644 --- a/themes/luci-theme-material/luasrc/view/themes/material/header.htm +++ b/themes/luci-theme-material/luasrc/view/themes/material/header.htm @@ -26,135 +26,10 @@ local boardinfo = util.ubus("system", "board") - local request = disp.context.path - local request2 = disp.context.request - - local category = request[1] - local cattree = category and disp.node(category) - - local leaf = request2[#request2] - - local tree = disp.node() local node = disp.context.dispatched - local categories = disp.node_childs(tree) - - local c = tree - local i, r - - -- tag all nodes leading to this page - for i, r in ipairs(request) do - if c.nodes and c.nodes[r] then - c = c.nodes[r] - c._menu_selected = true - end - end - -- send as HTML5 http.prepare_content("text/html") - - local function nodeurl(prefix, name, query) - local u = url(prefix, name) - if query then - u = u .. http.build_querystring(query) - end - return pcdata(u) - end - - local function render_tabmenu(prefix, node, level) - if not level then - level = 1 - end - - local childs = disp.node_childs(node) - if #childs > 0 then - if level > 2 then - write('') - end - - if selected_node then - 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('') - end - end - - local function render_topmenu() - local childs = disp.node_childs(cattree) - if #childs > 0 then - write('') - end - end -%> @@ -180,6 +55,134 @@ + ">
@@ -199,9 +202,7 @@
<%:Collecting data...%>
-
- <% render_topmenu() %> -
+
@@ -223,4 +224,4 @@
- <% if category then render_tabmenu(category, cattree) end %> + -- 2.30.2