13
|
1 <html>
|
|
2 <head>
|
|
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
4 <link rel="stylesheet" href="//neo4j-contrib.github.io/developer-resources/language-guides/assets/css/main.css">
|
|
5 <title>ISMI commentary relations</title>
|
|
6 </head>
|
|
7
|
|
8 <body style="background:none;">
|
|
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="tusi" placeholder="Search for 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="//neo4j.com/developer-resources">
|
|
29 <img src="//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 Commentary relations between 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>
|
14
|
47 <th>Author (translit)</th>
|
13
|
48 <th>Title (translit)</th>
|
|
49 <th>Title (arabic)</th>
|
|
50 <th>ismi_id</th>
|
|
51 </tr>
|
|
52 </thead>
|
|
53 <tbody>
|
|
54 </tbody>
|
|
55 </table>
|
|
56 </div>
|
|
57 </div>
|
|
58 <div class="col-md-7">
|
|
59 <div class="panel panel-default">
|
|
60 <div class="panel-heading" id="title">Details</div>
|
|
61 <div class="row">
|
|
62 <!-- <div class="col-sm-4 col-md-4">
|
|
63 <img src="" class="well" id="poster"/>
|
|
64 </div> -->
|
|
65 <div class="col-md-8 col-sm-8">
|
|
66 <h4>Details</h4>
|
|
67 <ul id="info">
|
|
68 </ul>
|
|
69 <h4>Commenting on</h4>
|
|
70 <ul id="commenting">
|
|
71 </ul>
|
|
72 <h4>Commentaries</h4>
|
|
73 <ul id="commentaries">
|
|
74 </ul>
|
|
75 </div>
|
|
76 </div>
|
|
77 </div>
|
|
78 </div>
|
|
79 </div>
|
|
80 <style type="text/css">
|
|
81 .node { stroke: #222; stroke-width: 1.5px; }
|
|
82 .node.TEXT { fill: #888; }
|
|
83 .node.movie { fill: #BBB; }
|
|
84 .link { stroke: #999; stroke-opacity: .6; stroke-width: 1px; }
|
|
85 </style>
|
|
86
|
|
87 <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
88 <!-- <script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script> -->
|
|
89 <script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" type="text/javascript"></script>
|
|
90 <script type="text/javascript">
|
|
91 backendApiPrefix = "";
|
|
92 $(function () {
|
|
93 function showText(text_id) {
|
|
94 $.get(backendApiPrefix+"/textandcommentaries/" + encodeURIComponent(text_id),
|
|
95 function (data) {
|
|
96 if (!data) return;
|
|
97 $("#title").text(data.title);
|
|
98 var $list = $("#info").empty();
|
14
|
99 $list.append($("<li> author: " + data.author + "</li>"));
|
13
|
100 for (var key in data.attrs) {
|
|
101 var val = data.attrs[key];
|
|
102 if (key === "link") {
|
|
103 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>";
|
|
104 }
|
|
105 $list.append($("<li>" + key + ": " + val + "</li>"));
|
|
106 };
|
|
107 var $commentaries = $("#commentaries").empty();
|
|
108 for (var key in data.commentaries) {
|
|
109 var val = data.commentaries[key];
|
14
|
110 $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
|
13
|
111 .click(function() { showText($(this).find("span.text_id").text());}));
|
|
112 }
|
|
113 var $commenting = $("#commenting").empty();
|
|
114 for (var key in data.commenting) {
|
|
115 var val = data.commenting[key];
|
14
|
116 $commenting.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>")
|
13
|
117 .click(function() { showText($(this).find("span.text_id").text());}));
|
|
118 }
|
|
119 }, "json");
|
|
120 return false;
|
|
121 }
|
|
122 function search() {
|
|
123 var query=$("#search").find("input[name=search]").val();
|
|
124 $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query),
|
|
125 function (data) {
|
|
126 var t = $("table#results tbody").empty();
|
|
127 if (!data || data.length == 0) return;
|
|
128 data.forEach(function (row) {
|
|
129 var text = row.text;
|
|
130 var author = row.author;
|
|
131 $("<tr><td>" + author.label + "</td><td>" + text.label + "</td><td>" + text.full_title + "</td><td class='text_id'>" + text.ismi_id + "</td></tr>").appendTo(t)
|
|
132 .click(function() { showText($(this).find("td.text_id").text());})
|
|
133 });
|
|
134 showText(data[0].text.ismi_id);
|
|
135 }, "json");
|
|
136 return false;
|
|
137 }
|
|
138
|
|
139 $("#search").submit(search);
|
|
140 search();
|
|
141 })
|
|
142 </script>
|
|
143
|
|
144 <script type="text/javascript">
|
|
145 var width = 800, height = 800;
|
|
146
|
|
147 var force = d3.layout.force()
|
|
148 .charge(-200).linkDistance(30).size([width, height]);
|
|
149
|
|
150 var svg = d3.select("#graph").append("svg")
|
|
151 .attr("width", "100%").attr("height", "100%")
|
|
152 .attr("pointer-events", "all");
|
|
153
|
|
154 d3.json(backendApiPrefix+"/graph", function(error, graph) {
|
|
155 if (error) return;
|
|
156
|
|
157 force.nodes(graph.nodes).links(graph.links).start();
|
|
158
|
|
159 var link = svg.selectAll(".link")
|
|
160 .data(graph.links).enter()
|
|
161 .append("line").attr("class", "link");
|
|
162
|
|
163 var node = svg.selectAll(".node")
|
|
164 .data(graph.nodes).enter()
|
|
165 .append("circle")
|
|
166 .attr("class", function (d) { return "node "+d.label })
|
|
167 .attr("r", 10)
|
|
168 .call(force.drag);
|
|
169
|
|
170 // html title attribute
|
|
171 node.append("title")
|
|
172 .text(function (d) { return d.title; })
|
|
173
|
|
174 // force feed algo ticks
|
|
175 force.on("tick", function() {
|
|
176 link.attr("x1", function(d) { return d.source.x; })
|
|
177 .attr("y1", function(d) { return d.source.y; })
|
|
178 .attr("x2", function(d) { return d.target.x; })
|
|
179 .attr("y2", function(d) { return d.target.y; });
|
|
180
|
|
181 node.attr("cx", function(d) { return d.x; })
|
|
182 .attr("cy", function(d) { return d.y; });
|
|
183 });
|
|
184 });
|
|
185 </script>
|
|
186 </body>
|
|
187 </html>
|