1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

edit ditto.js

This commit is contained in:
ruanyf 2014-04-25 23:35:27 +08:00
parent db71d9829c
commit 5d0454a7cd

View File

@ -16,6 +16,17 @@ var ditto = {
run: initialize run: initialize
}; };
var disqusCode = '<div id="disqus_thread"></div>'
+ '<script type="text/javascript">'
+ "var disqus_shortname = 'es6'; "
+ "(function() {"
+ "var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;"
+ "dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';"
+ "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);"
+ " })();"
+ '</script>';
function initialize() { function initialize() {
// initialize sidebar and buttons // initialize sidebar and buttons
if (ditto.sidebar) { if (ditto.sidebar) {
@ -185,7 +196,7 @@ function router() {
var loading = show_loading(); var loading = show_loading();
$.get(path , function(data) { $.get(path , function(data) {
$(ditto.error_id).hide(); $(ditto.error_id).hide();
$(ditto.content_id).html(marked(data)); $(ditto.content_id).html(marked(data)+disqusCode);
if ($(ditto.content_id+" h1").text() === ditto.document_title){ if ($(ditto.content_id+" h1").text() === ditto.document_title){
document.title = ditto.document_title; document.title = ditto.document_title;
} else { } else {