X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Fcomponentload.js;h=24b692b0e32f5d06c1a9cbd375d248914cef9c3c;hb=e4fd6366fd96df7b3076ac8f76e1701e7083342b;hp=57ddb17350287a3f93b0494169b5f56e7f5bcc82;hpb=509e94bc8086be4f2e2029d6c707c7dc541a762a;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/componentload.js b/root/js/componentload.js index 57ddb17..24b692b 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -85,7 +85,10 @@ function load_textinfo() { $('#textinfo_waitbox').hide(); $('#textinfo_load_status').empty(); $('#textinfo_container').show(); + // The tradition name should appear here and should be identical in the + // corresponding directory span. In case the name was just changed... $('.texttitle').empty().append( selectedTextInfo.name ); + $('#' + selectedTextID).empty().append( selectedTextInfo.name ); // Witnesses $('#witness_num').empty().append( selectedTextInfo.witnesses.size ); $('#witness_list').empty().append( selectedTextInfo.witnesses.join( ', ' ) ); @@ -161,9 +164,11 @@ function switch_stemweb_ui() { if( selectedTextInfo.stemweb_jobid == 0 ) { // We want to run Stemweb. $('#open_stemweb_ui').show(); - $('#call_stemweb').show() $('#query_stemweb_ui').hide(); - $('#stemweb_run_button').show(); + if( ! $('#stemweb-ui-dialog').dialog('isOpen') ) { + $('#call_stemweb').show() + $('#stemweb_run_button').show(); + } } else { $('#query_stemweb_ui').show(); $('#open_stemweb_ui').hide(); @@ -180,7 +185,6 @@ function query_stemweb_progress() { $.getJSON( requrl, function (data) { process_stemweb_result( data ); }); - // TODO need an error handler } function process_stemweb_result(data) { @@ -198,6 +202,9 @@ function process_stemweb_result(data) { var newIdx = stemmata.length - data.stemmata.length; load_stemma( newIdx, true ); } + // Hide the call dialog no matter how we got here + $('#call_stemweb').hide() + $('#stemweb_run_button').hide(); $('#stemweb_run_status').empty().append( _make_message( 'notification', 'You have one or more new stemmata!' ) ); } else { @@ -207,7 +214,7 @@ function process_stemweb_result(data) { } else if( data.status === 'running' ) { // Just tell the user. $('#stemweb_run_status').empty().append( - _make_message( 'notification', 'Your Stemweb query is still running!' ) ); + _make_message( 'warning', 'Your Stemweb query is still running!' ) ); } else if( data.status === 'notfound' ) { // Ask the user to refresh, for now. $('#stemweb_run_status').empty().append( @@ -217,11 +224,12 @@ function process_stemweb_result(data) { failureMsg = 'Your stemweb query failed'; if( data.message ) { failureMsg = failureMsg + ' with the following message: ' + data.message + } else { + failureMsg = failureMsg + ' without telling us why.' } $('#stemweb_run_status').empty().append( - _make_message( 'error', failuremsg + '.' ) ); + _make_message( 'error', failureMsg ) ); } - switch_stemweb_ui(); } function _make_message( type, msg ) { @@ -598,13 +606,13 @@ $(document).ready( function() { // whether to send application/json or application/xml? $.getJSON( requrl, reqparam, function (data) { mybuttons.button("enable"); - $('#stemweb-ui-dialog').dialog('close'); if( 'jobid' in data ) { // There is a pending job. selectedTextInfo.stemweb_jobid = data.jobid; - alert("Your request has been submitted to Stemweb.\nThe resulting tree will appear in due course."); + $('#stemweb_run_status').empty().append( + _make_message( 'notification', "Your request has been submitted to Stemweb.\nThe resulting tree will appear in due course." ) ); // Reload the current stemma to rejigger the buttons - load_stemma( selectedStemmaID, true ); + switch_stemweb_ui(); } else { // We appear to have an answer; process it. process_stemweb_result( data ); @@ -616,7 +624,8 @@ $(document).ready( function() { id: 'stemweb_close_button', text: 'Close', click: function() { - $('#stemweb-ui-dialog').dialog('close'); + $('#stemweb-ui-dialog').dialog('close'); + switch_stemweb_ui(); }, }, },