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.

441 lines
14 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. <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
  10. <link rel="apple-touch-icon" sizes="180x180" href="./img/favicon/apple-touch-icon.png">
  11. <link rel="icon" type="image/png" sizes="32x32" href="./img/favicon/favicon-32x32.png">
  12. <link rel="icon" type="image/png" sizes="16x16" href="./img/favicon/favicon-16x16.png">
  13. <link rel="manifest" href="./img/favicon/site.webmanifest">
  14. <link rel="mask-icon" href="./img/favicon/safari-pinned-tab.svg" color="#5bbad5">
  15. <meta name="msapplication-TileColor" content="#da532c">
  16. <meta name="theme-color" content="#498FBE">
  17. <script src="src/sigma.core.js"></script>
  18. <script src="src/conrad.js"></script>
  19. <script src="src/utils/sigma.utils.js"></script>
  20. <script src="src/utils/sigma.polyfills.js"></script>
  21. <script src="src/sigma.settings.js"></script>
  22. <script src="src/classes/sigma.classes.dispatcher.js"></script>
  23. <script src="src/classes/sigma.classes.configurable.js"></script>
  24. <script src="src/classes/sigma.classes.graph.js"></script>
  25. <script src="src/classes/sigma.classes.camera.js"></script>
  26. <script src="src/classes/sigma.classes.quad.js"></script>
  27. <script src="src/classes/sigma.classes.edgequad.js"></script>
  28. <script src="src/captors/sigma.captors.mouse.js"></script>
  29. <script src="src/captors/sigma.captors.touch.js"></script>
  30. <script src="src/renderers/sigma.renderers.canvas.js"></script>
  31. <script src="src/renderers/sigma.renderers.webgl.js"></script>
  32. <script src="src/renderers/sigma.renderers.svg.js"></script>
  33. <script src="src/renderers/sigma.renderers.def.js"></script>
  34. <script src="src/renderers/webgl/sigma.webgl.nodes.def.js"></script>
  35. <script src="src/renderers/webgl/sigma.webgl.nodes.fast.js"></script>
  36. <script src="src/renderers/webgl/sigma.webgl.edges.def.js"></script>
  37. <script src="src/renderers/webgl/sigma.webgl.edges.fast.js"></script>
  38. <script src="src/renderers/webgl/sigma.webgl.edges.arrow.js"></script>
  39. <script src="src/renderers/canvas/sigma.canvas.labels.def.js"></script>
  40. <script src="src/renderers/canvas/sigma.canvas.hovers.def.js"></script>
  41. <script src="src/renderers/canvas/sigma.canvas.nodes.def.js"></script>
  42. <script src="src/renderers/canvas/sigma.canvas.edges.def.js"></script>
  43. <script src="src/renderers/canvas/sigma.canvas.edges.curve.js"></script>
  44. <script src="src/renderers/canvas/sigma.canvas.edges.arrow.js"></script>
  45. <script src="src/renderers/canvas/sigma.canvas.edges.curvedArrow.js"></script>
  46. <script src="src/renderers/canvas/sigma.canvas.edgehovers.def.js"></script>
  47. <script src="src/renderers/canvas/sigma.canvas.edgehovers.curve.js"></script>
  48. <script src="src/renderers/canvas/sigma.canvas.edgehovers.arrow.js"></script>
  49. <script src="src/renderers/canvas/sigma.canvas.edgehovers.curvedArrow.js"></script>
  50. <script src="src/renderers/canvas/sigma.canvas.extremities.def.js"></script>
  51. <script src="src/renderers/svg/sigma.svg.utils.js"></script>
  52. <script src="src/renderers/svg/sigma.svg.nodes.def.js"></script>
  53. <script src="src/renderers/svg/sigma.svg.edges.def.js"></script>
  54. <script src="src/renderers/svg/sigma.svg.edges.curve.js"></script>
  55. <script src="src/renderers/svg/sigma.svg.labels.def.js"></script>
  56. <script src="src/renderers/svg/sigma.svg.hovers.def.js"></script>
  57. <script src="src/middlewares/sigma.middlewares.rescale.js"></script>
  58. <script src="src/middlewares/sigma.middlewares.copy.js"></script>
  59. <script src="src/misc/sigma.misc.animation.js"></script>
  60. <script src="src/misc/sigma.misc.bindEvents.js"></script>
  61. <script src="src/misc/sigma.misc.bindDOMEvents.js"></script>
  62. <script src="src/misc/sigma.misc.drawHovers.js"></script>
  63. <script src="src/plugins/sigma.plugins.neighborhoods/sigma.plugins.neighborhoods.js"></script>
  64. <script src="src/plugins/sigma.layout.forceAtlas2/supervisor.js"></script>
  65. <script src="src/plugins/sigma.layout.forceAtlas2/worker.js"></script>
  66. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  67. </head>
  68. <body>
  69. <div class="navbar navbar-expand-lg fixed-top navbar-dark bg-primary">
  70. <div class="container">
  71. <a class="navbar-brand" href="#">Steam Graph Project</a>
  72. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  73. <span class="navbar-toggler-icon"></span>
  74. </button>
  75. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  76. <ul class="navbar-nav mr-auto">
  77. <li class="nav-item">
  78. <a class="nav-link" href="index.html">Home</a>
  79. </li>
  80. <li class="nav-item">
  81. <a class="nav-link" href="graphs.html">Graphs<span class="sr-only">(current)</span></a>
  82. </li>
  83. <!--<li class="nav-item">-->
  84. <!--<a class="nav-link" href="profile.html">Profile Look-Up</a>-->
  85. <!--</li>-->
  86. <li class="nav-item">
  87. <a class="nav-link" href="faq.html">FAQ</a>
  88. </li>
  89. </ul>
  90. <ul class="nav navbar-nav navbar-right">
  91. <li>
  92. <a class="nav-link" href="https://jrtechs.net">Blog</a>
  93. </li>
  94. <li>
  95. <a class="nav-link" href="https://jrtechs.me">Resume</a>
  96. </li>
  97. <li>
  98. <a class="nav-link" href="https://github.com/jrtechs">Github</a>
  99. </li>
  100. </ul>
  101. </div>
  102. </div>
  103. </div>
  104. <!-- END SIGMA IMPORTS -->
  105. <div id="container">
  106. <style>
  107. #graph-container {
  108. top: 0;
  109. bottom: 0;
  110. left: 0;
  111. right: 0;
  112. position: absolute;
  113. background-color: #455660;
  114. }
  115. .sigma-edge {
  116. stroke: #14191C;
  117. fill-opacity: 0.7;
  118. stroke-opacity: 0.7;
  119. }
  120. .sigma-node {
  121. fill: #008080;
  122. stroke: #14191C;
  123. stroke-width: 2px;
  124. }
  125. .sigma-node:hover {
  126. fill: blue;
  127. }
  128. .sigma-label
  129. {
  130. fill: #00CED1 !important;
  131. }
  132. .muted {
  133. fill-opacity: 0.1;
  134. stroke-opacity: 0.1;
  135. }
  136. </style>
  137. <div id="graph-container" style="width:100%; height:100%"></div>
  138. </div>
  139. <script>
  140. var s;
  141. var g = {
  142. nodes: [],
  143. edges: []
  144. };
  145. /**
  146. * Creates a new sigma graph
  147. */
  148. s = new sigma({
  149. graph: g,
  150. settings: {
  151. enableHovering: false
  152. }
  153. });
  154. /**
  155. * Sets the sigma graph to render using svg
  156. */
  157. s.addRenderer({
  158. id: 'main',
  159. type: 'svg',
  160. container: document.getElementById('graph-container'),
  161. freeStyle: true
  162. });
  163. /**
  164. * Simple function to get the get data from the url
  165. */
  166. function getUrlVars()
  167. {
  168. var vars = {};
  169. window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
  170. function(m,key,value) {
  171. vars[key] = value;
  172. });
  173. return vars;
  174. }
  175. /** Web socket to communicate with the steam friend java server */
  176. connection = new WebSocket('ws://steam.student.rit.edu:4444');
  177. setTimeout(function()
  178. {
  179. if (this.connection.readyState != 1)
  180. {
  181. document.location.href = "error.html";
  182. }
  183. }, 6000);
  184. /**
  185. * When the web socket is opened, this function
  186. * fetches the get data and requests the server
  187. * to start giving it graph information
  188. */
  189. connection.onopen = function ()
  190. {
  191. var getData = getUrlVars();
  192. if(getData["id"] != undefined && getData["id"] != "")
  193. {
  194. connection.send("{id:'" + getData["id"] + "', graph:" +
  195. getData["graph"] + "}");
  196. connection.send("{go:1}");
  197. }
  198. else
  199. {
  200. connection.close();
  201. }
  202. };
  203. /**
  204. * Logs any errors with the web socket -- usually error
  205. * connecting to the server
  206. * @param error
  207. */
  208. connection.onerror = function (error)
  209. {
  210. console.log('WebSocket Error ' + error);
  211. };
  212. /**
  213. * Helper function to add a new node to the sigma graph
  214. *
  215. * @param request
  216. */
  217. function addNodeToGraph(request)
  218. {
  219. if(s.graph.nodes(request.id) == undefined)
  220. {
  221. s.graph.addNode({
  222. id: request.id,
  223. label: request.name,
  224. x: request.x,
  225. y: request.y,
  226. size: request.size
  227. });
  228. s.refresh();
  229. }
  230. }
  231. /**
  232. * Helper function to add an edge between two nodes on the
  233. * sigma graph
  234. *
  235. * @param request
  236. */
  237. function addEdgeToGraph(request)
  238. {
  239. s.graph.addEdge({
  240. id: request.id,
  241. source: request.p1,
  242. target: request.p2,
  243. size: 1
  244. });
  245. s.refresh();
  246. }
  247. /**
  248. * Parses any events from the server
  249. * action 1: add a new node to the graph
  250. * action 2: add a new edge to the graph
  251. * action 3: start applying forces to the graph
  252. *
  253. * @param e
  254. */
  255. connection.onmessage = function (e)
  256. {
  257. var request = JSON.parse(e.data);
  258. if(request.action == 1)
  259. {
  260. setTimeout(function()
  261. {
  262. addNodeToGraph(request);
  263. connection.send("{go:1}");
  264. }, 0);
  265. }
  266. else if(request.action == 2)
  267. {
  268. setTimeout(function()
  269. {
  270. addEdgeToGraph(request);
  271. connection.send("{go:1}");
  272. }, 0);
  273. }
  274. else if(request.action == 3)
  275. {
  276. var getData = getUrlVars();
  277. if(getData["graph"] == 2)
  278. {
  279. s.startForceAtlas2({worker: true, barnesHutOptimize: false,
  280. scalingRatio: 3, slowDown: 5, gravity: 10});
  281. setTimeout(function () {
  282. s.stopForceAtlas2();
  283. }, 15000);
  284. }
  285. else
  286. {
  287. s.startForceAtlas2({worker: true, barnesHutOptimize: false,
  288. scalingRatio: 6, slowDown: 4, gravity: 40});
  289. setTimeout(function () {
  290. s.stopForceAtlas2();
  291. }, 30000);
  292. }
  293. }
  294. else if(request.action == -1)
  295. {
  296. alert("The provided steamID was invalid.");
  297. }
  298. };
  299. // Binding silly interactions
  300. function mute(node)
  301. {
  302. if (!~node.getAttribute('class').search(/muted/))
  303. node.setAttributeNS(null, 'class',
  304. node.getAttribute('class') + ' muted');
  305. }
  306. function unmute(node)
  307. {
  308. node.setAttributeNS(null, 'class',
  309. node.getAttribute('class').replace(/(\s|^)muted(\s|$)/g, '$2'));
  310. }
  311. /**
  312. * jquery stuff for hiding and displaying users when clicked
  313. */
  314. s.bind('clickNode doubleClickNode rightClickNode', function(e)
  315. {
  316. $('.sigma-node, .sigma-edge, .sigma-label').each(function()
  317. {
  318. mute(this);
  319. });
  320. var neighbors = s.graph.neighborhood(e.data.node.id);
  321. neighbors.nodes.forEach(function(node)
  322. {
  323. unmute($('[data-node-id="' + node.id + '"]')[0]);
  324. unmute($('[data-label-target="' + node.id + '"]')[0]);
  325. });
  326. neighbors.edges.forEach(function(edge) {
  327. unmute($('[data-edge-id="' + edge.id + '"]')[0]);
  328. });
  329. });
  330. $('.sigma-node').click(function()
  331. {
  332. $('.sigma-node, .sigma-edge').each(function()
  333. {
  334. mute(this);
  335. });
  336. // Unmuting neighbors
  337. var neighbors = s.graph.neighborhood($(this).attr('data-node-id'));
  338. neighbors.nodes.forEach(function(node)
  339. {
  340. unmute($('[data-node-id="' + node.id + '"]')[0]);
  341. unmute($('[data-label-target="' + node.id + '"]')[0]);
  342. });
  343. neighbors.edges.forEach(function(edge)
  344. {
  345. unmute($('[data-edge-id="' + edge.id + '"]')[0]);
  346. });
  347. });
  348. s.bind('clickStage', function()
  349. {
  350. $('.sigma-node, .sigma-edge, .sigma-label').each(function()
  351. {
  352. unmute(this);
  353. });
  354. });
  355. </script>
  356. <!-
  357. ┈┈╱▔▔▔▔▔╲┈┈┈HM┈HM
  358. ┈╱┈┈╱▔╲╲╲▏┈┈┈HMMM
  359. ╱┈┈╱━╱▔▔▔▔▔╲━╮┈┈
  360. ▏┈▕┃▕╱▔╲╱▔╲▕╮┃┈┈
  361. ▏┈▕╰━▏▊▕▕▋▕▕━╯┈┈
  362. ╲┈┈╲╱▔╭╮▔▔┳╲╲┈┈┈
  363. ┈╲┈┈▏╭━━━━╯▕▕┈┈┈
  364. ┈┈╲┈╲▂▂▂▂▂▂╱╱┈┈┈
  365. ┈┈┈┈▏┊┈┈┈┈┊┈┈┈╲┈
  366. ┈┈┈┈▏┊┈┈┈┈┊▕╲┈┈╲
  367. ┈╱▔╲▏┊┈┈┈┈┊▕╱▔╲▕
  368. ┈▏ ┈┈┈╰┈┈┈┈╯┈┈┈▕▕
  369. ┈╲┈┈┈╲┈┈┈┈╱┈┈┈╱┈╲
  370. ┈┈╲┈┈▕▔▔▔▔▏┈┈╱╲╲╲▏
  371. ┈╱▔┈┈▕┈┈┈┈▏┈┈▔╲▔▔
  372. ┈╲▂▂▂╱┈┈┈┈╲▂▂▂╱┈
  373. If you are seeing this monkey that means that you are interested in my
  374. code. Yay!! If you are not here to hack me ... you should really consider
  375. contributing to some of my public projects on github.
  376. https://github.com/jrtechs
  377. -->
  378. <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>
  379. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  380. </body>
  381. </html>