summaryrefslogtreecommitdiff
path: root/_includes/extensions
diff options
context:
space:
mode:
Diffstat (limited to '_includes/extensions')
-rw-r--r--_includes/extensions/comments/disqus.html18
-rw-r--r--_includes/extensions/comments/gitment.html15
-rw-r--r--_includes/extensions/geopattern.html21
-rw-r--r--_includes/extensions/google-analytics.html12
-rw-r--r--_includes/extensions/google-translate.html98
-rw-r--r--_includes/extensions/hashlocate.html39
-rw-r--r--_includes/extensions/mathjax.html10
-rw-r--r--_includes/extensions/trianglify.html23
8 files changed, 236 insertions, 0 deletions
diff --git a/_includes/extensions/comments/disqus.html b/_includes/extensions/comments/disqus.html
new file mode 100644
index 0000000..c4f98fa
--- /dev/null
+++ b/_includes/extensions/comments/disqus.html
@@ -0,0 +1,18 @@
+ <div id="disqus_thread"></div>
+ <script>
+ var disqus_config = function () {
+ this.page.url = '{{ page.url | absolute_url }}';
+ this.page.identifier = '{{ page.url | absolute_url }}';
+ };
+
+ (function() {
+ var d = document, s = d.createElement('script');
+
+ // s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
+ s.src = 'https://jeffreytse.disqus.com/embed.js';
+
+ s.setAttribute('data-timestamp', +new Date());
+ (d.head || d.body).appendChild(s);
+ })();
+ </script>
+ <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
diff --git a/_includes/extensions/comments/gitment.html b/_includes/extensions/comments/gitment.html
new file mode 100644
index 0000000..56ad7ee
--- /dev/null
+++ b/_includes/extensions/comments/gitment.html
@@ -0,0 +1,15 @@
+ <div id="gitment_thread"></div>
+ <link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">
+ <script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
+ <script>
+ var gitment = new Gitment({
+ id: '{{ page.id }}',
+ owner: '{{ site.gitment.username }}',
+ repo: '{{ site.gitment.repo }}',
+ oauth: {
+ client_id: '{{ site.gitment.client_id }}',
+ client_secret: '{{ site.gitment.client_secret }}',
+ },
+ });
+ gitment.render('gitment_thread')
+ </script>
diff --git a/_includes/extensions/geopattern.html b/_includes/extensions/geopattern.html
new file mode 100644
index 0000000..3931533
--- /dev/null
+++ b/_includes/extensions/geopattern.html
@@ -0,0 +1,21 @@
+{% if include.selector %}
+ {% assign selector = include.selector %}
+{% endif %}
+
+{% if include.seed %}
+ {% assign seed = include.seed %}
+{% endif %}
+
+<script src="https://cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
+<script>
+ function setRandomBgImage(selector, seed) {
+ var pattern = GeoPattern.generate(seed);
+ var element = document.querySelector(selector)
+ if (element) {
+ element.style.backgroundImage = pattern.toDataUrl();
+ }
+ }
+
+ setRandomBgImage('{{ selector }}', '{{ seed }}');
+</script>
+
diff --git a/_includes/extensions/google-analytics.html b/_includes/extensions/google-analytics.html
new file mode 100644
index 0000000..e9afb20
--- /dev/null
+++ b/_includes/extensions/google-analytics.html
@@ -0,0 +1,12 @@
+<script>
+if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) {
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+
+ ga('create', '{{ site.google_analytics }}', 'auto');
+ ga('send', 'pageview');
+}
+</script>
+
diff --git a/_includes/extensions/google-translate.html b/_includes/extensions/google-translate.html
new file mode 100644
index 0000000..53d0996
--- /dev/null
+++ b/_includes/extensions/google-translate.html
@@ -0,0 +1,98 @@
+{% if include.translate_langs %}
+ {% assign translate_langs = include.translate_langs %}
+{% endif %}
+
+<div id="google_translate_element" style="display: none;">
+</div>
+
+<span class="ct-language">
+ <ul class="list-unstyled ct-language-dropdown">
+ {% for item in translate_langs %}
+ <li>
+ <a href="#" class="lang-select" data-lang="{{ item.lang }}">
+ {% if item.img %}
+ <img src="{{ item.img }}" title="{{ item.text }}">
+ {% else %}
+ {{ item.text }}
+ {% endif %}
+ </a>
+ </li>
+ {% endfor %}
+ </ul>
+</span>
+
+<script type="text/javascript">
+function googleTranslateElementInit() {
+ new google.translate.TranslateElement({
+ pageLanguage: '',
+ autoDisplay: false,
+ layout: google.translate.TranslateElement.InlineLayout.VERTICAL
+ }, 'google_translate_element');
+
+ function restoreLang() {
+ var iframe = document.getElementsByClassName('goog-te-banner-frame')[0];
+ if (!iframe) return;
+
+ var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
+ var restore_el = innerDoc.getElementsByTagName("button");
+
+ for (var i = 0; i < restore_el.length; i++) {
+ if (restore_el[i].id.indexOf("restore") >= 0) {
+ restore_el[i].click();
+ var close_el = innerDoc.getElementsByClassName("goog-close-link");
+ close_el[0].click();
+ return;
+ }
+ }
+ }
+
+ function triggerHtmlEvent(element, eventName) {
+ var event;
+ if (document.createEvent) {
+ event = document.createEvent('HTMLEvents');
+ event.initEvent(eventName, true, true);
+ element.dispatchEvent(event);
+ } else {
+ event = document.createEventObject();
+ event.eventType = eventName;
+ element.fireEvent('on' + event.eventType, event);
+ }
+ }
+
+ var googleCombo = document.querySelector("select.goog-te-combo");
+ var langSelect = document.querySelector('.ct-language');
+ langSelect.addEventListener('click', function(event) {
+ if (!event.target) {
+ return;
+ }
+
+ var selected = document.querySelector('.ct-language .ct-language-selected');
+ if (selected) {
+ selected.classList.remove('ct-language-selected');
+ }
+
+ var target = event.target;
+ while (target && target !== langSelect ) {
+ if (target.matches('.lang-select')) {
+ break;
+ }
+ target = target.parentElement;
+ }
+
+ if (target && target.matches('.lang-select')) {
+ var lang = target.getAttribute('data-lang');
+ if (googleCombo.value == lang) {
+ restoreLang();
+ } else {
+ target.parentElement.classList.add('ct-language-selected');
+ googleCombo.value = lang;
+ triggerHtmlEvent(googleCombo, 'change');
+ }
+ }
+
+ event.preventDefault();
+ });
+}
+</script>
+
+<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
diff --git a/_includes/extensions/hashlocate.html b/_includes/extensions/hashlocate.html
new file mode 100644
index 0000000..d44b249
--- /dev/null
+++ b/_includes/extensions/hashlocate.html
@@ -0,0 +1,39 @@
+<script>
+ function hashLocate(hashValue) {
+ hashValue = hashValue.replace(/^.*#h-/, '');
+ var element = document.getElementById(hashValue);
+
+ if (!element) {
+ return;
+ }
+
+ var headerHeight = 0;
+ var header = document.querySelector('header');
+ if (header) {
+ headerHeight = header.offsetHeight;
+ }
+ var supportPageOffset = window.pageXOffset !== undefined;
+ var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
+
+ var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
+ var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
+
+ var offsetY = element.offsetTop - headerHeight - 12;
+ if (y === offsetY) {
+ return;
+ }
+
+ window.scrollTo(x, offsetY);
+ }
+
+ // The first event occurred
+ if (window.location.hash) {
+ hashLocate(window.location.hash);
+ }
+
+ window.addEventListener('click', function(event) {
+ if (event.target.matches('a')) {
+ hashLocate(event.target.getAttribute('href'));
+ }
+ });
+</script>
diff --git a/_includes/extensions/mathjax.html b/_includes/extensions/mathjax.html
new file mode 100644
index 0000000..b06023b
--- /dev/null
+++ b/_includes/extensions/mathjax.html
@@ -0,0 +1,10 @@
+<script type="text/x-mathjax-config">
+ MathJax.Hub.Config({
+tex2jax: {
+skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
+inlineMath: [['$','$']]
+}
+});
+</script>
+<script
+ src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML" type="text/javascript"></script>
diff --git a/_includes/extensions/trianglify.html b/_includes/extensions/trianglify.html
new file mode 100644
index 0000000..22003dc
--- /dev/null
+++ b/_includes/extensions/trianglify.html
@@ -0,0 +1,23 @@
+{% if include.selector %}
+ {% assign selector = include.selector %}
+{% endif %}
+
+{% if include.seed %}
+ {% assign seed = include.seed %}
+{% endif %}
+
+<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/2.0.0/trianglify.min.js"></script>
+<script>
+ function setRandomBgImage(selector, seed) {
+ var element = document.querySelector(selector);
+ if (!element) return;
+ var pattern = Trianglify({
+ width: screen.width,
+ height: element.offsetHeight,
+ seed: seed
+ });
+ element.appendChild(pattern.canvas());
+ }
+
+ setRandomBgImage('{{ selector }}', '{{ seed }}');
+</script>