Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peterjclaw/build-contents
Javascript functions to automatically build the a contents box for an HTML page from its headings
https://github.com/peterjclaw/build-contents
Last synced: about 1 month ago
JSON representation
Javascript functions to automatically build the a contents box for an HTML page from its headings
- Host: GitHub
- URL: https://github.com/peterjclaw/build-contents
- Owner: PeterJCLaw
- Created: 2010-09-19T15:13:29.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2011-07-28T17:41:23.000Z (over 13 years ago)
- Last Synced: 2024-04-16T07:01:49.373Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
This project aims to create a simple javascript file that can be included
in any html page to create a contents box from the headings of the page.- build-contents.js: This is the file to include on your web page
- dummy.html: a dummy html file that demostrates how it worksIn order to use the functionality simply have the page call the
`buildContents' function at some point after the page as loaded. The
dummy file calls it in the body onload attribute. This function takes a
single optional parameter, which is a dictionary of options.Options: (type, default)
id: (string, 'contents-box')
The id of the block to append the list to. If there is no such
block then it is created, and appended to the bottom of the
document body.links: (boolean, true)
Whether or not each of the items in the contents list should link to
the heading that it references. This is done using the id of the
target heading. If no such id exists then no link is created.forceLinks: (boolean, true)
Whether or not to create ids for headins that don't have them such
that they can be linked to. Such ids are created before any attempt
to link to the heading, and are formed using the text in the heading
and a prefix.ordered: (boolean, false)
Whether or not the contents list should be an ordered list (),
as opposed to an unordered list ().