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 | }; |
04469f3e |
8 | $('#textinfo_load_status').empty(); |
5f0eda3f |
9 | $('#stemma_graph').empty(); |
98a45925 |
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); |
04469f3e |
18 | $("#textinfo_load_status").append( msghtml ).show(); |
98a45925 |
19 | } |
20 | } |
21 | ); |
62723740 |
22 | // Then get and load the actual content. |
98a45925 |
23 | // TODO: scale #stemma_graph both horizontally and vertically |
f6a8db89 |
24 | // TODO: load svgs from SVG.Jquery (to make scaling react in Safari) |
98a45925 |
25 | $.getJSON( basepath + "/textinfo/" + textid, function (textdata) { |
26 | // Add the scalar data |
27 | $('#textinfo_waitbox').hide(); |
28 | $('#textinfo_container').show(); |
5f0eda3f |
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 ); |
98a45925 |
34 | // Add the stemma(ta) and set up the stexaminer button |
35 | stemmata = textdata.stemmata; |
36 | if( stemmata.length ) { |
37 | selectedStemmaID = 0; |
38 | load_stemma( selectedStemmaID, basepath ); |
39 | } |
40 | // Set up the relationship mapper button |
41 | $('#run_relater').attr( 'action', basepath + "/relation/" + textid ); |
42 | }); |
43 | } |
44 | |
45 | function load_stemma( idx, basepath ) { |
46 | if( idx > -1 ) { |
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 ); |
53 | } |
5ba6c2b4 |
54 | } |