From 885b604a5b2a612a28f25e8d356585e2707b61b3 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Fri, 15 May 2015 23:36:14 -0400 Subject: First cut at hiding unused / duplicate groups in editdeviceparams view --- provisioning-editdeviceparams-html.lsp | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/provisioning-editdeviceparams-html.lsp b/provisioning-editdeviceparams-html.lsp index 08137c6..0a48834 100644 --- a/provisioning-editdeviceparams-html.lsp +++ b/provisioning-editdeviceparams-html.lsp @@ -16,6 +16,12 @@ function markoverride(c) else c.class = "groupdefaultoverride" end + elseif c.default and c.value ~= c.default then + if c.class then + c.class = c.class .." defaultoverride" + else + c.class = "defaultoverride" + end end end %> @@ -36,9 +42,57 @@ end end %> + function showsection() { + $("#"+$(this).attr("class")).toggle(); + if ($(this).next().next("a").length == 1) { + $(this).next().next().toggle(); + } + $(this).remove(); + } + + function hideunuseddivs() { + var previoussection = ""; + var previousnumber = 0; + $("div").filter(function(){ + var id = $(this).attr("id"); + // We're looking for an id that starts with section_ + if ((id != null) && (id.indexOf("section_") === 0)) { + return true; + } + return false; + }).each(function(i){ + var id = $(this).attr("id"); + var currentnumber = id.match(/\d+$/); + var currentsection + if (currentnumber != null) { + var len = id.length; + var numlen = currentnumber[0].length; + currentsection = id.substr(8, id.length-8-currentnumber[0].length); + currentnumber = currentnumber[0].toString(); + } else { + currentsection = id.substr(8); + currentnumber = 0; + } + + if ((currentsection == previoussection) && (currentnumber != previousnumber) && (0 == $(this).find(".defaultoverride").length) && (0 == $(this).find(".groupdefaultoverride").length)) { + $(this).toggle(); + $('Show').insertAfter($(this)).click(showsection); + if ($(this).prev("a").length == 1) { + // If the previous sibling is also a Show link, hide this one + $(this).next().toggle(); + } + } + + previoussection = currentsection; + previousnumber = currentnumber; + }); + + } + $(document).ready(function() { $(".deletedevice").click(function(){ return confirm("Are you sure you want to delete this device?")}); $(".groupdefaultoverride").siblings().select("contains('Default:')").addClass("error"); + hideunuseddivs(); }); -- cgit v1.2.3