Mercurial > hg > NetworkVis
comparison ismi-python-neo4jrestclient/static/index.html @ 6:aeef1fedd899
first version of ismi-python-neo4jrestclient. doesn't work yet.
author | casties |
---|---|
date | Mon, 28 Sep 2015 18:15:35 +0200 |
parents | |
children | 45dad9e38c82 |
comparison
equal
deleted
inserted
replaced
5:fa1b4fa5b4f8 | 6:aeef1fedd899 |
---|---|
1 <html> | |
2 <head> | |
3 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
4 <link rel="stylesheet" href="http://neo4j-contrib.github.io/developer-resources/language-guides/assets/css/main.css"> | |
5 <title>Neo4j Movies</title> | |
6 </head> | |
7 | |
8 <body> | |
9 <div id="graph"> | |
10 </div> | |
11 <div role="navigation" class="navbar navbar-default navbar-static-top"> | |
12 <div class="container"> | |
13 <div class="row"> | |
14 <div class="col-sm-6 col-md-6"> | |
15 <ul class="nav navbar-nav"> | |
16 <li> | |
17 <form role="search" class="navbar-form" id="search"> | |
18 <div class="form-group"> | |
19 <input type="text" value="Matrix" placeholder="Search for Movie Title" class="form-control" name="search"> | |
20 </div> | |
21 <button class="btn btn-default" type="submit">Search</button> | |
22 </form> | |
23 </li> | |
24 </ul> | |
25 </div> | |
26 <div class="navbar-header col-sm-6 col-md-6"> | |
27 <div class="logo-well"> | |
28 <a href="http://neo4j.com/developer-resources"> | |
29 <img src="http://neo4j-contrib.github.io/developer-resources/language-guides/assets/img/logo-white.svg" alt="Neo4j World's Leading Graph Database" id="logo"> | |
30 </a> | |
31 </div> | |
32 <div class="navbar-brand"> | |
33 <div class="brand">ISMI Texts</div> | |
34 </div> | |
35 </div> | |
36 </div> | |
37 </div> | |
38 </div> | |
39 | |
40 <div class="row"> | |
41 <div class="col-md-5"> | |
42 <div class="panel panel-default"> | |
43 <div class="panel-heading">Search Results</div> | |
44 <table id="results" class="table table-striped table-hover"> | |
45 <thead> | |
46 <tr> | |
47 <th>Movie</th> | |
48 <th>Released</th> | |
49 <th>Tagline</th> | |
50 </tr> | |
51 </thead> | |
52 <tbody> | |
53 </tbody> | |
54 </table> | |
55 </div> | |
56 </div> | |
57 <div class="col-md-7"> | |
58 <div class="panel panel-default"> | |
59 <div class="panel-heading" id="title">Details</div> | |
60 <div class="row"> | |
61 <div class="col-sm-4 col-md-4"> | |
62 <img src="" class="well" id="poster"/> | |
63 </div> | |
64 <div class="col-md-8 col-sm-8"> | |
65 <h4>Crew</h4> | |
66 <ul id="crew"> | |
67 </ul> | |
68 </div> | |
69 </div> | |
70 </div> | |
71 </div> | |
72 </div> | |
73 <style type="text/css"> | |
74 .node { stroke: #222; stroke-width: 1.5px; } | |
75 .node.actor { fill: #888; } | |
76 .node.movie { fill: #BBB; } | |
77 .link { stroke: #999; stroke-opacity: .6; stroke-width: 1px; } | |
78 </style> | |
79 | |
80 <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
81 <script src="http://d3js.org/d3.v3.min.js" type="text/javascript"></script> | |
82 <script type="text/javascript"> | |
83 $(function () { | |
84 function showMovie(title) { | |
85 $.get("/movie/" + encodeURIComponent(title), | |
86 function (data) { | |
87 if (!data) return; | |
88 $("#title").text(data.title); | |
89 $("#poster").attr("src","http://neo4j-contrib.github.io/developer-resources/language-guides/assets/posters/"+encodeURIComponent(data.title)+".jpg"); | |
90 var $list = $("#crew").empty(); | |
91 data.cast.forEach(function (cast) { | |
92 $list.append($("<li>" + cast.name + " " +cast.job + (cast.job == "acted"?" as " + cast.role : "") + "</li>")); | |
93 }); | |
94 }, "json"); | |
95 return false; | |
96 } | |
97 function search() { | |
98 var query=$("#search").find("input[name=search]").val(); | |
99 $.get("/search?q=" + encodeURIComponent(query), | |
100 function (data) { | |
101 var t = $("table#results tbody").empty(); | |
102 if (!data || data.length == 0) return; | |
103 data.forEach(function (row) { | |
104 var movie = row.movie; | |
105 $("<tr><td class='movie'>" + movie.title + "</td><td>" + movie.released + "</td><td>" + movie.tagline + "</td></tr>").appendTo(t) | |
106 .click(function() { showMovie($(this).find("td.movie").text());}) | |
107 }); | |
108 showMovie(data[0].movie.title); | |
109 }, "json"); | |
110 return false; | |
111 } | |
112 | |
113 $("#search").submit(search); | |
114 search(); | |
115 }) | |
116 </script> | |
117 | |
118 <script type="text/javascript"> | |
119 var width = 800, height = 800; | |
120 | |
121 var force = d3.layout.force() | |
122 .charge(-200).linkDistance(30).size([width, height]); | |
123 | |
124 var svg = d3.select("#graph").append("svg") | |
125 .attr("width", "100%").attr("height", "100%") | |
126 .attr("pointer-events", "all"); | |
127 | |
128 d3.json("/graph", function(error, graph) { | |
129 if (error) return; | |
130 | |
131 force.nodes(graph.nodes).links(graph.links).start(); | |
132 | |
133 var link = svg.selectAll(".link") | |
134 .data(graph.links).enter() | |
135 .append("line").attr("class", "link"); | |
136 | |
137 var node = svg.selectAll(".node") | |
138 .data(graph.nodes).enter() | |
139 .append("circle") | |
140 .attr("class", function (d) { return "node "+d.label }) | |
141 .attr("r", 10) | |
142 .call(force.drag); | |
143 | |
144 // html title attribute | |
145 node.append("title") | |
146 .text(function (d) { return d.title; }) | |
147 | |
148 // force feed algo ticks | |
149 force.on("tick", function() { | |
150 link.attr("x1", function(d) { return d.source.x; }) | |
151 .attr("y1", function(d) { return d.source.y; }) | |
152 .attr("x2", function(d) { return d.target.x; }) | |
153 .attr("y2", function(d) { return d.target.y; }); | |
154 | |
155 node.attr("cx", function(d) { return d.x; }) | |
156 .attr("cy", function(d) { return d.y; }); | |
157 }); | |
158 }); | |
159 </script> | |
160 </body> | |
161 </html> |