Overview
Comment:style(skin/js/toc.js): rename parameter "skipRootInSlug" "skipH1sInSlug"
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0d626b82419ddee59019808b1557b42247390c648c257e484b723a9831ac584e
User & Date: dbohdan on 2020-08-24 10:32:30
Other Links: manifest | tags
Context
2020-08-24
11:08
refactor(music/music.sql): add constraint NOT NULL to all columns check-in: 8b14826415 user: dbohdan tags: trunk
10:32
style(skin/js/toc.js): rename parameter "skipRootInSlug" "skipH1sInSlug" check-in: 0d626b8241 user: dbohdan tags: trunk
09:06
feat(skin/js/toc.js): add option to not include top-level heading in slug text check-in: 96285315e2 user: dbohdan tags: trunk
Changes

Modified skin/js/toc.js from [f315bd9963] to [e5feac40c6].

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    li.appendChild(a);
    
    return li;
};

// Set unique fragement ids on headings and return an element containing the
// ToC.  The ToC consists of nested <ul>s.
tocGen.createToC = function(headings, skipRootInSlug) {
    var prevLevel = 0;
    var stack = [null, null, null, null, null, null];

    var f = function(heading) {
        var level = +heading.tagName[1];
        var i, ul;

................................................................................
                stack[i - 1].list.appendChild(li);
            }

            stack[i] = {'list': ul, 'text': ''};
        }
        stack[level - 1].text = heading.innerText;
       
        var slug = stack.slice(1 * skipRootInSlug, level).map(function(x) {
            return tocGen.slugify(x.text);
        }).join('--');
        heading.id = slug;        
        var liA = tocGen.createLiA('#' + slug, heading.innerText);

        stack[level - 1].list.appendChild(liA);

................................................................................

// Insert el into the document after ref.
tocGen.insertAfter = function(ref, el) {
    ref.parentNode.insertBefore(el, ref.nextSibling);
}

// Add a ToC to the current wiki page.
tocGen.addToC = function(skipRootInSlug) {
    var headings = tocGen.headings();

    var contentsHeading = tocGen.contentsHeading(headings);
    if (!contentsHeading) return;

    var toc = tocGen.createToC(headings, skipRootInSlug);
    tocGen.insertAfter(contentsHeading, toc);
};







|







 







|







 







|





|


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    li.appendChild(a);
    
    return li;
};

// Set unique fragement ids on headings and return an element containing the
// ToC.  The ToC consists of nested <ul>s.
tocGen.createToC = function(headings, skipH1sInSlug) {
    var prevLevel = 0;
    var stack = [null, null, null, null, null, null];

    var f = function(heading) {
        var level = +heading.tagName[1];
        var i, ul;

................................................................................
                stack[i - 1].list.appendChild(li);
            }

            stack[i] = {'list': ul, 'text': ''};
        }
        stack[level - 1].text = heading.innerText;
       
        var slug = stack.slice(1 * skipH1sInSlug, level).map(function(x) {
            return tocGen.slugify(x.text);
        }).join('--');
        heading.id = slug;        
        var liA = tocGen.createLiA('#' + slug, heading.innerText);

        stack[level - 1].list.appendChild(liA);

................................................................................

// Insert el into the document after ref.
tocGen.insertAfter = function(ref, el) {
    ref.parentNode.insertBefore(el, ref.nextSibling);
}

// Add a ToC to the current wiki page.
tocGen.addToC = function(skipH1sInSlug) {
    var headings = tocGen.headings();

    var contentsHeading = tocGen.contentsHeading(headings);
    if (!contentsHeading) return;

    var toc = tocGen.createToC(headings, skipH1sInSlug);
    tocGen.insertAfter(contentsHeading, toc);
};