tripal_analysis_go.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.length > 0){
  6. var option = document.getElementById("analysis_id_for_go_report");
  7. if (option) {
  8. var options = document.getElementsByTagName('option');
  9. var index = 0;
  10. for (index = 0; index < options.length; index ++) {
  11. if (options[index].value == option.value) {
  12. break;
  13. }
  14. }
  15. selectbox[0].selectedIndex = index;
  16. tripal_analysis_go_org_charts(option.value);
  17. // Otherwise, show the first option by default
  18. } else {
  19. selectbox[0].selectedIndex = 1;
  20. tripal_analysis_go_org_charts(selectbox.val());
  21. }
  22. }
  23. });
  24. function tripal_analysis_go_org_charts(item){
  25. if(!item){
  26. $("#tripal_analysis_go_org_charts").html('');
  27. return false;
  28. }
  29. // Form the link for the following ajax call
  30. var link = baseurl + '/tripal_analysis_go_org_charts/' + item;
  31. tripal_startAjax();
  32. $.ajax({
  33. url: link,
  34. dataType: 'json',
  35. type: 'POST',
  36. success: function(data){
  37. $("#tripal_analysis_go_org_charts").html(data[0]);
  38. tripal_cv_init_chart();
  39. tripal_cv_init_tree();
  40. tripal_stopAjax();
  41. }
  42. });
  43. return false;
  44. }
  45. }