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 $('#stemma_graph').empty();
9 $('#textinfo_waitbox').show();
10 $('#textinfo_container').ajaxError(
11 function ( e, jqxhr, settings, exception ) {
12 if ( settings.url.indexOf( 'textinfo' ) > -1 ) {
13 $('#textinfo_waitbox').hide();
14 var msg = "An error occurred: ";
15 var msghtml = $('<span>').attr('class', 'error').text(
16 msg + jqxhr.status + " " + jqxhr.statusText);
17 $("#textinfo_container").append( msghtml ).show();
21 // Then get and load the actual content.
22 // TODO: scale #stemma_graph both horizontally and vertically
23 // TODO: load svgs from SVG.Jquery (to make scaling react in Safari)
24 $.getJSON( basepath + "/textinfo/" + textid, function (textdata) {
25 // Add the scalar data
26 $('#textinfo_waitbox').hide();
27 $('#textinfo_container').show();
28 $('.texttitle').empty().append( textdata.traditionname );
29 $('#witness_num').empty().append( textdata.witnesses.size );
30 $('#witness_list').empty().append( textdata.witnesses.join( ', ' ) );
31 $('#reading_num').empty().append( textdata.readings );
32 $('#relationship_num').empty().append( textdata.relationships );
33 // Add the stemma(ta) and set up the stexaminer button
34 stemmata = textdata.stemmata;
35 if( stemmata.length ) {
37 load_stemma( selectedStemmaID, basepath );
39 // Set up the relationship mapper button
40 $('#run_relater').attr( 'action', basepath + "/relation/" + textid );
44 function load_stemma( idx, basepath ) {
46 selectedStemmaID = idx;
47 $('#stemma_graph').empty();
48 $('#stemma_graph').append( stemmata[idx] );
49 // Stexaminer submit action
50 var stexpath = basepath + "/stexaminer/" + selectedTextID + "/" + idx;
51 $('#run_stexaminer').attr( 'action', stexpath );