X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Frelationship.js;h=6e4295b2f6d883e1355040a3743ab3070199baf7;hb=a166dca8c7ea6f667181841bd25905b55901df76;hp=2cbd7ee818c9705c91fda151a7555b9f30ba0074;hpb=69a19c917ed3a2303f3beb7f669c55e7f1bedb47;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/relationship.js b/root/js/relationship.js index 2cbd7ee..6e4295b 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -1,32 +1,199 @@ -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; +var MARGIN=30; +var svg_root = null; +var svg_root_element = null; +var start_element_height = 0; +var reltypes = {}; +var readingdata = {}; + +function getTextURL( which ) { + return basepath + textid + '/' + which; +} + +function getReadingURL( reading_id ) { + return basepath + textid + '/reading/' + reading_id; +} + +// Make an XML ID into a valid selector +function jq(myid) { + return '#' + myid.replace(/(:|\.)/g,'\\$1'); +} + +// Actions for opening the reading panel +function node_dblclick_listener( evt ) { + // Open the reading dialogue for the given node. + // First get the reading info + var reading_id = $(this).attr('id'); + var reading_info = readingdata[reading_id]; + // and then populate the dialog box with it. + // Set the easy properties first + $('#reading-form').dialog( 'option', 'title', 'Reading information for "' + reading_info['text'] + '"' ); + $('#reading_id').val( reading_id ); + toggle_checkbox( $('#reading_is_nonsense'), reading_info['is_nonsense'] ); + toggle_checkbox( $('#reading_grammar_invalid'), reading_info['grammar_invalid'] ); + // Use .text as a backup for .normal_form + var normal_form = reading_info['normal_form']; + if( !normal_form ) { + normal_form = reading_info['text']; + } + var nfboxsize = 10; + if( normal_form.length > 9 ) { + nfboxsize = normal_form.length + 1; + } + $('#reading_normal_form').attr( 'size', nfboxsize ) + $('#reading_normal_form').val( normal_form ); + if( editable ) { + // Fill in the witnesses for the de-collation box. + $('#reading_decollate_witnesses').empty(); + $.each( reading_info['witnesses'], function( idx, wit ) { + $('#reading_decollate_witnesses').append( $('