get analysis info into the stexaminer, unstyled as yet
[scpubgit/stemmaweb.git] / root / js / stexaminer.js
CommitLineData
b8a92065 1var colors = ['#ffeeaa','#afc6e9','#d5fff6','#ffccaa','#ffaaaa','#e5ff80','#e5d5ff','#ffd5e5'];
2var row_triggered = false;
d5514865 3
4function color_row( row ) {
b8a92065 5 row_triggered = true;
f007ac1e 6 $('ellipse').attr( {stroke:'white', fill:'#fff'} );
b8a92065 7 $('.node').children('polygon').attr( {stroke:'#fff', fill:'#fff'} );
8 $('.node').children('text').attr( {stroke:'none', fill:'#000'} );
9 $('tr.active_variant_row').children('td').removeClass('cellb0 cellb1 cellb2 cellb3 cellb4 cellb5 cellb6 cellb7');
d5514865 10 row.parent().nextAll('.clickable').children('span').click();
b8a92065 11 $('td.active_variant_cell').removeClass('active_variant_cell');
12 row_triggered = false;
d5514865 13}
14
b8a92065 15function color_nodes( column_index, arr_node_ids, arr_greynode_ids ) {
16 if( !row_triggered ) {
17 $('tr.active_variant_row').children('td').removeClass('cellb0 cellb1 cellb2 cellb3 cellb4 cellb5 cellb6 cellb7');
18 $('td.active_variant_cell').removeClass('active_variant_cell');
f007ac1e 19 $('ellipse').attr( {stroke:'white', fill:'#fff'} );
b8a92065 20 $('.node').children('polygon').attr( {stroke:'#fff', fill:'#fff'} );
21 $('.node').children('text').attr( {stroke:'none', fill:'#000'} );
22 };
23 $('tr.active_variant_row').removeClass('active_variant_row')
24 jQuery.each( arr_greynode_ids, function(index,value) {
25 nodes = $('.node').children('title').filter( function(index) {
26 return $(this).text() == value;
27 })
28 nodes.siblings('ellipse, polygon, text').each( function( index ) {
29 $(this).attr( {stroke:'#ddd', fill:'#f8f8f8'} );
30 });
31 });
32 jQuery.each( arr_node_ids, function(index,value) {
33 $('.node').children('title').filter( function(index) {
34 return $(this).text() == value;
35 }).siblings('ellipse').each( function( index ) {
36 $(this).attr( {stroke:'black', fill:colors[column_index-1]} );
37 });
38 });
39}
ef3db56f 40
41function show_stats( row_index ) {
42 var rs = readingstats[row_index];
43 var rshtml = $('#stats_template').clone();
44 rshtml.find('#statrank').append( rs.id );
45 $.each( rs.readings, function( idx, rdghash ) {
46 var readinglabel = rdghash.readingid;
47 if( rdghash.text ) {
48 readinglabel += ' (' + rdghash.text + ')';
49 }
50 var readingroots = rdghash.independent_occurrence.join( ', ' );
51 var rdgstats = $('#reading_template').clone();
52 rdgstats.find('.readinglabel').append( readinglabel );
53 rdgstats.find('.reading_copied').append( rdghash.followed );
54 rdgstats.find('.reading_changed').append( rdghash.not_followed );
55 rdgstats.find('.reading_unclear').append( rdghash.follow_unknown );
56 rdgstats.find('.readingroots').append( readingroots );
57 if( ! $.isEmptyObject( rdghash.reading_parents ) ) {
58 var parentstats = $('#reading_parent_template').clone();
59 $.each( rdghash.reading_parents, function( parentid, pdata ) {
60 var parentdesc = pdata.label;
61 if( pdata.relation ) {
62 parentdesc += ' - variant type ' + pdata.relation.type;
63 if( pdata.relation.annotation ) {
64 parentdesc += ' [ ' + pdata.relation.annotation + ' ]';
65 }
66 } else {
67 parentdesc += ' - no syntactic relation';
68 }
69 var parentitem = $('<li>').append( parentdesc );
70 parentstats.find('.reading_parent_list').append( parentitem );
71 });
72 rdgstats.find('.reading_statistics').append( parentstats.contents() );
73 }
74 rshtml.append( rdgstats.contents() );
75 });
76 $('#row_statistics').empty();
77 $('#row_statistics').append( rshtml.contents() );
78};