index.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>DOKK Graph</title>
  7. <style>
  8. html, body, #graph {
  9. font-family: monospace;
  10. font-size: 1rem;
  11. height: 100%;
  12. margin: 0;
  13. padding: 0;
  14. width: 100%;
  15. }
  16. .sidebar {
  17. background: #fbfbfb;
  18. box-shadow: 0 0 .5rem 0 lightgray;
  19. bottom: 0;
  20. left: 0;
  21. padding: 1rem;
  22. position: absolute;
  23. top: 0;
  24. width: 25%;
  25. }
  26. input[type=search] {
  27. padding: .5rem 1rem;
  28. width: 100%;
  29. }
  30. #search_results {
  31. list-style: none;
  32. margin: 1rem 0 0 0;
  33. padding: 0;
  34. }
  35. #search_results > li {
  36. cursor: pointer;
  37. margin: 0;
  38. padding: 0;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <div id="graph"></div>
  44. <script src="vis-network.min.js"></script>
  45. <script src="data.js"></script>
  46. <script>
  47. var container = document.getElementById("graph");
  48. var data = { nodes: nodes, edges: edges };
  49. var options = {
  50. nodes: {
  51. borderWidth: 1,
  52. color: {
  53. background: "white",
  54. border: "gray",
  55. highlight: {
  56. background: "yellow"
  57. },
  58. hover: {
  59. background: "yellow"
  60. }
  61. },
  62. font: {
  63. color: "black"
  64. },
  65. shape: "box"
  66. },
  67. edges: {
  68. color: {
  69. color: "#f0f0f0",
  70. hover: "#e0e0e0",
  71. highlight: "red"
  72. },
  73. font: {
  74. size: 10,
  75. align: "middle",
  76. },
  77. physics: true,
  78. smooth: false,
  79. },
  80. layout: {
  81. randomSeed: 0
  82. },
  83. physics: {
  84. solver: "repulsion",
  85. repulsion: {
  86. nodeDistance: 1000
  87. },
  88. stabilization: {
  89. enabled: false
  90. },
  91. timestep: 1,
  92. },
  93. interaction: {
  94. hover: true
  95. },
  96. };
  97. network = new vis.Network(container, data, options);
  98. function search(text) {
  99. text = text.trim();
  100. about_container = document.getElementById('about');
  101. results_container = document.getElementById('search_results');
  102. if(text.length == 0) {
  103. about_container.style.display = "block";
  104. results_container.style.display = "none";
  105. return;
  106. }
  107. about_container.style.display = "none";
  108. results_container.style.display = "block";
  109. text = text.toLowerCase();
  110. results = nodes.filter(obj => {
  111. return obj.label.toLowerCase().startsWith(text);
  112. }).slice(0, 100);
  113. results_container.replaceChildren();
  114. results.forEach(function (result, index, arr) {
  115. li = document.createElement("li");
  116. li.appendChild(document.createTextNode(result.label));
  117. li.addEventListener("click", function(event) {
  118. network.selectNodes([ result.id ]);
  119. network.focus(result.id, {
  120. scale: 1.2,
  121. animation: false
  122. });
  123. });
  124. results_container.appendChild(li);
  125. });
  126. }
  127. </script>
  128. <div class="sidebar">
  129. <input type="search" oninput="search(this.value)" placeholder="Search node..." />
  130. <div id="about">
  131. <p>
  132. <i>DOKK</i> is a community-curated graph.
  133. </p>
  134. <p>
  135. Join the
  136. <a href="https://clif.peers.community/dokk/dokk.mlist">mailing list</a>
  137. or download the
  138. <a href="https://clif.peers.community/dokk/graph.git">data</a>,
  139. and participate in the creation of a free database of the world's knowledge.
  140. Let's build it together!
  141. <br /><br /><br /><br />
  142. IRC: #<a href="https://peers.community/">peers</a> at irc.libera.chat
  143. </p>
  144. </div>
  145. <ul id="search_results"></ul>
  146. </div>
  147. </body>
  148. </html>