MCPcopy Create free account
hub / github.com/adonovan/spaghetti / onData

Function onData

code.js:12–71  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

10
11// onData is called shortly after page load with the result of the /data request.
12function onData(data) {
13 // Save array of Package objects.
14 packages = data.Packages
15
16 // Show initial packages.
17 $('#initial').text(data.Initial.map(i => packages[i].PkgPath).join("\n"))
18
19 // Show broken edges.
20 broken = data.Broken
21 var html = ""
22 for (var i in broken) {
23 edge = broken[i]
24 html += "<button type='button' onclick='unbreak(" + edge[0] + ", " + edge[1] + ")'>unbreak</button> "
25 + "<code>" + packages[edge[0]].PkgPath + "</code> ⟶ "
26 + "<code>" + packages[edge[1]].PkgPath + "</code><br/>"
27 }
28 $('#broken').html(html)
29
30 // Populate package/module "directory" tree.
31 $('#tree').jstree({
32 "core": {
33 "animation": 0,
34 "check_callback": true,
35 'data': data.Tree,
36 },
37 "types": {
38 "#": {
39 },
40 "root": {
41 "icon": "/static/3.3.11/assets/images/tree_icon.png"
42 },
43 "module": {
44 "icon": "https://jstree.com/static/3.3.11/assets/images/tree_icon.png"
45 },
46 "default": {
47 },
48 "pkg": {
49 "icon": "https://old.jstree.com//static/v.1.0pre/_demo/file.png"
50 }
51 },
52 "plugins": ["search", "state", "types", "wholerow"],
53 "search": {
54 "case_sensitive": false,
55 "show_only_matches": true,
56 }
57 })
58
59 // Show package info when a node is clicked.
60 $('#tree').on("changed.jstree", function (e, data) {
61 if (data.node) {
62 selectPkg(data.node.original)
63 }
64 })
65
66 // Search the tree when the user types in the search box.
67 $("#search").keyup(function () {
68 var searchString = $(this).val();
69 $('#tree').jstree('search', searchString);

Callers

nothing calls this directly

Calls 1

selectPkgFunction · 0.85

Tested by

no test coverage detected