annotate ismi-python-neo4jrestclient/static/commentaries.html @ 39:88c5232f9d48 default tip

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