Commit | Line | Data |
98a45925 |
1 | function loadTradition( textid, textname, editable ) { |
2 | selectedTextID = textid; |
3 | // First insert the placeholder image and register an error handler |
538715bd |
4 | var basepath = window.location.pathname |
a86eba5d |
5 | if( basepath.lastIndexOf('/') == basepath.length - 1 ) { |
6 | basepath = basepath.slice( 0, basepath.length - 1) |
7 | }; |
5f0eda3f |
8 | $('#stemma_graph').empty(); |
98a45925 |
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(); |
18 | } |
19 | } |
20 | ); |
62723740 |
21 | // Then get and load the actual content. |
98a45925 |
22 | // TODO: scale #stemma_graph both horizontally and vertically |
f6a8db89 |
23 | // TODO: load svgs from SVG.Jquery (to make scaling react in Safari) |
98a45925 |
24 | $.getJSON( basepath + "/textinfo/" + textid, function (textdata) { |
25 | // Add the scalar data |
26 | $('#textinfo_waitbox').hide(); |
27 | $('#textinfo_container').show(); |
5f0eda3f |
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 ); |
98a45925 |
33 | // Add the stemma(ta) and set up the stexaminer button |
34 | stemmata = textdata.stemmata; |
35 | if( stemmata.length ) { |
36 | selectedStemmaID = 0; |
37 | load_stemma( selectedStemmaID, basepath ); |
38 | } |
39 | // Set up the relationship mapper button |
40 | $('#run_relater').attr( 'action', basepath + "/relation/" + textid ); |
41 | }); |
42 | } |
43 | |
44 | function load_stemma( idx, basepath ) { |
45 | if( idx > -1 ) { |
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 ); |
52 | } |
5ba6c2b4 |
53 | } |