-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconcept.html
57 lines (47 loc) · 1.81 KB
/
concept.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<title>jQuery Table of Contents Generator</title>
<meta charset="UTF-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="jquery.tableofcontents.js"></script>
<style>
body {
font-family: Consolas,serif;
font-size: 18px;
}
p {
margin: 14px;
}
h1, h2, h3 {
margin-top: 80px;
}
#container {
width: 800px;
margin: 0 auto;
}
</style>
</head>
<body id="container">
<div id="toc"></div>
<h1>jQuery Table of Contents Generator</h1>
<p>Add a table of contents <input type="button" onclick="$('#toc').tableofcontents()" value="to this page"/>.</p>
<p>I want to work on a jQuery plugin, since I've not done one of those before, and it seems like something that might come up in a job interview, or for a freelance client. I've also always wanted to be able to add a table of contents to a document I've written in HTML.</p>
<h2>What It Should Do</h2>
<p>I want the script to be able to look through a set of nodes/HTML header tags, take it's title, and add it to a contents div which it creates where the user asks.</p>
<p>Each subheading should be listed too, indented each time.</p>
<p>The listing should all be links to the appropriate part of the page, so it will need to add anchor names to each of the H# tags too.</p>
<h3>How It Should Do It</h3>
<p>The first job will be to make a tree of objects, like this:</p>
<pre>
header = {
string name;
header children[];
}
</pre>
<p>To get this, we'll have to recursively iterate over each element of the page...</p>
<h2>Future expansions</h2>
<p>In the future I want to make a Wordpress addon which automatically does this for posts which have a certain shorttag in.</p>
<p>I'd also like to make a bookmarklet, so you can make a table of contents on whatever page you like.</p>
</body>
</html>