Mercurial > hg > NetworkVis
comparison ismi-python-neo4jrestclient/static/commentaries_authors3.html @ 21:d964d9a23837
now with clickable author names in detail panel.
author | casties |
---|---|
date | Fri, 09 Oct 2015 15:01:20 +0200 |
parents | d8bbf6d5920b |
children | b709419d4235 |
comparison
equal
deleted
inserted
replaced
20:d8bbf6d5920b | 21:d964d9a23837 |
---|---|
37 | 37 |
38 <div class="row"> | 38 <div class="row"> |
39 <div class="col-md-5"> | 39 <div class="col-md-5"> |
40 <div class="panel panel-default"> | 40 <div class="panel panel-default"> |
41 <div class="panel-heading"> | 41 <div class="panel-heading"> |
42 <span>Texts by this author</span> | 42 <span id="author">Titles by this author</span> |
43 <span class="clickhide">(click to hide)</span> | 43 <span class="clickhide">(click to hide)</span> |
44 <span class="clickhide" style="display:none;">(click to show)</span> | 44 <span class="clickhide" style="display:none;">(click to show)</span> |
45 </div> | 45 </div> |
46 <table id="results" class="table table-striped table-hover"> | 46 <table id="results" class="table table-striped table-hover"> |
47 <thead> | 47 <thead> |
48 <tr> | 48 <tr> |
49 <th>Author (translit)</th> | |
50 <th>Title (translit)</th> | 49 <th>Title (translit)</th> |
51 <th>Title (arabic)</th> | 50 <th>Title (arabic)</th> |
52 <th>ismi_id</th> | 51 <th>ismi_id</th> |
53 </tr> | 52 </tr> |
54 </thead> | 53 </thead> |
122 $.get(backendApiPrefix+"/textandcommentaries/" + encodeURIComponent(text_id), | 121 $.get(backendApiPrefix+"/textandcommentaries/" + encodeURIComponent(text_id), |
123 function (data) { | 122 function (data) { |
124 if (!data) return; | 123 if (!data) return; |
125 $("#title").text("Title: "+data.title); | 124 $("#title").text("Title: "+data.title); |
126 var $list = $("#info").empty(); | 125 var $list = $("#info").empty(); |
127 $list.append($("<li> author: " + data.author + "</li>")); | 126 $list.append($("<li> Author: " + data.author.label + "</li>") |
127 .click(function() { | |
128 search(data.author.ismi_id, true); | |
129 })); | |
128 for (var key in data.attrs) { | 130 for (var key in data.attrs) { |
129 var val = data.attrs[key]; | 131 var val = data.attrs[key]; |
130 if (key === "link") { | 132 if (key === "link") { |
131 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>"; | 133 val = "<a href=\"" + val + "\" target=\"_blank\">" + val + "</a>"; |
132 } | 134 } |
133 $list.append($("<li>" + key + ": " + val + "</li>")); | 135 $list.append($("<li>" + key + ": " + val + "</li>")); |
134 }; | 136 }; |
135 // re-set selected | 137 // re-set selected |
136 $("#graph .selected").each(function(){this.classList.remove("selected")}); | 138 $("#graph .selected").each(function(){this.classList.remove("selected")}); |
137 $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")}); | 139 $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")}); |
140 // add commentaries | |
138 var $commentaries = $("#commentaries").empty(); | 141 var $commentaries = $("#commentaries").empty(); |
139 for (var key in data.commentaries) { | 142 for (var key in data.commentaries) { |
140 var val = data.commentaries[key]; | 143 var val = data.commentaries[key]; |
141 $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>") | 144 $commentaries.append($("<li>" + val.title + " [<span class=\"text_id\">" + key + "</span>] by " + val.author + "</li>") |
142 .click(function() { showText($(this).find("span.text_id").text());})); | 145 .click(function() { showText($(this).find("span.text_id").text());})); |
148 .click(function() { showText($(this).find("span.text_id").text());})); | 151 .click(function() { showText($(this).find("span.text_id").text());})); |
149 } | 152 } |
150 }, "json"); | 153 }, "json"); |
151 return false; | 154 return false; |
152 } | 155 } |
153 function search() { | 156 function search(query, keep_detail_view) { |
154 var query=$("#search").find("input[name=search]").val(); | 157 if (query == null) { |
158 query=$("#search").find("input[name=search]").val(); | |
159 } | |
155 $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query), | 160 $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query), |
156 function (data) { | 161 function (data) { |
157 var t = $("table#results tbody").empty(); | 162 var t = $("table#results tbody").empty(); |
158 if (!data || data.length == 0) return; | 163 if (!data || data.length == 0) return; |
159 // clear all marks | 164 // clear all marks |
160 $("#graph .marked").each(function(){this.classList.remove("marked")}); | 165 $("#graph .marked").each(function(){this.classList.remove("marked")}); |
166 // fill table of titles | |
161 data.forEach(function (row) { | 167 data.forEach(function (row) { |
162 var text = row.text; | 168 var text = row.text; |
163 var author = row.author; | 169 var author = row.author; |
170 $("#author").text("Titles by Author: "+author.label+" ["+author.ismi_id+"]"); | |
164 var comm = row.is_commentary || row.has_commentaries; | 171 var comm = row.is_commentary || row.has_commentaries; |
165 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) | 172 var $row = $("<tr><td>" + text.label + "</td><td>" + text.full_title + "</td><td class='text_id'>" + text.ismi_id + "</td></tr>").appendTo(t) |
166 .click(function() { showText($(this).find("td.text_id").text());}); | 173 .click(function() { showText($(this).find("td.text_id").text());}); |
167 if (comm) { | 174 if (comm) { |
168 $row.addClass("marked"); | 175 $row.addClass("marked"); |
169 } | 176 } |
170 // set mark | 177 // set mark |
171 $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); | 178 $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); |
172 }); | 179 }); |
173 showText(data[0].text.ismi_id); | 180 if (!keep_detail_view) { |
181 // show first title | |
182 showText(data[0].text.ismi_id); | |
183 } | |
174 }, "json"); | 184 }, "json"); |
175 return false; | 185 return false; |
176 } | 186 } |
177 // export API | 187 // export API |
178 searchApi.showText = showText; | 188 searchApi.showText = showText; |
210 .append("path") | 220 .append("path") |
211 .attr("d", "M0,-5 L10,0 L0,5") | 221 .attr("d", "M0,-5 L10,0 L0,5") |
212 .attr("class","arrowHead"); | 222 .attr("class","arrowHead"); |
213 | 223 |
214 // load graph | 224 // load graph |
215 d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) { | 225 d3.json(backendApiPrefix+"/graph?limit=10", function(error, graph) { |
216 if (error) return; | 226 if (error) return; |
217 | 227 |
218 force.nodes(graph.nodes).links(graph.links).start(); | 228 force.nodes(graph.nodes).links(graph.links).start(); |
219 | 229 |
220 var link = svg.selectAll(".link") | 230 var link = svg.selectAll(".link") |
229 .append("circle") | 239 .append("circle") |
230 .attr("class", function (d) { return "node "+d.label+" ismi-"+d.ismi_id}) | 240 .attr("class", function (d) { return "node "+d.label+" ismi-"+d.ismi_id}) |
231 .attr("r", 8) // 10 | 241 .attr("r", 8) // 10 |
232 .attr("data-ismi_id", function(d) {return d.ismi_id}) | 242 .attr("data-ismi_id", function(d) {return d.ismi_id}) |
233 .on("click", function() { | 243 .on("click", function() { |
234 console.log("click on ", this); | |
235 var id = this.getAttribute("data-ismi_id"); | 244 var id = this.getAttribute("data-ismi_id"); |
236 searchApi.showText(id); | 245 searchApi.showText(id); |
237 }) | 246 }) |
238 .call(force.drag); | 247 .call(force.drag); |
239 | 248 |