1
0
mirror of https://github.com/mbirth/wiki.git synced 2024-12-25 23:04:06 +00:00

Add spot.im. Improved comment's javascript loading.

This commit is contained in:
Markus Birth 2015-12-02 11:49:28 +01:00
parent 26ab5aa439
commit 7efc8e549c
2 changed files with 25 additions and 10 deletions

View File

@ -2,6 +2,7 @@
<li class="static"><strong>Comments:</strong></li> <li class="static"><strong>Comments:</strong></li>
<li data-service="disqus" data-div="comments_disqus">Disqus</li> <li data-service="disqus" data-div="comments_disqus">Disqus</li>
<li data-service="google" data-div="comments_google">Google+</li> <li data-service="google" data-div="comments_google">Google+</li>
<li data-service="spotim" data-div="comments_spotim">spot.im</li>
<li class="hint static">(Click to enable.)</li> <li class="hint static">(Click to enable.)</li>
</ul> </ul>
@ -19,3 +20,13 @@
<div id="comments_google" class="comments-tab"> <div id="comments_google" class="comments-tab">
<div class="g-comments" data-href="{{ site.url }}{{ page.url }}" data-width="868" data-first_party_property="BLOGGER" data-view_type="FILTERED_POSTMOD">Loading Google+ comments…</div> <div class="g-comments" data-href="{{ site.url }}{{ page.url }}" data-width="868" data-first_party_property="BLOGGER" data-view_type="FILTERED_POSTMOD">Loading Google+ comments…</div>
</div> </div>
<div id="comments_spotim" class="comments-tab">
<div id="spot-im-frame-inpage" data-post-id="{% if page.id %}{{ page.id }}{% else %}/index{% endif %}"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
window.SPOTIM = {
spotId: 'sp_cNwZLN9Q'
};
</script>
</div>

View File

@ -2,26 +2,30 @@
--- ---
$(document).ready -> $(document).ready ->
$('ul#comments-tabs li').not('.static').click -> $('ul#comments-tabs li').not('.static').click ->
addScript = (script) ->
scr = document.createElement 'script'
scr.type = 'text/javascript'
scr.async = true
scr.src = script
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild scr
tab_id = $(this).attr 'data-div' tab_id = $(this).attr 'data-div'
service = $(this).attr 'data-service' service = $(this).attr 'data-service'
switch service switch service
when 'disqus' when 'disqus'
# load Disqus # load Disqus
dsq = document.createElement 'script' addScript("//#{disqus_shortname}.disqus.com/embed.js")
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
$(this).removeAttr 'data-service' $(this).removeAttr 'data-service'
when 'google' when 'google'
# load Google+ # load Google+
gog = document.createElement 'script' addScript('//apis.google.com/js/plusone.js')
gog.type = 'text/javascript' $(this).removeAttr 'data-service'
gog.async = true
gog.src = '//apis.google.com/js/plusone.js' when 'spotim'
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild gog # load spot.im
addScript('//www.spot.im/launcher/bundle.js')
$(this).removeAttr 'data-service' $(this).removeAttr 'data-service'
$('ul#comments-tabs li.hint').remove() $('ul#comments-tabs li.hint').remove()