disqus_scripts.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {% macro disqus_misc_scripts() %}
  2. <script type="text/javascript">
  3. var disqus_shortname = '{{ DISQUS_SITENAME }}';
  4. (function () {
  5. var s = document.createElement('script'); s.async = true;
  6. s.type = 'text/javascript';
  7. s.src = '//' + disqus_shortname + '.disqus.com/count.js';
  8. (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
  9. }());
  10. </script>
  11. <script language="javascript" type="text/javascript">
  12. function uncollapse() {
  13. if (window.location.hash.match(/^#comment-\d+$/)) {
  14. $('#disqus_thread').collapse('show');
  15. }
  16. }
  17. </script>
  18. <script type="text/javascript" language="JavaScript">
  19. uncollapse();
  20. window.onhashchange=function(){
  21. if (window.location.hash.match(/^#comment-\d+$/))
  22. window.location.reload(true);
  23. }
  24. </script>
  25. <script>
  26. $('#disqus_thread').on('shown', function () {
  27. var link = document.getElementsByClassName('accordion-toggle');
  28. var old_innerHTML = link[0].innerHTML;
  29. $(link[0]).fadeOut(500, function() {
  30. $(this).text('Click here to hide comments').fadeIn(500);
  31. });
  32. $('#disqus_thread').on('hidden', function () {
  33. $(link[0]).fadeOut(500, function() {
  34. $(this).text(old_innerHTML).fadeIn(500);
  35. });
  36. })
  37. })
  38. </script>
  39. {% endmacro %}
  40. {% macro disqus_comments_script(article) %}
  41. <div id="disqus_thread"></div>
  42. <script type="text/javascript">
  43. var disqus_shortname = '{{ DISQUS_SITENAME }}';
  44. {% if article.disqus_identifier %}
  45. var disqus_identifier = '{{ article.disqus_identifier }}';
  46. {% else %}
  47. var disqus_identifier = '{{ SITEURL }}/{{ article.url }}';
  48. {% endif %}
  49. var disqus_url = '{{ SITEURL }}/{{ article.url }}';
  50. (function() {
  51. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  52. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  53. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  54. })();
  55. </script>
  56. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  57. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  58. {% endmacro %}