It has been 1485 days since the last update, the content of the article may be outdated.

这里发现了一个叫Elegent的主题,现在不知道还有没有,那时候这里面的特色,使用折叠效果来展示文章分类。
貌似是因为jQuery依赖出了问题,这个动效不生效,所以一顿修改。那时候连jQuery,Bootstrap,HTML都不懂,就凭借着常年debug的技能去修改。

Issue

This happens with the file elegant/templates/base.html, which rules the element of every pages
at around line 97 , there is a quote:

html
<script src="http://code.jquery.com/jquery.min.js"></script>  

it seems the http request is nolonger credited in this case, and a potential consequence is that:
The following collapse funtion in elegant/templates/category.html reports an error "$" undefined,
the collapse effect in Categories page does not work.

html
<script  language="javascript" type="text/javascript">
function uncollapse() {
$(window.location.hash).collapse({
toggle: true
})
}
</script>

Solution

just modify the file elegant/templates/base.html


Method 1. Remove ‘http:’

remove prefix in the js/html template files. “http://“ -> “//“
i.e. change

html
<script src="http://code.jquery.com/jquery.min.js"></script>  

to

html
<script src="//code.jquery.com/jquery.min.js"></script>  
```
this is highly recommended on Github, see elegant issues [#167](https://github.com/talha131/pelican-elegant/issues/166) and [#153](https://github.com/talha131/pelican-elegant/pull/153)
this is quite simple, but I didnot adopt this solution, sence haven't noticed these pages.

---
#### Method 2. JS function `document.write`

This is what I've actually adopted,

```html
<!-- 协议过旧,不信任,注释
<script src="http://code.jquery.com/jquery.min.js"></script>
-->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript">
var prot = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + prot + "code.jquery.com/jquery.min.js' type='text/javascript' %3E%3C/script%3E"));
</script>

this bring in a warning massage (press F12 in your browser,see console):
warning massage

warning massage

but this works well, I stopt debugging.

This solution comes from a smilar github issue #127 of netflow, see pditommaso’s comment on 6 Apr 2016.