X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fjs%2Fcomponentload.js;h=e881f840f4f1e61dd04479b243f42cb1f1b676e1;hb=2156735cc700dcd5d6a62f8aca4a0f09b7604241;hp=e05e5c5016e7ed06ab56f437277dff534359c8ce;hpb=f6a8db89d391b57e3ddb05a1684ff1e16cfd7523;p=scpubgit%2Fstemmaweb.git diff --git a/root/js/componentload.js b/root/js/componentload.js index e05e5c5..e881f84 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -1,13 +1,19 @@ -function loadTradition( textid ) { - +function loadTradition( textid, textname ) { + // First insert the placeholder image + var basepath = window.location.pathname + if( basepath.lastIndexOf('/') == basepath.length - 1 ) { + basepath = basepath.slice( 0, basepath.length - 1) + }; + var imghtml = 'Loading SVG...' + $('#stemma_graph').empty(); + $('#variant_graph').empty(); + $('#stemma_graph').append( imghtml ); + $('#variant_graph').append( imghtml ); + // Then get and load the actual content. // TODO: scale #stemma_grpah both horizontally and vertically // TODO: load svgs from SVG.Jquery (to make scaling react in Safari) - $('#stemma_graph').load( "stemma/" + textid , function() { - var stemma_svg_element = $('#stemma_graph svg').svg().svg('get').root(); - console.log( stemma_svg_element ); - stemma_svg_element.height.baseVal.value = $('#stemma_graph').height(); - }); - $('#variant_graph').load( "variantgraph/" + textid , function() { + $('#stemma_graph').load( basepath + "/stemma/" + textid ); + $('#variant_graph').load( basepath + "/variantgraph/" + textid , function() { var variant_svg_element = $('#variant_graph svg').svg().svg('get').root(); var svg_height = variant_svg_element.height.baseVal.value; var svg_width = variant_svg_element.width.baseVal.value; @@ -15,4 +21,13 @@ function loadTradition( textid ) { variant_svg_element.height.baseVal.value = container_height; variant_svg_element.width.baseVal.value = (svg_width/svg_height * container_height); }); + + // Then populate the various elements with the right text name/ID. + // Stemma and variant graph titles + $('.texttitle').empty(); + $('.texttitle').append( textname ); + // Stexaminer submit action + $('#run_stexaminer').attr( 'action', basepath + "/stexaminer/" + textid ); + // Relationship mapper submit action + $('#run_relater').attr( 'action', basepath + "/relation/" + textid ); }