X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Fcomponentload.js;h=838da464a877485d00976413214691456b9ec69c;hb=c2b80bba7c5c1620828f6aa4d7ee841bf8d9a8e4;hp=0f98f357a85fb6519ddd0bd7c8076d3cfd85d677;hpb=b8f3a8c84607f14ac726968064cd35d3ea0a661c;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/componentload.js b/root/js/componentload.js index 0f98f35..838da46 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -45,12 +45,12 @@ function loadTradition( textid, textname, editable ) { // Hide the functionality that is irrelevant if( editable ) { $('#open_stemma_add').show(); - $('#open_stemweb_ui').show(); $('#open_textinfo_edit').show(); $('#relatebutton_label').text('View collation and edit relationships'); } else { $('#open_stemma_add').hide(); $('#open_stemweb_ui').hide(); + $('#query_stemweb_ui').hide(); $('#open_textinfo_edit').hide(); $('#relatebutton_label').text('View collation and relationships'); } @@ -133,6 +133,14 @@ function load_stemma( idx, editable ) { $('#open_stemma_edit').hide(); $('#run_stexaminer').hide(); $('#stemma_identifier').empty(); + // Add the relevant Stemweb functionality + if( editable ) { + if( selectedTextInfo.stemweb_jobid == 0 ) { + $('#open_stemweb_ui').show(); + } else { + $('#query_stemweb_ui').show(); + } + } if( idx > -1 ) { // Load the stemma and its properties var stemmadata = stemmata[idx]; @@ -151,6 +159,32 @@ function load_stemma( idx, editable ) { } } +function query_stemweb_progress() { + var requrl = _get_url([ "stemweb", "query", selectedTextInfo.stemweb_jobid ]); + $.getJSON( requrl, function (data) { + // Look for a status message, either success, running, or notfound. + if( data.status === 'success' ) { + // Add the new stemmata to the textinfo and tell the user. + if( data.stemmata.length > 0 ) { + stemmata = stemmata.concat( data.stemmata ); + if( selectedStemmaID == -1 ) { + // We have a stemma for the first time; load the first one. + load_stemma( 0 ); + } + alert( 'You have one or more new stemmata!' ); + } else { + alert( 'Stemweb run finished with no stemmata...huh?!' ); + } + } else if( data.status === 'running' ) { + // Just tell the user. + alert( 'Your Stemweb query is still running!' ); + } else if( data.status === 'notfound' ) { + // Ask the user to refresh, for now. + alert( 'Your Stemweb query probably finished and reported back. Please reload to check.' ); + } + }); +} + // Load the SVG we are given function loadSVG(svgData) { var svgElement = $('#stemma_graph'); @@ -511,7 +545,7 @@ $(document).ready( function() { optCtrl = $(''); } // Add the name and element ID - optCtrl.attr( 'name', argInfo.name ).attr( 'id', optId ); + optCtrl.attr( 'name', argInfo.key ).attr( 'id', optId ); // Append the label and the option itself to the form. $('#stemweb_runtime_options').append( optLabel ) .append( optCtrl ).append( $('
') ); @@ -527,8 +561,7 @@ $(document).ready( function() { }, }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) { $(event.target).parent().find('.ui-button').button("enable"); - if( ajaxSettings.url.indexOf( 'algorithms' ) > -1 - && ajaxSettings.type == 'POST' ) { + if( ajaxSettings.url.indexOf( 'stemweb/request' ) > -1 ) { display_error( jqXHR, $("#stemweb_run_status") ); } });