tripal_analysis_go.js 1.7 KB

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