playground add disqus

This commit is contained in:
Van 2015-03-01 22:03:56 +08:00
parent 92bee6437b
commit fda56c4fb7
2 changed files with 20 additions and 4 deletions

View File

@ -332,6 +332,21 @@ var playground = {
} }
}); });
}, },
disqus: function () {
var url = window.location.href;
if (url.indexOf("?") >= 0) {
if (url.indexOf("disqus=") >= 0) {
url = url.replace("disqus=false", "disqus=true");
console.log(url);
} else {
url += "&disqus=true";
}
} else {
url += "?disqus=true";
}
window.location.href = url;
},
stop: function () { stop: function () {
if (!playground.editor) { if (!playground.editor) {
return; return;

View File

@ -15,7 +15,7 @@
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/themes/default.css?{{.conf.StaticResourceVersion}}"> <link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/themes/default.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/sign.css?{{.conf.StaticResourceVersion}}"> <link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/sign.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}"> <link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/side.css?{{.conf.StaticResourceVersion}}">
{{if .embed}}<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/playground-embed.css?{{.conf.StaticResourceVersion}}">{{else}}<link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/playground.css?{{.conf.StaticResourceVersion}}">{{end}} <link rel="stylesheet" href="{{.conf.StaticServer}}/static/css/playground{{if .embed}}-embed{{end}}.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-{{.codeMirrorVer}}/codemirror.css?{{.conf.StaticResourceVersion}}"> <link rel="stylesheet" href="{{.conf.StaticServer}}/static/js/lib/codemirror-{{.codeMirrorVer}}/codemirror.css?{{.conf.StaticResourceVersion}}">
<link rel="stylesheet" href="{{$.conf.StaticServer}}/static/js/overwrite/codemirror/theme/wide.css?{{.conf.StaticResourceVersion}}"> <link rel="stylesheet" href="{{$.conf.StaticServer}}/static/js/overwrite/codemirror/theme/wide.css?{{.conf.StaticResourceVersion}}">
@ -40,6 +40,9 @@
<li> <li>
<button class="btn btn-red" id="stop" onclick="playground.stop();">{{.i18n.stop}}</button> <button class="btn btn-red" id="stop" onclick="playground.stop();">{{.i18n.stop}}</button>
</li> </li>
<li>
<button class="btn-white btn" id="disqus" onclick="playground.disqus();">Disqus</button>
</li>
<li> <li>
<button class="btn-white btn" id="share" onclick="playground.share();">{{.i18n.share}}</button> <button class="btn-white btn" id="share" onclick="playground.share();">{{.i18n.share}}</button>
</li> </li>
@ -75,9 +78,7 @@
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})(); })(); </script>
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{{end}} {{end}}
<div class="footer"> <div class="footer">