X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=stemmaweb%2Froot%2Fjs%2Fstexaminer.js;h=2a9e10e6eb62dd178aadb8ae9e02be307cbea4ff;hb=e41080b62247df50142675a091efb3b369d08f1d;hp=ffe2c93a754f80f09ca561e89c656fa8a100fef1;hpb=cf9626aa522609c7905db938407b8ef41ab8c840;p=scpubgit%2Fstemmatology.git
diff --git a/stemmaweb/root/js/stexaminer.js b/stemmaweb/root/js/stexaminer.js
index ffe2c93..2a9e10e 100644
--- a/stemmaweb/root/js/stexaminer.js
+++ b/stemmaweb/root/js/stexaminer.js
@@ -1,23 +1,43 @@
var colors = ['#ffeeaa','#afc6e9','#d5fff6','#ffccaa','#ffaaaa','#e5ff80','#e5d5ff','#ffd5e5'];
var row_triggered = false;
-$(document).ready(function() {
- $('.rowid').click( function() {
+var original_svg;
+
+function handle_row_click( row ) {
+ var ridx = row.parent().parent().index()
+ var rs = readingstats[ridx];
+ var imghtml = ''
+ $('#stemma_graph').empty();
+ $('#stemma_graph').append( imghtml );
+ if( rs.layerwits ) {
+ var stemma_form = { 'dot': graphdot, 'layerwits': rs.layerwits };
+ $('#stemma_graph').load( 'graphsvg', stemma_form, function() {
+ color_row( row );
+ show_stats( rs );
+ });
+ } else {
+ $('#stemma_graph').empty();
+ $('#stemma_graph').append( original_svg );
+ color_row( row );
+ show_stats( rs );
+ }
+}
+
+function color_row( row ) {
row_triggered = true;
- $('ellipse').attr( {stroke:'black', fill:'#fff'} );
+ $('ellipse').attr( {stroke:'white', fill:'#fff'} );
$('.node').children('polygon').attr( {stroke:'#fff', fill:'#fff'} );
$('.node').children('text').attr( {stroke:'none', fill:'#000'} );
$('tr.active_variant_row').children('td').removeClass('cellb0 cellb1 cellb2 cellb3 cellb4 cellb5 cellb6 cellb7');
- $(this).parent().nextAll('.clickable').children('span').click();
+ row.parent().nextAll('.clickable').children('span').click();
$('td.active_variant_cell').removeClass('active_variant_cell');
row_triggered = false;
- });
- $('svg').width('485px');
-})
+}
+
function color_nodes( column_index, arr_node_ids, arr_greynode_ids ) {
if( !row_triggered ) {
$('tr.active_variant_row').children('td').removeClass('cellb0 cellb1 cellb2 cellb3 cellb4 cellb5 cellb6 cellb7');
$('td.active_variant_cell').removeClass('active_variant_cell');
- $('ellipse').attr( {stroke:'black', fill:'#fff'} );
+ $('ellipse').attr( {stroke:'white', fill:'#fff'} );
$('.node').children('polygon').attr( {stroke:'#fff', fill:'#fff'} );
$('.node').children('text').attr( {stroke:'none', fill:'#000'} );
};
@@ -38,3 +58,41 @@ function color_nodes( column_index, arr_node_ids, arr_greynode_ids ) {
});
});
}
+
+function show_stats( rs ) {
+ var rshtml = $('#stats_template').clone();
+ rshtml.find('#statrank').append( rs.id );
+ $.each( rs.readings, function( idx, rdghash ) {
+ var rdgstats = $('#reading_template').clone();
+ rdgstats.find('.readinglabel').append( rdghash.text );
+ rdgstats.find('.reading_copied').append( rdghash.followed );
+ rdgstats.find('.reading_changed').append( rdghash.not_followed );
+ rdgstats.find('.reading_unclear').append( rdghash.follow_unknown );
+ rdgstats.find('.readingroots').append( rdghash.independent_occurrence );
+ if( ! $.isEmptyObject( rdghash.reading_parents ) ) {
+ var parentstats = $('#reading_parent_template').clone();
+ $.each( rdghash.reading_parents, function( parentid, pdata ) {
+ var parentdesc = pdata.label;
+ if( pdata.relation ) {
+ parentdesc += ' - variant type ' + pdata.relation.type;
+ if( pdata.relation.annotation ) {
+ parentdesc += ' [ ' + pdata.relation.annotation + ' ]';
+ }
+ } else {
+ parentdesc += ' - no syntactic relation';
+ }
+ var parentitem = $('