/*------------------------------------------- Glossary-JS version 3.1 Michigan State University Virtual University Design and Technology Creator: Nathan Lounds Project Page: http://code.google.com/p/glossary-js/ Dependencies: jquery.js (http://jquery.com) auto-highlighting requires jquery.highlight.js (http://bartaz.github.com/sandbox.js/jquery.highlight.html) glossary.css Copyright (c) 2010 Michigan State University Board of Trustees License: http://www.opensource.org/licenses/mit-license.php --------------------------------------------*/ GlossaryJS_css = window.GlossaryJS_css || "glossary.css"; GlossaryJS_txt = window.GlossaryJS_txt || "glossary.txt"; GlossaryJS_section = window.GlossaryJS_section || ""; GlossaryJS_autohighlight = window.GlossaryJS_autohighlight || false; var GlossaryJS = { glossary: new Array(), initialize : function() { // $(".glossary").each(function(i){ var cur = this; cur.className = "highlightSpan"; }); $(".highlightSpan") .live("mouseover", function() { GlossaryJS.word = this; clearTimeout(GlossaryJS.timer); GlossaryJS.getDefinition(); $(".glossary_height").equalHeights(); $(".glossary_width").equalWidths(); }) .live("mouseout", function() { var the_div = document.getElementById("glossaryTooltip"); if(the_div) { GlossaryJS.timer = setTimeout("$('#glossaryTooltip').remove()",1000); } }) .live("click", function() { var me = this; me.blur(); $("#glossaryTooltip").attr("title","click to close"); GlossaryJS.word = me; GlossaryJS.getDefinition(); $(".glossary_height").equalHeights(); $(".glossary_width").equalWidths(); }); GlossaryJS.loadGlossary(); }, loadGlossary: function() { $.ajax({ type: "GET", url: GlossaryJS_txt, data: "", success: function(str){ // Create the array of glossary terms var the_words = str.split("\n"), counter = 0, inarray, the_word_arr for (i = 0; i < the_words.length; i++) { inarray = false; the_word_arr = the_words[i].split("|"); if(the_word_arr.length<3 || (the_word_arr.length==3&&GlossaryJS_section==the_word_arr[1])) { if(the_word_arr) { if(the_word_arr[0].length>1) { for(k = 0; k < GlossaryJS.glossary.length; k++) { if(the_word_arr[0]===GlossaryJS.glossary[k].word) { inarray = true; k = GlossaryJS.glossary.length; } } if(inarray===false) { GlossaryJS.glossary[counter] = {}; GlossaryJS.glossary[counter].word = the_word_arr[0]; if(GlossaryJS_autohighlight===true) { $(document.body).highlight(GlossaryJS.glossary[counter].word, { wordsOnly: true, className: 'highlightSpan' }); } GlossaryJS.glossary[counter].def = ""; GlossaryJS.glossary[counter].section = ""; if(the_word_arr.length==3) { GlossaryJS.glossary[counter].section = the_word_arr[1]; GlossaryJS.glossary[counter].def = the_word_arr[2]; } else if (the_word_arr.length==2) { GlossaryJS.glossary[counter].def = the_word_arr[1]; } counter++; } } } } } // Make the glossary unordered list (if there's a div for it) var str_output = ""; var GlossaryUL = document.getElementById("GlossaryJS"); if(GlossaryUL) { for (i=0; i <= GlossaryJS.glossary.length; i++) { if(GlossaryJS.glossary[i]) { str_output += "