use paths relative to our base
[scpubgit/stemmatology.git] / stemmaweb / root / js / componentload.js
1 function loadTradition( textid ) {
2     // First insert the placeholder image
3     var basepath = window.location.pathname
4     var imghtml = '<img src="' + basepath + '/images/ajax-loader.gif" alt="Loading SVG..."/>'
5     $('#stemma_graph').empty();
6     $('#variant_graph').empty();
7     $('#stemma_graph').append( imghtml );
8     $('#variant_graph').append( imghtml );
9     // Then get and load the actual content.
10     // TODO: scale #stemma_grpah both horizontally and vertically
11     // TODO: load svgs from SVG.Jquery (to make scaling react in Safari)
12         $('#stemma_graph').load( basepath + "/stemma/" + textid , function() {
13         var stemma_svg_element = $('#stemma_graph svg').svg().svg('get').root();
14         console.log( stemma_svg_element );
15         stemma_svg_element.height.baseVal.value = $('#stemma_graph').height();
16         });
17     $('#variant_graph').load( basepath + "/variantgraph/" + textid , function() {
18         var variant_svg_element = $('#variant_graph svg').svg().svg('get').root();
19         var svg_height = variant_svg_element.height.baseVal.value;
20         var svg_width = variant_svg_element.width.baseVal.value;
21         var container_height = $('#variant_graph').height();
22         variant_svg_element.height.baseVal.value = container_height;
23         variant_svg_element.width.baseVal.value = (svg_width/svg_height * container_height);
24         });
25 }