<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="footer">
<body>

<footer class="footer bg-white">

    <div class="footer-social">
        <div class="footer-container clearfix">
            <div class="social-list">
                <th:block th:each="index:${commons.social()}">
                    <th:block th:if="${index.value}!=null and ${index.value}!=''">
                        <th:block th:switch="${index.key}">

                            <th:block th:case="'weibo'">
                                <a class="social weibo" target="blank"
                                   th:href="@{${index.value}}">微博</a>
                            </th:block>

                            <th:block th:case="'zhihu'">
                                <a class="social zhihu" target="blank"
                                   th:href="@{${index.value}}">知乎</a>
                            </th:block>

                            <th:block th:case="'github'">
                                <a class="social github" target="blank"
                                   th:href="@{${index.value}}">Github</a>
                            </th:block>

                            <th:block th:case="'twitter'">
                                <a class="social twitter" target="blank"
                                   th:href="@{${index.value}}">Twitter</a>
                            </th:block>
                        </th:block>
                    </th:block>
                </th:block>
            </div>
        </div>
    </div>
    <div class="footer-meta">
        <div class="footer-container">
            <div class="meta-item meta-copyright">
                <div class="meta-copyright-info">
                    <div class="info-text">
                        <a href="http://www.owlfeng.cn" style="display: block;margin: 0 auto;" class="info-logo">
                            <img style="display: block;margin: 0 auto;" th:src="@{/user/img/logo.png}"
                                 th:alt="${commons.site_title()}"/>
                        </a>
                        <div>
                            <br/>
                            <p><a href="#header"> 在线人数<span class="counter"
                                                            th:text="${application.online_number}">0</span>人</a> <a
                                    href="/rss">订阅网站rss</a></p>
                            <p>&copy; 版权所有 <a href="https://github.com/owlfeng1021/owlBlog" target="_blank"
                                              rel="nofollow">owlBlog</a>
                            </p>
                            <th:block th:if="${option}!=null and ${option.getValue()}!=''">
                                <p th:text="${option.getValue()}"></p>
                            </th:block>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</footer>

<th:block th:if="${is_post}">
    <div id="directory-content" class="directory-content">
        <div id="directory"></div>
    </div>
    <script>
        /*<![CDATA[*/
        var postDirectoryBuild = function () {
            var postChildren = function children(childNodes, reg) {
                    var result = [],
                        isReg = typeof reg === 'object',
                        isStr = typeof reg === 'string',
                        node, i, len;
                    for (i = 0, len = childNodes.length; i < len; i++) {
                        node = childNodes[i];
                        if ((node.nodeType === 1 || node.nodeType === 9) &&
                            (!reg ||
                                isReg && reg.test(node.tagName.toLowerCase()) ||
                                isStr && node.tagName.toLowerCase() === reg)) {
                            result.push(node);
                        }
                    }
                    return result;
                },
                createPostDirectory = function (article, directory, isDirNum) {
                    var contentArr = [],
                        titleId = [],
                        levelArr, root, level,
                        currentList, list, li, link, i, len;
                    levelArr = (function (article, contentArr, titleId) {
                        var titleElem = postChildren(article.childNodes, /^h\d$/),
                            levelArr = [],
                            lastNum = 1,
                            lastRevNum = 1,
                            count = 0,
                            guid = 1,
                            id = 'directory' + (Math.random() + '').replace(/\D/, ''),
                            lastRevNum, num, elem;
                        while (titleElem.length) {
                            elem = titleElem.shift();
                            contentArr.push(elem.innerHTML);
                            num = +elem.tagName.match(/\d/)[0];
                            if (num > lastNum) {
                                levelArr.push(1);
                                lastRevNum += 1;
                            } else if (num === lastRevNum ||
                                num > lastRevNum && num <= lastNum) {
                                levelArr.push(0);
                                lastRevNum = lastRevNum;
                            } else if (num < lastRevNum) {
                                levelArr.push(num - lastRevNum);
                                lastRevNum = num;
                            }
                            count += levelArr[levelArr.length - 1];
                            lastNum = num;
                            elem.id = elem.id || (id + guid++);
                            titleId.push(elem.id);
                        }
                        if (count !== 0 && levelArr[0] === 1) levelArr[0] = 0;

                        return levelArr;
                    })(article, contentArr, titleId);
                    currentList = root = document.createElement('ul');
                    dirNum = [0];
                    for (i = 0, len = levelArr.length; i < len; i++) {
                        level = levelArr[i];
                        if (level === 1) {
                            list = document.createElement('ul');
                            if (!currentList.lastElementChild) {
                                currentList.appendChild(document.createElement('li'));
                            }
                            currentList.lastElementChild.appendChild(list);
                            currentList = list;
                            dirNum.push(0);
                        } else if (level < 0) {
                            level *= 2;
                            while (level++) {
                                if (level % 2) dirNum.pop();
                                currentList = currentList.parentNode;
                            }
                        }
                        dirNum[dirNum.length - 1]++;
                        li = document.createElement('li');
                        link = document.createElement('a');
                        link.href = '#' + titleId[i];
                        link.innerHTML = !isDirNum ? contentArr[i] :
                            dirNum.join('.') + ' ' + contentArr[i];
                        li.appendChild(link);
                        currentList.appendChild(li);
                    }
                    directory.appendChild(root);
                };
            createPostDirectory(document.getElementById('post-content'), document.getElementById('directory'), true);
        };
        postDirectoryBuild();
        /*]]>*/
    </script>
</th:block>

<script th:src="@{//cdn.bootcss.com/headroom/0.9.1/headroom.min.js}"></script>
<script th:src="@{//cdn.bootcss.com/highlight.js/9.9.0/highlight.min.js}"></script>
<script th:src="@{//cdn.bootcss.com/instantclick/3.0.1/instantclick.min.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var isOk = [[${is_post}]];
    if (isOk) {
        var postDirectory = new Headroom(document.getElementById("directory-content"), {
            tolerance: 0,
            offset: 100,
            classes: {
                initial: "initial",
                pinned: "pinned",
                unpinned: "unpinned"
            }
        });
    }


    var header = new Headroom(document.getElementById("header"), {
        tolerance: 10,
        offset: 80,
        classes: {
            initial: "animated",
            pinned: "slideDown",
            unpinned: "slideUp"
        }
    });
    header.init();
    $('#search-inp').keypress(function (e) {
        var key = e.which; //e.which是按键的值
        if (key == 13) {
            var q = $(this).val();
            if (q && q != '') {
                window.location.href = '/search/' + q;
            }
        }
    });
    /*]]>*/
</script>
<script data-no-instant="">
    /*<![CDATA[*/
    InstantClick.on('change', function (isInitialLoad) {
        var blocks = document.querySelectorAll('pre code');
        for (var i = 0; i < blocks.length; i++) {
            hljs.highlightBlock(blocks[i]);
        }
        if (isInitialLoad === false) {
            if (typeof ga !== 'undefined') ga('send', 'pageview', location.pathname + location.search);
        }
    });
    InstantClick.init('mousedown');
    /*]]>*/
</script>
</body>
</html>