X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Fcomponentload.js;h=838da464a877485d00976413214691456b9ec69c;hb=c2b80bba7c5c1620828f6aa4d7ee841bf8d9a8e4;hp=e8042043bf71b68e8f2e0353d8783604f2a971dd;hpb=ed0ce314499c09f02a26f836cb5828919cc6f3fc;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/componentload.js b/root/js/componentload.js index e804204..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');