Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2327)

Side by Side Diff: third_party/webgl/resources/generateTOC.js

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 function nextLevel(nodeList, startIndex, hlevel, prefix, tocString)
2 {
3 var hIndex = 1;
4 var i = startIndex;
5
6 while (i < nodeList.length) {
7 var currentNode = nodeList[i];
8
9 if (currentNode.tagName != "H"+hlevel)
10 break;
11
12 if (currentNode.className == "no-toc") {
13 ++i;
14 continue;
15 }
16
17 var sectionString = prefix+hIndex;
18
19 // Update the TOC
20 var text = currentNode.innerHTML;
21 // Strip off names specified via <a name="..."></a>
22 var tocText = text.replace(/<a name=[\'\"][^\'\"]*[\'\"]>([^<]*)<\/a>/g, "$1");
23 tocString.s += "<li class='toc-h"+hlevel+"'><a href='#"+sectionString+"' ><span class='secno'>"+sectionString+"</span>"+tocText+"</a></li>\n";
24
25 // Modify the header
26 currentNode.innerHTML = "<span class=secno>"+sectionString+"</span> "+te xt;
27 currentNode.id = sectionString;
28
29 // traverse children
30 i = nextLevel(nodeList, i+1, hlevel+1, sectionString+".", tocString);
31 hIndex++;
32 }
33
34 return i;
35 }
36
37 function generateTOC(toc)
38 {
39 var nodeList = $("h2,h3,h4,h5,h6");
40 var tocString = { s:"<ul class='toc'>\n" };
41 nextLevel(nodeList, 0, 2, "", tocString);
42 toc.innerHTML = tocString.s;
43
44 // Now position the document, in case a #xxx directive was given
45 var id = window.location.hash.substring(1);
46 if (id.length > 0) {
47 var target = document.getElementById(id);
48 if (target) {
49 var rect = target.getBoundingClientRect();
50 setTimeout(function() { window.scrollTo(0, rect.top) }, 0);
51 }
52 }
53 }
OLDNEW
« no previous file with comments | « third_party/webgl/resources/default.css ('k') | third_party/webgl/resources/jquery-1.3.2.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698