Update tradition name in directory as soon as it is changed. Fixes #35
[scpubgit/stemmaweb.git] / root / js / componentload.js
index 57ddb17..5c9412d 100644 (file)
@@ -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();
@@ -217,11 +222,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 ) {
@@ -616,7 +622,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();
                                },
                        },
                },