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