Overview
Comment:build(skin): put JavaScript files in js/ dir
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c134825c49ba709d021a55bd7856a133ae6fc043fda09d94ea44195630eb240a
User & Date: dbohdan on 2020-07-04 16:39:55
Other Links: manifest | tags
Context
2020-07-04
17:10
feat(skin/css/highlight.js): do not change background of highlighted blocks Leaf check-in: 14a2ff79c9 user: dbohdan tags: trunk
16:39
build(skin): put JavaScript files in js/ dir check-in: c134825c49 user: dbohdan tags: trunk
16:37
build(skin): give skin files standard names check-in: 5acfd85546 user: dbohdan tags: trunk
Changes

Modified skin/Makefile from [125dfb0197] to [056e8fd19c].

3
4
5
6
7
8
9
10
11
12
13
css.txt: css/bootstrap.min.css css/bootswatch.css css/highlight.js.css css/tclssg.css Makefile
	cat css/bootstrap.min.css \
	    css/bootswatch.css \
	    css/highlight.js.css \
	    css/tclssg.css \
	    > $@

js.txt: highlight.pack.js toc.js bottom.js Makefile
	sed 's/\$$/<th1>puts \\$$<\/th1>/g' highlight.pack.js > $@
	cat toc.js >> $@
	cat bottom.js >> $@







|
|
|
|
3
4
5
6
7
8
9
10
11
12
13
css.txt: css/bootstrap.min.css css/bootswatch.css css/highlight.js.css css/tclssg.css Makefile
	cat css/bootstrap.min.css \
	    css/bootswatch.css \
	    css/highlight.js.css \
	    css/tclssg.css \
	    > $@

js.txt: js/highlight.pack.js js/toc.js js/bottom.js Makefile
	sed 's/\$$/<th1>puts \\$$<\/th1>/g' js/highlight.pack.js > $@
	cat js/toc.js >> $@
	cat js/bottom.js >> $@

Deleted skin/bottom.js version [87b1d06ebf].

1
2
// ------
hljs.initHighlightingOnLoad();
<
<




Deleted skin/highlight.pack.js version [8bdcf93237].

cannot compute difference between binary files

Added skin/js/bottom.js version [87b1d06ebf].





>
>
1
2
// ------
hljs.initHighlightingOnLoad();

Added skin/js/highlight.pack.js version [8bdcf93237].

cannot compute difference between binary files

Added skin/js/toc.js version [801d6d3ef5].

























































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// toc.js
// Generate a ToC for a Fossil wiki page.  This code should work in old
// browsers.
// Copyright (c) 2020 D. Bohdan.
// License: MIT.

var tocGen = {};

// Returns an array of all h1-h6 headings in the wiki page.
tocGen.headings = function() {
    var md = document.querySelector('.markdown');
    if (!md) {
        return [];
    }

    return Array.prototype.slice.call(
        md.querySelectorAll('h1, h2, h3, h4, h5, h6')
    );
};

// Returns the element after which we append the ToC.
tocGen.tocHeading = function(hs) {
    return hs.filter(function(el) {
        return el.innerText == 'Contents';
    })[0];
};

// Transform a string into a form suitable for a fragment identifier.
tocGen.slugify = function(s) {
    return s.toLowerCase().match(/\w+/g).join('-');
};

// Returns an <li><a href>text</a></li>.
tocGen.createLiA = function(href, text) {
    var li = document.createElement('li');
    var a = document.createElement('a');
    a.href = href;
    a.innerText = text;
    li.appendChild(a);
    
    return li;
};

// Returns an element containing the ToC.  The ToC consists of nested lists.
tocGen.toc = function(hs, tocHeading) {
    var level = 0;
    var stack = [];

    var f = function(h, n) {
        var elLevel = +h.tagName[1];
        var i, ul;

        // Nest the lists.
        for (i = level; i < elLevel; i++) {
            ul = document.createElement('ul');

            if (elLevel > 1) {
                var li = document.createElement('li');
                li.style.listStyle = 'none';
                li.appendChild(ul);
                stack[stack.length - 1].appendChild(li);
            }

            stack.push(ul);
        };
        for (i = level; i > elLevel; i--) {
            ul = stack.pop();
        };
        
        level = elLevel;

        var slug = tocGen.slugify(n + ' ' + h.innerText); 
        var liA = tocGen.createLiA('#' + slug, h.innerText);

        stack[stack.length - 1].appendChild(liA);
    };

    hs.forEach(f);

    return stack[0];
};

// Add a fragment id to every element in hs.
tocGen.addIds = function(hs) {
    hs.forEach(function(el, i) {
        el.id = tocGen.slugify(i + ' ' + el.innerText);
    });
}

// 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() {
    var hs = tocGen.headings();

    var tocHeading = tocGen.tocHeading(hs);
    if (!tocHeading) return;

    var toc = tocGen.toc(hs, tocHeading);
    
    tocGen.addIds(hs);
    tocGen.insertAfter(tocHeading, toc);
};

tocGen.addToc();

Deleted skin/toc.js version [801d6d3ef5].

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// toc.js
// Generate a ToC for a Fossil wiki page.  This code should work in old
// browsers.
// Copyright (c) 2020 D. Bohdan.
// License: MIT.

var tocGen = {};

// Returns an array of all h1-h6 headings in the wiki page.
tocGen.headings = function() {
    var md = document.querySelector('.markdown');
    if (!md) {
        return [];
    }

    return Array.prototype.slice.call(
        md.querySelectorAll('h1, h2, h3, h4, h5, h6')
    );
};

// Returns the element after which we append the ToC.
tocGen.tocHeading = function(hs) {
    return hs.filter(function(el) {
        return el.innerText == 'Contents';
    })[0];
};

// Transform a string into a form suitable for a fragment identifier.
tocGen.slugify = function(s) {
    return s.toLowerCase().match(/\w+/g).join('-');
};

// Returns an <li><a href>text</a></li>.
tocGen.createLiA = function(href, text) {
    var li = document.createElement('li');
    var a = document.createElement('a');
    a.href = href;
    a.innerText = text;
    li.appendChild(a);
    
    return li;
};

// Returns an element containing the ToC.  The ToC consists of nested lists.
tocGen.toc = function(hs, tocHeading) {
    var level = 0;
    var stack = [];

    var f = function(h, n) {
        var elLevel = +h.tagName[1];
        var i, ul;

        // Nest the lists.
        for (i = level; i < elLevel; i++) {
            ul = document.createElement('ul');

            if (elLevel > 1) {
                var li = document.createElement('li');
                li.style.listStyle = 'none';
                li.appendChild(ul);
                stack[stack.length - 1].appendChild(li);
            }

            stack.push(ul);
        };
        for (i = level; i > elLevel; i--) {
            ul = stack.pop();
        };
        
        level = elLevel;

        var slug = tocGen.slugify(n + ' ' + h.innerText); 
        var liA = tocGen.createLiA('#' + slug, h.innerText);

        stack[stack.length - 1].appendChild(liA);
    };

    hs.forEach(f);

    return stack[0];
};

// Add a fragment id to every element in hs.
tocGen.addIds = function(hs) {
    hs.forEach(function(el, i) {
        el.id = tocGen.slugify(i + ' ' + el.innerText);
    });
}

// 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() {
    var hs = tocGen.headings();

    var tocHeading = tocGen.tocHeading(hs);
    if (!tocHeading) return;

    var toc = tocGen.toc(hs, tocHeading);
    
    tocGen.addIds(hs);
    tocGen.insertAfter(tocHeading, toc);
};

tocGen.addToc();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<