X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Frelationship.js;h=f011bc6a419fae81941cf3e976774fd1e6f09956;hb=2a65f5c92fc04069b827194aa591a5795bc9b81b;hp=b615f5aa4a31dd4a7caf9bde29bdb7a141f0d1f0;hpb=1500082017b1e41d0286601205de7c655d63fb35;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/relationship.js b/root/js/relationship.js index b615f5a..f011bc6 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -1,80 +1,287 @@ -function getTextPath() { - var currpath = window.location.pathname - if( currpath.lastIndexOf('/') == currpath.length - 1 ) { - currpath = currpath.slice( 0, currpath.length - 1) - }; - var path_elements = currpath.split('/'); - var textid = path_elements.pop(); - var basepath = path_elements.join( '/' ); - var path_parts = [ basepath, textid ]; - return path_parts; -} - -function svgLoaded() { - // some initial scaling - var svg_element = $('#svgbasics').children('svg'); - var svg_graph = svg_element.svg().svg('get').root(); - var svg_vbwidth = svg_graph.viewBox.baseVal.width; - var svg_vbheight = svg_graph.viewBox.baseVal.height; - var scroll_padding = $('#graph_container').width(); - // (Use attr('width') to set width attr, otherwise style="width: npx;" is set.) - var svg_element_width = svg_vbwidth/svg_vbheight * parseInt(svg_element.attr('height')); - svg_element_width += scroll_padding; - svg_element.attr( 'width', svg_element_width ); - $('ellipse').attr( {stroke:'black', fill:'#fff'} ); +var MARGIN=30; +var svg_root = null; +var svg_root_element = null; +var start_element_height = 0; +var reltypes = {}; +var readingdata = {}; +var text_direction = 'LR'; + +jQuery.removeFromArray = function(value, arr) { + return jQuery.grep(arr, function(elem, index) { + return elem !== value; + }); +}; + +function arrayUnique(array) { + var a = array.concat(); + for(var i=0; i 9 ) { + nfboxsize = normal_form.length + 1; + } + $('#reading_normal_form').attr( 'size', nfboxsize ) + $('#reading_normal_form').val( normal_form ); + // Now do the morphological properties. + morphology_form( reading_info['lexemes'] ); + // and then open the dialog. + $('#reading-form').dialog("open"); } +function toggle_checkbox( box, value ) { + if( value == null ) { + value = false; + } + box.attr('checked', value ); +} + +function morphology_form ( lexlist ) { + if( lexlist.length ) { + $('#morph_outer').show(); + $('#morphology').empty(); + $.each( lexlist, function( idx, lex ) { + var morphoptions = []; + if( 'wordform_matchlist' in lex ) { + $.each( lex['wordform_matchlist'], function( tdx, tag ) { + var tagstr = stringify_wordform( tag ); + morphoptions.push( tagstr ); + }); + } + var formtag = 'morphology_' + idx; + var formstr = ''; + if( 'form' in lex ) { + formstr = stringify_wordform( lex['form'] ); + } + var form_morph_elements = morph_elements( + formtag, lex['string'], formstr, morphoptions ); + $.each( form_morph_elements, function( idx, el ) { + $('#morphology').append( el ); + }); + }); + } else { + $('#morph_outer').hide(); + } +} + +function stringify_wordform ( tag ) { + if( tag ) { + var elements = tag.split(' // '); + return elements[1] + ' // ' + elements[2]; + } + return '' +} + +function morph_elements ( formtag, formtxt, currform, morphoptions ) { + var clicktag = '(Click to select)'; + if ( !currform ) { + currform = clicktag; + } + var formlabel = $('