Mercurial > hg > NetworkVis
annotate ismi-python-neo4jrestclient/static/commentaries.html @ 38:fee275163ff9
more layout tweaks.
| author | casties |
|---|---|
| date | Thu, 04 Feb 2016 17:41:49 +0100 |
| parents | 7b5dcd3238d2 |
| children | 88c5232f9d48 |
| rev | line source |
|---|---|
| 20 | 1 <html> |
| 2 <head> | |
| 3 <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| 4 <link rel="stylesheet" href="static/main.css"> | |
| 5 <title>ISMI commentary relations</title> | |
| 6 </head> | |
| 7 | |
| 8 <body style="background:none;"> | |
| 9 <div role="navigation" class="navbar navbar-default navbar-static-top"> | |
| 10 <div class="container"> | |
| 11 <div class="row"> | |
| 12 <div class="col-sm-6 col-md-6"> | |
| 13 <ul class="nav navbar-nav"> | |
| 14 <li> | |
| 15 <form role="search" class="navbar-form" id="search"> | |
| 16 <div class="form-group"> | |
|
31
a6b2a09ea413
fix commentary chain visualisation author name display and search by clicking author name.
casties
parents:
24
diff
changeset
|
17 <input type="text" value="jaghmini" placeholder="Search for person name" class="form-control" name="search"> |
| 20 | 18 </div> |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
19 <button class="btn btn-default" type="submit">Search for author name or id</button> |
| 20 | 20 </form> |
| 21 </li> | |
| 22 </ul> | |
| 23 </div> | |
| 24 <div class="navbar-header col-sm-6 col-md-6"> | |
| 25 <div class="logo-well"> | |
| 26 <a href="//neo4j.com/developer-resources"> | |
| 27 <img src="//neo4j-contrib.github.io/developer-resources/language-guides/assets/img/logo-white.svg" alt="Neo4j World's Leading Graph Database" id="logo"> | |
| 28 </a> | |
| 29 </div> | |
| 30 <div class="navbar-brand"> | |
| 31 <div class="brand">ISMI Commentary relations between Texts</div> | |
| 32 </div> | |
| 33 </div> | |
| 34 </div> | |
| 35 </div> | |
| 36 </div> | |
| 37 | |
| 38 <div class="row"> | |
| 38 | 39 <div class="col-md-7"> |
| 20 | 40 <div class="panel panel-default"> |
| 41 <div class="panel-heading"> | |
| 35 | 42 <b id="author">Titles by this author</b> |
| 20 | 43 <span class="clickhide">(click to hide)</span> |
| 44 <span class="clickhide" style="display:none;">(click to show)</span> | |
| 45 </div> | |
| 46 <table id="results" class="table table-striped table-hover"> | |
| 47 <thead> | |
| 48 <tr> | |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
49 <th>Author</th> |
| 20 | 50 <th>Title (translit)</th> |
| 51 <th>Title (arabic)</th> | |
| 52 <th>ismi_id</th> | |
| 53 </tr> | |
| 54 </thead> | |
| 55 <tbody> | |
| 56 </tbody> | |
| 57 </table> | |
| 58 </div> | |
| 59 </div> | |
| 38 | 60 <div class="col-md-5"> |
| 20 | 61 <div class="panel panel-default"> |
| 62 <div class="panel-heading"> | |
| 35 | 63 <b id="title">Text details</b> |
| 20 | 64 <span class="clickhide">(click to hide)</span> |
| 65 <span class="clickhide" style="display:none;">(click to show)</span> | |
| 66 </div> | |
| 67 <div class="row"> | |
| 68 <!-- <div class="col-sm-4 col-md-4"> | |
| 69 <img src="" class="well" id="poster"/> | |
| 70 </div> --> | |
| 71 <div class="col-md-8 col-sm-8"> | |
| 36 | 72 <h5>Details</h5> |
| 73 <ul id="info" class="list-unstyled"> | |
| 20 | 74 </ul> |
| 36 | 75 <h5>Commenting on</h5> |
| 20 | 76 <ul id="commenting"> |
| 77 </ul> | |
| 36 | 78 <h5>Commentaries</h5> |
| 20 | 79 <ul id="commentaries"> |
| 80 </ul> | |
| 81 </div> | |
| 82 </div> | |
| 83 </div> | |
| 84 </div> | |
| 85 </div> | |
| 86 <div class="col-lg-12"> | |
| 87 <div class="panel panel-default"> | |
| 88 <div class="panel-heading"> | |
| 35 | 89 <span><b>Graph of commentaries</b></span> |
| 20 | 90 <span class="clickhide">(click to hide)</span> |
| 91 <span class="clickhide" style="display:none;">(click to show)</span> | |
| 92 </div> | |
| 93 <div id="graph"> | |
| 94 </div> | |
| 95 </div> | |
| 96 </div> | |
| 97 | |
| 98 <style type="text/css"> | |
| 99 .node { stroke: #222; stroke-width: 1.5px; } | |
| 100 .node.TEXT { fill: #888; } | |
| 101 .node.TEXT.marked { stroke: red; } | |
| 102 .node.TEXT.selected { fill: red; } | |
| 103 .link { stroke: #999; stroke-opacity: .6; stroke-width: 2px; } | |
| 104 .arrowHead { fill: #999 } | |
| 105 tr.marked {border: 2px solid red;} | |
| 106 </style> | |
| 107 | |
| 108 <script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
| 109 <!-- <script src="https://d3js.org/d3.v3.min.js" type="text/javascript"></script> --> | |
| 110 <script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" type="text/javascript"></script> | |
| 111 <script type="text/javascript"> | |
| 112 // make panels roll-up | |
| 113 $(".panel-heading").on("click", function() { | |
| 114 $(this).find(".clickhide").toggle(); | |
| 115 $(this).next().slideToggle(); | |
| 116 }); | |
| 117 // provide search and graph | |
|
31
a6b2a09ea413
fix commentary chain visualisation author name display and search by clicking author name.
casties
parents:
24
diff
changeset
|
118 backendApiPrefix = ""; |
| 20 | 119 searchApi = {}; |
| 120 $(function () { | |
| 121 function showText(text_id) { | |
| 122 $.get(backendApiPrefix+"/textandcommentaries/" + encodeURIComponent(text_id), | |
| 123 function (data) { | |
| 124 if (!data) return; | |
| 125 $("#title").text("Title: "+data.title); | |
| 126 var $list = $("#info").empty(); | |
| 35 | 127 $list.append($("<li><b>Author:</b> " + data.author.label + " [" + data.author.ismi_id + "]</li>") |
| 21 | 128 .click(function() { |
|
31
a6b2a09ea413
fix commentary chain visualisation author name display and search by clicking author name.
casties
parents:
24
diff
changeset
|
129 search(data.author.label, true); |
| 21 | 130 })); |
| 20 | 131 for (var key in data.attrs) { |
|
31
a6b2a09ea413
fix commentary chain visualisation author name display and search by clicking author name.
casties
parents:
24
diff
changeset
|
132 if (key[0] === "_") continue; |
| 20 | 133 var val = data.attrs[key]; |
| 134 if (key === "link") { | |
| 135 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>"; | |
| 136 } | |
| 35 | 137 $list.append($("<li><b>" + key + ":</b> " + val + "</li>")); |
| 20 | 138 }; |
| 139 // re-set selected | |
| 140 $("#graph .selected").each(function(){this.classList.remove("selected")}); | |
| 141 $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")}); | |
| 21 | 142 // add commentaries |
| 20 | 143 var $commentaries = $("#commentaries").empty(); |
| 144 for (var key in data.commentaries) { | |
| 145 var val = data.commentaries[key]; | |
| 146 $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>") | |
| 147 .click(function() { showText($(this).find("span.text_id").text());})); | |
| 148 } | |
| 149 var $commenting = $("#commenting").empty(); | |
| 150 for (var key in data.commenting) { | |
| 151 var val = data.commenting[key]; | |
| 152 $commenting.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>") | |
| 153 .click(function() { showText($(this).find("span.text_id").text());})); | |
| 154 } | |
| 155 }, "json"); | |
| 156 return false; | |
| 157 } | |
| 21 | 158 function search(query, keep_detail_view) { |
| 24 | 159 console.log("search query=", typeof query); |
| 160 if (query == null || typeof query === "object") { | |
| 21 | 161 query=$("#search").find("input[name=search]").val(); |
| 162 } | |
| 20 | 163 $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query), |
| 164 function (data) { | |
| 165 var t = $("table#results tbody").empty(); | |
| 166 if (!data || data.length == 0) return; | |
| 167 // clear all marks | |
| 168 $("#graph .marked").each(function(){this.classList.remove("marked")}); | |
| 21 | 169 // fill table of titles |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
170 var authors = {}; |
| 20 | 171 data.forEach(function (row) { |
| 172 var text = row.text; | |
| 173 var author = row.author; | |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
174 // collect authors |
|
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
175 authors[author.ismi_id] = author; |
| 20 | 176 var comm = row.is_commentary || row.has_commentaries; |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
177 var $row = $("<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) |
| 20 | 178 .click(function() { showText($(this).find("td.text_id").text());}); |
| 179 if (comm) { | |
| 180 $row.addClass("marked"); | |
| 181 } | |
| 182 // set mark | |
| 183 $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); | |
| 184 }); | |
|
37
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
185 var authorlist = ""; |
|
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
186 for (var a in authors) { |
|
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
187 authorlist += (authorlist ? ", " : "") + authors[a].label + " ["+authors[a].ismi_id+"]"; |
|
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
188 } |
|
7b5dcd3238d2
search field also accepts ismi_ids. display list of authors in head. display author name in title list.
casties
parents:
36
diff
changeset
|
189 $("#author").text("Titles by: "+authorlist); |
| 21 | 190 if (!keep_detail_view) { |
|
31
a6b2a09ea413
fix commentary chain visualisation author name display and search by clicking author name.
casties
parents:
24
diff
changeset
|
191 // show first title in detail view |
| 21 | 192 showText(data[0].text.ismi_id); |
| 193 } | |
| 20 | 194 }, "json"); |
| 195 return false; | |
| 196 } | |
| 197 // export API | |
| 198 searchApi.showText = showText; | |
| 199 searchApi.search = search; | |
| 200 // start search | |
| 201 $("#search").submit(search); | |
| 202 search(); | |
| 203 }); | |
| 204 </script> | |
| 205 | |
| 206 <script type="text/javascript"> | |
| 207 var width = 1400, height = 1400; | |
| 208 | |
| 209 var force = d3.layout.force() | |
| 210 .charge(-100) // -200 | |
| 211 .linkDistance(30) // 30 | |
| 212 .size([width, height]); | |
| 213 | |
| 214 var svg = d3.select("#graph").append("svg") | |
| 215 .attr("width", "1400px").attr("height", "1400px") | |
| 216 .attr("pointer-events", "all"); | |
| 217 | |
| 218 // arrow head marker | |
| 219 var defs = svg.append("defs").append("marker") | |
| 220 .attr({ | |
| 221 "id":"arrow", | |
| 222 "markerUnits": "strokeWidth", | |
| 223 "viewBox":"0 -5 10 10", | |
| 224 "refX": 20, // 5 | |
| 225 "refY":0, | |
| 226 "markerWidth":4, | |
| 227 "markerHeight":4, | |
| 228 "orient":"auto" | |
| 229 }) | |
| 230 .append("path") | |
| 231 .attr("d", "M0,-5 L10,0 L0,5") | |
| 232 .attr("class","arrowHead"); | |
| 233 | |
| 234 // load graph | |
|
22
b709419d4235
show id for author in detail panel.
root@ismi-dev.rz-berlin.mpg.de
parents:
21
diff
changeset
|
235 d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) { |
| 20 | 236 if (error) return; |
| 237 | |
| 238 force.nodes(graph.nodes).links(graph.links).start(); | |
| 239 | |
| 240 var link = svg.selectAll(".link") | |
| 241 .data(graph.links).enter() | |
| 242 .append("line").attr({ | |
| 243 "class": "link", | |
| 244 "marker-end": "url(#arrow)" | |
| 245 }); | |
| 246 | |
| 247 var node = svg.selectAll(".node") | |
| 248 .data(graph.nodes).enter() | |
| 249 .append("circle") | |
| 250 .attr("class", function (d) { return "node "+d.label+" ismi-"+d.ismi_id}) | |
| 251 .attr("r", 8) // 10 | |
| 252 .attr("data-ismi_id", function(d) {return d.ismi_id}) | |
| 253 .on("click", function() { | |
| 254 var id = this.getAttribute("data-ismi_id"); | |
| 255 searchApi.showText(id); | |
| 256 }) | |
| 257 .call(force.drag); | |
| 258 | |
| 259 console.log("searchApi:", searchApi); | |
| 260 // html title attribute | |
| 261 node.append("title") | |
| 262 .text(function (d) { return d.title; }) | |
| 263 | |
| 264 // force feed algo ticks | |
| 265 force.on("tick", function() { | |
| 266 link.attr("x1", function(d) { return d.source.x; }) | |
| 267 .attr("y1", function(d) { return d.source.y; }) | |
| 268 .attr("x2", function(d) { return d.target.x; }) | |
| 269 .attr("y2", function(d) { return d.target.y; }); | |
| 270 | |
| 271 node.attr("cx", function(d) { return d.x; }) | |
| 272 .attr("cy", function(d) { return d.y; }); | |
| 273 }); | |
| 274 }); | |
| 275 | |
| 276 </script> | |
| 277 </body> | |
| 278 </html> |
