glossary.js 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(document).ready(function() {
  2. $(window).load(function () {
  3. var my_text=$(".glossary-content").html();
  4. my_protocol = location.protocol;
  5. my_pathname=location.pathname;
  6. work_path = my_pathname.substr(0,my_pathname.indexOf('/courses/'));
  7. $.ajax({
  8. contentType: "application/x-www-form-urlencoded",
  9. beforeSend: function(content_object) {
  10. },
  11. type: "POST",
  12. url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
  13. data: "glossary_data=true",
  14. success: function(datas) {
  15. if (datas.length==0) {
  16. return false;
  17. }
  18. data_terms=datas.split("[|.|_|.|-|.|]");
  19. var complex_array = new Array();
  20. var cp_complex_array = new Array();
  21. for(i=0;i<data_terms.length;i++) {
  22. specific_terms=data_terms[i].split("__|__|");
  23. var real_term = specific_terms[1];
  24. var real_code = specific_terms[0];
  25. complex_array[real_code] = real_term;
  26. cp_complex_array[real_code] = real_term;
  27. }
  28. complex_array.reverse();
  29. for (var my_index in complex_array) {
  30. n = complex_array[my_index];
  31. if (n == null) {
  32. n = '';
  33. } else {
  34. for (var cp_my_index in cp_complex_array) {
  35. cp_data = cp_complex_array[cp_my_index];
  36. if (cp_data == null) {
  37. cp_data = '';
  38. } else {
  39. if (cp_data == n) {
  40. my_index = cp_my_index;
  41. }
  42. }
  43. }
  44. $('#highlight-plugin').removeHighlight().highlight(n,my_index)
  45. }
  46. }
  47. var complex_array = new Array();
  48. $("#highlight-plugin .glossary-ajax").mouseover(function(){
  49. random_id = Math.round(Math.random()*100);
  50. div_show_id="div_show_id"+random_id;
  51. div_content_id="div_content_id"+random_id;
  52. $(this).append("<div id="+div_show_id+" ><div id="+div_content_id+">&nbsp;</div></div>");
  53. $("div#"+div_show_id).attr("style","z-index:99;display:inline;float:left;position:absolute;background-color:#F2F2F2;border-bottom: 1px solid #2E2E2E;border-right: 1px solid #2E2E2E;border-left: 1px solid #2E2E2E;border-top: 1px solid #2E2E2E;color:#305582;margin-left:5px;margin-right:5px;");
  54. $("div#"+div_content_id).attr("style","z-index:99;background-color:#F2F2F2;color:#0B3861;margin-left:8px;margin-right:8px;margin-top:5px;margin-bottom:5px;");
  55. notebook_id = $(this).attr("name");
  56. data_notebook = notebook_id.split("link");
  57. my_glossary_id = data_notebook[1];
  58. $.ajax({
  59. contentType: "application/x-www-form-urlencoded",
  60. beforeSend: function(content_object) {
  61. $("div#"+div_content_id).html("<img src='../../../../main/inc/lib/javascript/indicator.gif' />");
  62. },
  63. type: "POST",
  64. url: "../../../../main/glossary/glossary_ajax_request.php",
  65. data: "glossary_id="+my_glossary_id,
  66. success: function(datas) {
  67. $("div#"+div_content_id).html(datas);
  68. }
  69. });
  70. });
  71. $("#highlight-plugin .glossary-ajax").mouseout(function(){
  72. var current_element = $(this);
  73. div_show_id=current_element.find("div").attr("id");
  74. $("div#"+div_show_id).remove();
  75. });
  76. //helpers
  77. }
  78. });
  79. });
  80. });