Line 14: | Line 14: | ||
['protein', 'a biological thing'], | ['protein', 'a biological thing'], | ||
['xanthios','????'], | ['xanthios','????'], | ||
− | ['pheophorbide','a compound occuring in | + | ['pheophorbide','a compound occuring in chlorophylls degradation pathway'], |
['agronomist','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], | ['agronomist','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], | ||
['agronomists','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], | ['agronomists','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], |
Revision as of 00:09, 20 October 2019
// ----[ PUT ALL WORD DEFINITIONS IN ARRAY BELOW] ----
/* By keeping all of the definitions in one place, we can use them across multiple pages instead of redefining words (inconsistently) every time they appear */
var definitions = [ ['lorem ipsum', 'a commonly employed block of mock-text that is used to critque the typography of a webpage'], ['platea', 'a word that Prabhu thinks is cool'], ['duo', 'a pair of two'], ['id', 'the part of the mind in which innate instinctive impulses and primary processes are manifest as theorized by Sigmund Freud'], ['sit', 'a physical command commonly given to dogs'], ['sed', 'a Spanish word meaning \"thirst\"'],
['protein', 'a biological thing'], ['xanthios','????'], ['pheophorbide','a compound occuring in chlorophylls degradation pathway'], ['agronomist','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], ['agronomists','a scientist who develops methods that will improve the use of soil and increase the production of food and fiber crops.'], ['photosensitizer','a molecule that produces a chemical change in another molecule in a photochemical process.'], ['mycelial','the vegetative part of a fungus or fungus-like bacterial colony'], ['minimum inhibitory concentration', ' lowest concentration of an antibacterial agent necessary to inhibit visible growth'],
];
function identifyDefinition(word) { for(var defIndex = 0; defIndex < definitions.length; ++defIndex) { if(definitions[defIndex][0].toLowerCase() == word.toLowerCase()) { return definitions[defIndex][1]; } } }
function setDefinitions() {
terms = document.getElementsByTagName("DFN");
for(var termIndex = 0; termIndex < terms.length; ++termIndex) {
var term = terms[termIndex]; var lemma = term.getAttribute("data-lemma"); var word = (lemma != null) ? lemma : term.textContent;
// "data-toggle" enables the tooltip var toggle = document.createAttribute("data-toggle"); toggle.value = "tooltip"; term.setAttributeNode(toggle);
// "title" refers to the contents of the tooltip (i.e. the word definition) var title = document.createAttribute("title"); var definition = identifyDefinition(word) title.value = "Definition: " + ((definition == null) ? "???" : definition); term.setAttributeNode(title);
// "placement" is set to auto which means the tooltip will appear wherever room is left (top | bottom | right | left) var placement = document.createAttribute("data-placement"); placement.value = "auto"; term.setAttributeNode(placement);
// "offset" changes the displacement of the tooltip (makes it deviate from centre) var offset = document.createAttribute("data-offset"); offset.value = "75%"; term.setAttributeNode(offset);
// "html" enables the "title" attribute to use html tags (in this case, the tag was used) var html = document.createAttribute("data-html"); html.value = "true"; term.setAttributeNode(html);
}
// This line enables Bootstrap's tooltips (they are disabled by default) $('[data-toggle="tooltip"]').tooltip(); }