From d60f37126ff98ad641e042ea76d23554af0295d5 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 30 Mar 2021 16:53:41 -0400 Subject: [PATCH] search --- code.js | 36 +++++++++++++++++++++++------------- index.html | 7 ++++++- style.css | 1 + 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/code.js b/code.js index 47f7e2b..ebba234 100644 --- a/code.js +++ b/code.js @@ -16,7 +16,7 @@ function onLoad() { packages = data.Packages // Show initial (root) packages. - $('#roots').text(data.Roots.map(i => packages[i]).join("\n")) + $('#roots').text(data.Roots.map(i => packages[i].PkgPath).join("\n")) // Show broken edges. broken = data.Broken @@ -31,28 +31,38 @@ function onLoad() { // Populate package/module "directory" tree. $('#tree').jstree({ - "core" : { - "animation" : 0, - "check_callback" : true, - 'data' : data.Tree, + "core": { + "animation": 0, + "check_callback": true, + 'data': data.Tree, }, - "types" : { - "#" : { + "types": { + "#": { }, - "root" : { - "icon" : "/static/3.3.11/assets/images/tree_icon.png" + "root": { + "icon": "/static/3.3.11/assets/images/tree_icon.png" }, "module": { - "icon" : "https://jstree.com/static/3.3.11/assets/images/tree_icon.png" + "icon": "https://jstree.com/static/3.3.11/assets/images/tree_icon.png" }, "default": { }, - "pkg" : { + "pkg": { "icon": "https://old.jstree.com//static/v.1.0pre/_demo/file.png" } }, - "plugins" : ["contextmenu", "dnd", "search", "state", "types", "wholerow"], + "plugins": ["search", "state", "types", "wholerow"], + "search": { + "case_sensitive": false, + "show_only_matches": true, + } }) + + // Search the tree when the user types in the search box. + $("#search").keyup(function () { + var searchString = $(this).val(); + $('#tree').jstree('search', searchString); + }); // Show package info when a node is clicked. $('#tree').on("changed.jstree", function (e, data) { @@ -83,7 +93,7 @@ function selectPkg(json) { // TODO(adonovan): display imports as a set of links, // with as ImportPath text and "select dir tree node" as action. - if (json.Imports != null) { + if (json.Imports != null) { // TODO(adonovan): how can this be null? $('#imports').text(json.Imports.join(" ")) } diff --git a/index.html b/index.html index d663cf4..aca2584 100644 --- a/index.html +++ b/index.html @@ -32,6 +32,11 @@

Packages

of the graph rooted at the node, divided by the node's in-degree. Click a package to show more information about it. +
+ + +

tree
@@ -46,7 +51,7 @@

Selected package: N/A

This list shows the packages directly imported by the selected package - ... + ...

Node x dominates diff --git a/style.css b/style.css index 4ecbc30..9cdc552 100644 --- a/style.css +++ b/style.css @@ -2,6 +2,7 @@ body { margin: 1em; font-family: "Minion Pro", serif; } h1, h2, h3, h4, .jstree-default { font-family: Lato; } code, pre { font-family: Consolas, monospace; } button { font-size: 50%; } +pre#imports { font-size: 50%; max-height: 3em; overflow: scroll; } /* the ⓘ symbol */ .tooltip {