Skip to Content
Web Design in a Nutshell, 3rd Edition
book

Web Design in a Nutshell, 3rd Edition

by Jennifer Robbins
February 2006
Intermediate to advanced
826 pages
63h 42m
English
O'Reilly Media, Inc.
Content preview from Web Design in a Nutshell, 3rd Edition

Example 2: Page Glossary

This script is pageGlossary from Easy Designs (url="easy-designs.net/code/pageGlossary/"/>). It traverses a specified portion of the document (identified by an id), collecting all of the abbreviation, acronym, and definition elements, and writes them out to the designated portion of the page (also identified by an id) as a formal page glossary. The script also removes duplicate entries and sorts the contents alphabetically. Here it is:

var pageGlossary = { getFrom: false, // where to collect terms from buildIn: false, // where to place the glossary glossArr: [], // the working glossary as an array usedArr: [], // terms we've used ( to track duplicates ) init: function( fromId, toId ){ /* init( ) takes two arguments: * id of the collection area * id of the destination */ // make sure the required methods and elements are available if( !document.getElementById || !document.getElementsByTagName || !document.getElementById( fromId ) || !document.getElementById( toId ) ) return; // set the collection area pageGlossary.getFrom = document.getElementById( fromId ); // set the destination area pageGlossary.buildIn = document.getElementById( toId ); // run the collection method (below) pageGlossary.collect( ); // if the glossary array has no members, quit now if( pageGlossary.usedArr.length < 1 ) return; // resort the array in alphabetical order using ksort (below) pageGlossary.glossArr = pageGlossary.ksort( pageGlossary.glossArr ); // run the build method (below) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Responsive Web Design with HTML5 and CSS3

Beginning Responsive Web Design with HTML5 and CSS3

Jonathan Fielding

Publisher Resources

ISBN: 0596009879Errata Page