X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Frelationship.js;h=b2a6f2df75f1f6e4164230cf1379f12b3bb78bee;hb=cfa6ff766d71f99550b215cf31b9d5f82bdfcde4;hp=adc23bf6566667dd5316e73abad54955a6477248;hpb=76f05423e4d36c01a24381f4b1ec91b4a762bfbe;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/relationship.js b/root/js/relationship.js index adc23bf..b2a6f2d 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -3,34 +3,169 @@ var svg_root = null; var svg_root_element = null; var start_element_height = 0; var reltypes = {}; +var readingdata = {}; -function getTextPath() { - var currpath = window.location.pathname; - // Get rid of trailing slash - if( currpath.lastIndexOf('/') == currpath.length - 1 ) { - currpath = currpath.slice( 0, currpath.length - 1) - }; - // Get rid of query parameters - if( currpath.lastIndexOf('?') != -1 ) { - currpath = currpath.slice( 0, currpath.lastIndexOf('?') ); - }; - var path_elements = currpath.split('/'); - var textid = path_elements.pop(); - var basepath = path_elements.join( '/' ); - var path_parts = [ basepath, textid ]; - return path_parts; +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 = $('