tripal_analysis_go.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // Copyright 2009 Clemson University
  3. //
  4. if (Drupal.jsEnabled) {
  5. function tripal_analysis_go_org_charts(item){
  6. if(!item){
  7. $("#tripal_analysis_go_org_charts").html('');
  8. return false;
  9. }
  10. // Get the base url. Drupal can not pass it through the form so we need
  11. // to get it ourself. Use different patterns to match the url in case
  12. // the Clean URL function is turned on
  13. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
  14. if(!baseurl) {
  15. var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
  16. }
  17. if (!baseurl) {
  18. // This base_url is obtained when Clena URL function is off
  19. var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
  20. }
  21. if (!baseurl) {
  22. // The last possibility is we've assigned an alias path, get base_url till the last /
  23. var baseurl = location.href.substring(0,location.href.lastIndexOf('/'));
  24. }
  25. // Form the link for the following ajax call
  26. var link = baseurl + '/tripal_analysis_go_org_charts/' + item;
  27. tripal_startAjax();
  28. $.ajax({
  29. url: link,
  30. dataType: 'json',
  31. type: 'POST',
  32. success: function(data){
  33. $("#tripal_analysis_go_org_charts").html(data[0]);
  34. tripal_cv_init_chart();
  35. tripal_cv_init_tree();
  36. tripal_stopAjax();
  37. }
  38. });
  39. return false;
  40. }
  41. }