get relationship mapper to work even without morphology extension
[scpubgit/stemmaweb.git] / root / js / relationship-full.js
index cd3d867..b5a9f14 100644 (file)
@@ -5,36 +5,12 @@ var start_element_height = 0;
 var reltypes = {};
 var readingdata = {};
 
-function getTextPath() {
-    var currpath = window.location.pathname;
-    // Get rid of trailing slash
-    if( currpath.lastIndexOf('/') == currpath.length - 1 ) { 
-       currpath = currpath.slice( 0, currpath.length - 1) 
-    };
-    // Get rid of query parameters
-    if( currpath.lastIndexOf('?') != -1 ) {
-       currpath = currpath.slice( 0, currpath.lastIndexOf('?') );
-    };
-    var path_elements = currpath.split('/');
-    var textid = path_elements.pop();
-    var basepath = path_elements.join( '/' );
-    var path_parts = [ basepath, textid ];
-    return path_parts;
-}
-
-function getRelativePath() {
-       var path_parts = getTextPath();
-       return path_parts[0];
-}
-
 function getTextURL( which ) {
-       var path_parts = getTextPath();
-       return path_parts[0] + '/' + path_parts[1] + '/' + which;
+       return basepath + textid + '/' + which;
 }
 
 function getReadingURL( reading_id ) {
-       var path_parts = getTextPath();
-       return path_parts[0] + '/' + path_parts[1] + '/reading/' + reading_id;
+       return basepath + textid + '/reading/' + reading_id;
 }
 
 // Make an XML ID into a valid selector
@@ -220,9 +196,8 @@ function svgEnlargementLoaded() {
 }
 
 function add_relations( callback_fn ) {
-       var basepath = getRelativePath();
        var textrelpath = getTextURL( 'relationships' );
-    $.getJSON( basepath + '/definitions', function(data) {
+    $.getJSON( basepath + 'definitions', function(data) {
         var rel_types = data.types.sort();
         $.getJSON( textrelpath,
         function(data) {
@@ -677,8 +652,7 @@ $(document).ready(function () {
     create: function(event, ui) { 
         $(this).data( 'relation_drawn', false );
         //TODO? Err handling?
-               var basepath = getRelativePath();
-        var jqjson = $.getJSON( basepath + '/definitions', function(data) {
+        var jqjson = $.getJSON( basepath + 'definitions', function(data) {
             var types = data.types.sort();
             $.each( types, function(index, value) {   
                  $('#rel_type').append( $('<option />').attr( "value", value ).text(value) );