// Set the easy properties first
$('#reading-form').dialog( 'option', 'title', 'Reading information for "' + reading_info['text'] + '"' );
$('#reading_id').val( reading_id );
- $('#reading_is_nonsense').val( reading_info['is_nonsense'] );
- $('#reading_grammar_invalid').val( reading_info['grammar_invalid'] );
+ $('#reading_is_nonsense').attr( 'checked', reading_info['is_nonsense'] );
+ $('#reading_grammar_invalid').attr( 'checked', reading_info['grammar_invalid'] );
// Use .text as a backup for .normal_form
var normal_form = reading_info['normal_form'];
if( !normal_form ) {
$('#morphology').empty();
$.each( lexlist, function( idx, lex ) {
var morphoptions = [];
- $.each( lex['wordform_matchlist'], function( tdx, tag ) {
- var tagstr = stringify_wordform( tag );
- morphoptions.push( tagstr );
- });
+ if( 'wordform_matchlist' in lex ) {
+ $.each( lex['wordform_matchlist'], function( tdx, tag ) {
+ var tagstr = stringify_wordform( tag );
+ morphoptions.push( tagstr );
+ });
+ }
var formtag = 'morphology_' + idx;
- //forminput.autocomplete('search', '');
var formstr = '';
- if( lex['form'] ) {
+ if( 'form' in lex ) {
formstr = stringify_wordform( lex['form'] );
}
var form_morph_elements = morph_elements(
}
function stringify_wordform ( tag ) {
- var elements = tag.split(' // ');
- return elements[1] + ' // ' + elements[2];
+ if( tag ) {
+ var elements = tag.split(' // ');
+ return elements[1] + ' // ' + elements[2];
+ }
+ return ''
}
function morph_elements ( formtag, formtxt, currform, morphoptions ) {
});
}
+function relemmatize () {
+ // Send the reading for a new lemmatization and reopen the form.
+ var reading_id = $('#reading_id').val()
+ ncpath = getReadingURL( reading_id );
+ form_values = {
+ 'normal_form': $('#reading_normal_form').val(),
+ 'relemmatize': 1 };
+ var jqjson = $.post( ncpath, form_values, function( data ) {
+ // Update the form with the return
+ if( 'id' in data ) {
+ // We got back a good answer. Stash it
+ readingdata[reading_id] = data;
+ // and regenerate the morphology form.
+ morphology_form( data['lexemes'] );
+ } else {
+ alert("Could not relemmatize as requested: " + data['error']);
+ }
+ });
+}
+
// Initialize the SVG once it exists
function svgEnlargementLoaded() {
//Give some visual evidence that we are working
$("#dialog_overlay").hide();
}
}).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
- if( ( ajaxSettings.type == 'POST' ) && jqXHR.status == 403 ) {
+ if( ajaxSettings.url == getTextURL('relationships')
+ && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) {
var errobj = jQuery.parseJSON( jqXHR.responseText );
$('#status').append( '<p class="error">Error: ' + errobj.error + '</br>The relationship cannot be made.</p>' );
}
$( this ).dialog( "close" );
},
Update: function() {
+ $('#reading_status').empty();
var reading_id = $('#reading_id').val()
form_values = {
'id' : reading_id,
- 'is_nonsense': $('#reading_is_nonsense').val(),
- 'grammar_invalid': $('#reading_grammar_invalid').val(),
+ 'is_nonsense': $('#reading_is_nonsense').is(':checked'),
+ 'grammar_invalid': $('#reading_grammar_invalid').is(':checked'),
'normal_form': $('#reading_normal_form').val() };
// Add the morphology values
$('.reading_morphology').each( function() {
}
},
create: function() {
- // $('#reading_relemmatize').button();
- $('#reading_relemmatize').click( function () {
- // Send the reading for a new lemmatization and reopen the form.
- alert( "Got a click function for relemmatize button" );
- var reading_id = $('#reading_id').val()
- ncpath = getReadingURL( reading_id );
- form_values = {
- 'normal_form': $('#reading_normal_form').val(),
- 'relemmatize': 1 };
- var jqjson = $.post( ncpath, form_values, function( data ) {
- // Update the form with the return
- if( 'reading_id' in data ) {
- // We got back a good answer. Stash it
- readingdata[reading_id] = data;
- // and regenerate the morphology form.
- morphology_form( data['lexemes'] );
- } // else throw an error with what is in ['error']
- });
- // Prevent submit
- return false;
- });
},
open: function() {
$(".ui-widget-overlay").css("background", "none");
$("#dialog_overlay").show();
+ $('#reading_status').empty();
$("#dialog_overlay").height( $("#enlargement_container").height() );
$("#dialog_overlay").width( $("#enlargement_container").innerWidth() );
$("#dialog_overlay").offset( $("#enlargement_container").offset() );
close: function() {
$("#dialog_overlay").hide();
}
+ }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
+ if( ajaxSettings.url.lastIndexOf( getReadingURL('') ) > -1
+ && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) {
+ var errobj = jQuery.parseJSON( jqXHR.responseText );
+ $('#reading_status').append( '<p class="error">Error: ' + errobj.error + '</p>' );
+ }
});