Browse Source

fixed the loading problem for GO/Kegg on organism page where base_url is not '/'

ccheng 15 năm trước cách đây
mục cha
commit
309927249d

+ 18 - 2
theme_tripal/js/tripal_analysis_go.js

@@ -8,8 +8,24 @@ if (Drupal.jsEnabled) {
          $("#tripal_analysis_go_org_charts").html('');
          return false;
       }
-       
-      link = '/tripal_analysis_go_org_charts/' + item;
+      // Get the base url. Drupal can not pass it through the form so we need 
+	   // to get it ourself. Use different patterns to match the url in case
+      // the Clean URL function is turned on
+      var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
+      if(!baseurl) {
+   	   var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
+      }
+      if (!baseurl) {
+         // This base_url is obtained when Clena URL function is off
+         var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
+      }
+      if (!baseurl) {
+         // The last possibility is we've assigned an alias path, get base_url till the last /
+         var baseurl = location.href.substring(0,location.href.lastIndexOf('/'));
+      }
+      
+      // Form the link for the following ajax call       
+      var link = baseurl + '/tripal_analysis_go_org_charts/' + item;
       tripal_startAjax();
       $.ajax({
            url: link,

+ 18 - 2
theme_tripal/js/tripal_analysis_kegg.js

@@ -15,8 +15,24 @@ if (Drupal.jsEnabled) {
          $("#tripal_analysis_kegg_org_report").html('');
          return false;
       }
-       
-      link = '/tripal_analysis_kegg_org_report/' + item;
+      // Get the base url. Drupal can not pass it through the form so we need 
+	  // to get it ourself. Use different patterns to match the url in case
+      // the Clean URL function is turned on
+      var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
+      if(!baseurl) {
+  	     var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
+      }
+      if (!baseurl) {
+         // This base_url is obtained when Clena URL function is off
+         var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
+      }
+      if (!baseurl) {
+         // The last possibility is we've assigned an alias path, get base_url till the last /
+         var baseurl = location.href.substring(0,location.href.lastIndexOf('/'));
+      }
+     
+      // Form the link for the following ajax call  
+      var link = baseurl + '/tripal_analysis_kegg_org_report/' + item;
       tripal_startAjax();
       $.ajax({
            url: link,