Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
11 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Jrtechs Steam Friend Graph Project</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <link rel="stylesheet" href="css/bootstrap.css" media="screen">
  9. <script src="src/sigma.core.js"></script>
  10. <script src="src/conrad.js"></script>
  11. <script src="src/utils/sigma.utils.js"></script>
  12. <script src="src/utils/sigma.polyfills.js"></script>
  13. <script src="src/sigma.settings.js"></script>
  14. <script src="src/classes/sigma.classes.dispatcher.js"></script>
  15. <script src="src/classes/sigma.classes.configurable.js"></script>
  16. <script src="src/classes/sigma.classes.graph.js"></script>
  17. <script src="src/classes/sigma.classes.camera.js"></script>
  18. <script src="src/classes/sigma.classes.quad.js"></script>
  19. <script src="src/classes/sigma.classes.edgequad.js"></script>
  20. <script src="src/captors/sigma.captors.mouse.js"></script>
  21. <script src="src/captors/sigma.captors.touch.js"></script>
  22. <script src="src/renderers/sigma.renderers.canvas.js"></script>
  23. <script src="src/renderers/sigma.renderers.webgl.js"></script>
  24. <script src="src/renderers/sigma.renderers.svg.js"></script>
  25. <script src="src/renderers/sigma.renderers.def.js"></script>
  26. <script src="src/renderers/webgl/sigma.webgl.nodes.def.js"></script>
  27. <script src="src/renderers/webgl/sigma.webgl.nodes.fast.js"></script>
  28. <script src="src/renderers/webgl/sigma.webgl.edges.def.js"></script>
  29. <script src="src/renderers/webgl/sigma.webgl.edges.fast.js"></script>
  30. <script src="src/renderers/webgl/sigma.webgl.edges.arrow.js"></script>
  31. <script src="src/renderers/canvas/sigma.canvas.labels.def.js"></script>
  32. <script src="src/renderers/canvas/sigma.canvas.hovers.def.js"></script>
  33. <script src="src/renderers/canvas/sigma.canvas.nodes.def.js"></script>
  34. <script src="src/renderers/canvas/sigma.canvas.edges.def.js"></script>
  35. <script src="src/renderers/canvas/sigma.canvas.edges.curve.js"></script>
  36. <script src="src/renderers/canvas/sigma.canvas.edges.arrow.js"></script>
  37. <script src="src/renderers/canvas/sigma.canvas.edges.curvedArrow.js"></script>
  38. <script src="src/renderers/canvas/sigma.canvas.edgehovers.def.js"></script>
  39. <script src="src/renderers/canvas/sigma.canvas.edgehovers.curve.js"></script>
  40. <script src="src/renderers/canvas/sigma.canvas.edgehovers.arrow.js"></script>
  41. <script src="src/renderers/canvas/sigma.canvas.edgehovers.curvedArrow.js"></script>
  42. <script src="src/renderers/canvas/sigma.canvas.extremities.def.js"></script>
  43. <script src="src/renderers/svg/sigma.svg.utils.js"></script>
  44. <script src="src/renderers/svg/sigma.svg.nodes.def.js"></script>
  45. <script src="src/renderers/svg/sigma.svg.edges.def.js"></script>
  46. <script src="src/renderers/svg/sigma.svg.edges.curve.js"></script>
  47. <script src="src/renderers/svg/sigma.svg.labels.def.js"></script>
  48. <script src="src/renderers/svg/sigma.svg.hovers.def.js"></script>
  49. <script src="src/middlewares/sigma.middlewares.rescale.js"></script>
  50. <script src="src/middlewares/sigma.middlewares.copy.js"></script>
  51. <script src="src/misc/sigma.misc.animation.js"></script>
  52. <script src="src/misc/sigma.misc.bindEvents.js"></script>
  53. <script src="src/misc/sigma.misc.bindDOMEvents.js"></script>
  54. <script src="src/misc/sigma.misc.drawHovers.js"></script>
  55. <script src="src/plugins/sigma.plugins.neighborhoods/sigma.plugins.neighborhoods.js"></script>
  56. <script src="src/plugins/sigma.layout.forceAtlas2/supervisor.js"></script>
  57. <script src="src/plugins/sigma.layout.forceAtlas2/worker.js"></script>
  58. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  59. </head>
  60. <body>
  61. <div class="navbar navbar-expand-lg fixed-top navbar-dark bg-primary">
  62. <div class="container">
  63. <a href="index.html" class="navbar-brand">Jrtechs Steam Graph Project</a>
  64. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
  65. <span class="navbar-toggler-icon"></span>
  66. </button>
  67. <div class="collapse navbar-collapse" id="navbarResponsive">
  68. <ul class="navbar-nav">
  69. <li class="nav-item">
  70. <a class="nav-link" href="graphs.html">Graphs</a>
  71. </li>
  72. <li class="nav-item">
  73. <a class="nav-link" href="https://jrtechs.net">Blog</a>
  74. </li>
  75. <li class="nav-item">
  76. <a class="nav-link" href="https://jrtechs.me">Resume</a>
  77. </li>
  78. <li class="nav-item">
  79. <a class="nav-link" href="https://github.com/jrtechs">Github</a>
  80. </li>
  81. </ul>
  82. </div>
  83. </div>
  84. </div>
  85. <!-- END SIGMA IMPORTS -->
  86. <div id="container">
  87. <style>
  88. #graph-container {
  89. top: 0;
  90. bottom: 0;
  91. left: 0;
  92. right: 0;
  93. position: absolute;
  94. /*background-color: #455660;*/
  95. }
  96. .sigma-edge {
  97. /*stroke: #14191C;*/
  98. }
  99. .sigma-node {
  100. /*fill: green;*/
  101. /*stroke: #14191C;*/
  102. /*stroke-width: 2px;*/
  103. }
  104. .sigma-node:hover {
  105. fill: blue;
  106. }
  107. .muted {
  108. fill-opacity: 0.1;
  109. stroke-opacity: 0.1;
  110. }
  111. </style>
  112. <div id="graph-container" style="width:100%; height:100%"></div>
  113. </div>
  114. <script>
  115. var s,
  116. g = {
  117. nodes: [],
  118. edges: []
  119. },
  120. colors = [
  121. '#617db4',
  122. '#668f3c',
  123. '#c6583e',
  124. '#b956af'
  125. ];
  126. // Instantiate sigma:
  127. s = new sigma({
  128. graph: g,
  129. settings: {
  130. enableHovering: false
  131. }
  132. });
  133. s.addRenderer({
  134. id: 'main',
  135. type: 'svg',
  136. container: document.getElementById('graph-container'),
  137. freeStyle: true
  138. });
  139. getData = getUrlVars();
  140. connection = new WebSocket('ws://localhost:4444');
  141. connection.onopen = function ()
  142. {
  143. console.log('Connected!');
  144. if(getData["id"] != undefined && getData["id"] != "")
  145. {
  146. connection.send("{id:'" + getData["id"] + "', graph:" + getData["graph"] + "}");
  147. }
  148. else
  149. {
  150. connection.close();
  151. }
  152. };
  153. // Log errors
  154. connection.onerror = function (error)
  155. {
  156. console.log('WebSocket Error ' + error);
  157. };
  158. function getUrlVars()
  159. {
  160. var vars = {};
  161. var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  162. vars[key] = value;
  163. });
  164. return vars;
  165. }
  166. function addNodeToGraph(request)
  167. {
  168. if(s.graph.nodes(request.id) == undefined)
  169. {
  170. s.graph.addNode({
  171. id: request.id,
  172. label: request.name,
  173. x: request.x,
  174. y: request.y,
  175. size: Math.random(),
  176. color: colors[Math.floor(Math.random() * colors.length)]
  177. });
  178. s.refresh();
  179. }
  180. }
  181. function addEdgeToGraph(request)
  182. {
  183. s.graph.addEdge({
  184. id: request.id,
  185. source: request.p1,
  186. target: request.p2,
  187. size: Math.random(),
  188. });
  189. s.refresh();
  190. }
  191. // Log messages from the server
  192. connection.onmessage = function (e)
  193. {
  194. var request = JSON.parse(e.data);
  195. if(request.action == 1)
  196. {
  197. addNodeToGraph(request);
  198. }
  199. else if(request.action == 2)
  200. {
  201. addEdgeToGraph(request);
  202. }
  203. };
  204. //jquery stuff for hiding and displaying users when clicked
  205. s.bind('clickNode doubleClickNode rightClickNode', function(e)
  206. {
  207. console.log(e.type, e);
  208. $('.sigma-node, .sigma-edge').each(function()
  209. {
  210. mute(this);
  211. });
  212. var neighbors = s.graph.neighborhood(e.data.node.id);
  213. neighbors.nodes.forEach(function(node)
  214. {
  215. unmute($('[data-node-id="' + node.id + '"]')[0]);
  216. });
  217. neighbors.edges.forEach(function(edge) {
  218. unmute($('[data-edge-id="' + edge.id + '"]')[0]);
  219. });
  220. });
  221. // Binding silly interactions
  222. function mute(node)
  223. {
  224. if (!~node.getAttribute('class').search(/muted/))
  225. node.setAttributeNS(null, 'class', node.getAttribute('class') + ' muted');
  226. }
  227. function unmute(node)
  228. {
  229. node.setAttributeNS(null, 'class', node.getAttribute('class').replace(/(\s|^)muted(\s|$)/g, '$2'));
  230. }
  231. $('.sigma-node').click(function()
  232. {
  233. console.log("click");
  234. $('.sigma-node, .sigma-edge').each(function()
  235. {
  236. mute(this);
  237. });
  238. // Unmuting neighbors
  239. var neighbors = s.graph.neighborhood($(this).attr('data-node-id'));
  240. neighbors.nodes.forEach(function(node)
  241. {
  242. unmute($('[data-node-id="' + node.id + '"]')[0]);
  243. });
  244. neighbors.edges.forEach(function(edge)
  245. {
  246. unmute($('[data-edge-id="' + edge.id + '"]')[0]);
  247. });
  248. });
  249. s.bind('clickStage', function()
  250. {
  251. $('.sigma-node, .sigma-edge').each(function()
  252. {
  253. unmute(this);
  254. });
  255. });
  256. </script>
  257. <!-
  258. ┈┈╱▔▔▔▔▔╲┈┈┈HM┈HM
  259. ┈╱┈┈╱▔╲╲╲▏┈┈┈HMMM
  260. ╱┈┈╱━╱▔▔▔▔▔╲━╮┈┈
  261. ▏┈▕┃▕╱▔╲╱▔╲▕╮┃┈┈
  262. ▏┈▕╰━▏▊▕▕▋▕▕━╯┈┈
  263. ╲┈┈╲╱▔╭╮▔▔┳╲╲┈┈┈
  264. ┈╲┈┈▏╭━━━━╯▕▕┈┈┈
  265. ┈┈╲┈╲▂▂▂▂▂▂╱╱┈┈┈
  266. ┈┈┈┈▏┊┈┈┈┈┊┈┈┈╲┈
  267. ┈┈┈┈▏┊┈┈┈┈┊▕╲┈┈╲
  268. ┈╱▔╲▏┊┈┈┈┈┊▕╱▔╲▕
  269. ┈▏ ┈┈┈╰┈┈┈┈╯┈┈┈▕▕
  270. ┈╲┈┈┈╲┈┈┈┈╱┈┈┈╱┈╲
  271. ┈┈╲┈┈▕▔▔▔▔▏┈┈╱╲╲╲▏
  272. ┈╱▔┈┈▕┈┈┈┈▏┈┈▔╲▔▔
  273. ┈╲▂▂▂╱┈┈┈┈╲▂▂▂╱┈
  274. If you are seeing this monkey that means that you are interested in my
  275. code. Yay!! If you are not here to hack me ... you should really consider
  276. contributing to some of my public projects on github.
  277. https://github.com/jrtechs
  278. -->
  279. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  280. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  281. </body>
  282. </html>