1 function loadTradition( textid, textname, editable ) {
2 selectedTextID = textid;
3 // First insert the placeholder image and register an error handler
4 var basepath = window.location.pathname
5 if( basepath.lastIndexOf('/') == basepath.length - 1 ) {
6 basepath = basepath.slice( 0, basepath.length - 1)
8 $('#textinfo_load_status').empty();
9 $('#stemma_graph').empty();
10 $('#textinfo_waitbox').show();
11 $('#textinfo_container').ajaxError(
12 function ( e, jqxhr, settings, exception ) {
13 if ( settings.url.indexOf( 'textinfo' ) > -1 ) {
14 $('#textinfo_waitbox').hide();
15 var msg = "An error occurred: ";
16 var msghtml = $('<span>').attr('class', 'error').text(
17 msg + jqxhr.status + " " + jqxhr.statusText);
18 $("#textinfo_load_status").append( msghtml ).show();
22 // Then get and load the actual content.
23 // TODO: scale #stemma_graph both horizontally and vertically
24 // TODO: load svgs from SVG.Jquery (to make scaling react in Safari)
25 $.getJSON( basepath + "/textinfo/" + textid, function (textdata) {
26 // Add the scalar data
27 $('#textinfo_waitbox').hide();
28 $('#textinfo_container').show();
29 $('.texttitle').empty().append( textdata.traditionname );
30 $('#witness_num').empty().append( textdata.witnesses.size );
31 $('#witness_list').empty().append( textdata.witnesses.join( ', ' ) );
32 $('#reading_num').empty().append( textdata.readings );
33 $('#relationship_num').empty().append( textdata.relationships );
34 // Add the stemma(ta) and set up the stexaminer button
35 stemmata = textdata.stemmata;
36 if( stemmata.length ) {
38 load_stemma( selectedStemmaID, basepath );
40 // Set up the relationship mapper button
41 $('#run_relater').attr( 'action', basepath + "/relation/" + textid );
45 function load_stemma( idx, basepath ) {
47 selectedStemmaID = idx;
48 $('#stemma_graph').empty();
49 $('#stemma_graph').append( stemmata[idx] );
50 // Stexaminer submit action
51 var stexpath = basepath + "/stexaminer/" + selectedTextID + "/" + idx;
52 $('#run_stexaminer').attr( 'action', stexpath );