X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Frelationship.js;h=e822d70846d717dff217e35738a9dc95e62290b5;hb=f6516f222feb909cd3999fc0ca29ac90311a0266;hp=7f6ed879c165b0ffb576158468bdcc9fe7cb1dfd;hpb=065c7cf2799ee9e71c8ed953bfc0a166e4a6b902;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/relationship.js b/root/js/relationship.js index 7f6ed87..e822d70 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -5,36 +5,23 @@ 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; -} - -function getRelativePath() { - var path_parts = getTextPath(); - return path_parts[0]; -} +function arrayUnique(array) { + var a = array.concat(); + for(var i=0; i').attr( + 'value', wit ).text( wit ) ); + }); + } // Now do the morphological properties. + morphology_form( reading_info['lexemes'] ); // and then open the dialog. - $('#morphology').empty(); - $.each( reading_info['lexemes'], function( idx, lex ) { - var morphoptions = []; - $.each( lex['wordform_matchlist'], function( tdx, tag ) { - var tagstr = stringify_wordform( tag ); - morphoptions.push( tagstr ); - }); - var formtag = 'morphology_' + idx; - var form_morph_elements = morph_elements( formtag ); - form_morph_elements[0].text( lex['string'] + ': ' ); - form_morph_elements[1].autocomplete({ - source: morphoptions, - minLength: 0 - }); - //forminput.autocomplete('search', ''); - if( lex['form'] ) { - var formstr = stringify_wordform( lex['form'] ); - form_morph_elements[1].val( formstr ); - } - $.each( form_morph_elements, function( idx, el ) { - $('#morphology').append( el ); - }); - }); $('#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 ) { - return tag['lemma'] + ' // ' + tag['morphology']; + if( tag ) { + var elements = tag.split(' // '); + return elements[1] + ' // ' + elements[2]; + } + return '' } -function morph_elements ( formtag ) { +function morph_elements ( formtag, formtxt, currform, morphoptions ) { + var clicktag = '(Click to select)'; + if ( !currform ) { + currform = clicktag; + } var formlabel = $('