Skip to content

Commit 4d2b610

Browse files
committed
opti: utils to js file
1 parent d163367 commit 4d2b610

24 files changed

+180
-127
lines changed

.eslintrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"env": {
33
"browser": true,
4-
"jquery": true
5-
4+
"jquery": true,
5+
"node": true
66
},
77
"rules": {
8-
"no-console": "off",
8+
"no-console": "error",
99
"semi": ["error", "always"],
1010
"quotes": ["error", "single"],
1111
"comma-dangle": ["error", "never"],
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{%- if site.disqus.shortname and page.key -%}
2+
<div id="disqus_thread"></div>
3+
<script>
4+
/**
5+
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
6+
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
7+
var disqus_config = function () {
8+
this.page.url = '{%- include snippets/page-url.html -%}';
9+
this.page.identifier = '{{ page.key }}';
10+
};
11+
(function() { // DON'T EDIT BELOW THIS LINE
12+
var d = document, s = d.createElement('script');
13+
s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
14+
s.setAttribute('data-timestamp', +new Date());
15+
(d.head || d.body).appendChild(s);
16+
})();
17+
</script>
18+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
19+
{%- endif -%}

_includes/scripts/components/chart.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* global Chart */
2+
(function () {
3+
var SOURCES = window.TEXT_VARIABLES.sources;
4+
var PAGE = window.TEXT_VARIABLES.page;
5+
if (PAGE.chart) {
6+
window.Lazyload.js([SOURCES.jquery, SOURCES.chart], function() {
7+
var $canvas = null, $this = null, _ctx = null, _text = '';
8+
$('.language-chart').each(function(){
9+
$this = $(this);
10+
$canvas = $('<canvas></canvas>');
11+
_text = $this.text();
12+
$this.text('').append($canvas);
13+
_ctx = $canvas.get(0).getContext('2d');
14+
(_ctx && _text) && (new Chart(_ctx, JSON.parse(_text)) && $this.attr('data-processed', true));
15+
});
16+
});
17+
}
18+
})();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* global ga */
2+
(function() {
3+
var ENVIRONMENT = window.TEXT_VARIABLES.jekyll.environment;
4+
var GA_TRACKING_ID = window.TEXT_VARIABLES.site.ga_tracking_id;
5+
if(GA_TRACKING_ID && ENVIRONMENT !== 'development') {
6+
/* eslint-disable */
7+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
8+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
9+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
10+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
11+
/* eslint-enable */
12+
ga('create', GA_TRACKING_ID, 'auto');
13+
ga('send', 'pageview');
14+
}
15+
})();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(function () {
2+
var SOURCES = window.TEXT_VARIABLES.sources;
3+
var PAGE = window.TEXT_VARIABLES.page;
4+
if (PAGE.mathjax) {
5+
var _config = { tex2jax: {
6+
inlineMath: [['$','$'], ['\\(','\\)']]
7+
}};
8+
if (PAGE.mathjax_autoNumber == true) {
9+
_config.TeX = { equationNumbers: { autoNumber: 'all' } };
10+
}
11+
window.MathJax = _config;
12+
window.Lazyload.js(SOURCES.mathjax);
13+
}
14+
})();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* global mermaid */
2+
(function () {
3+
var SOURCES = window.TEXT_VARIABLES.sources;
4+
var PAGE = window.TEXT_VARIABLES.page;
5+
if (PAGE.mermaid) {
6+
window.Lazyload.js(SOURCES.mermaid, function() {
7+
mermaid.init(undefined, '.language-mermaid');
8+
mermaid.initialize({ startOnLoad: true });
9+
});
10+
}
11+
})();

_includes/scripts/lib/toc.js renamed to _includes/scripts/components/toc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
})
6464
);
6565
$window.on('resize', window.throttle(function() {
66-
console.log('toc', disabled);
6766
if (!disabled) {
6867
rendered || render();
6968
calc();

0 commit comments

Comments
 (0)