在每个旋转木马图像上添加diss评论

Add Disqus comment on each carousel Image

本文关键字:添加 diss 评论 图像 旋转木马      更新时间:2023-09-26

我正在使用carousel从我的服务器上循环使用图像。

我想为每个carousel图像添加一个diss线程用于注释

我的代码添加图像到我的Carousel并显示它如下:

$('#imgModal').on('show.bs.modal', function(event) {
var indicators = $(this).find('.carousel-indicators');
var items = $(this).find('.carousel-inner');
var targPath = $(event.relatedTarget).attr('src').split('/');
var imgsPath = targPath.splice(0, targPath.length - 3).join('/') + '/';
var target = {
    date: targPath[0],
    category: targPath[1],
    name: targPath[2]
};
 // Lister les répertoires (dates)
$.ajax({
    url: imgsPath,
    success: function(data) {
        var dates = [];
        var date;
        $(data).find('a').each(function() {
            date = $(this).attr('href').replace(/'/$/, '');
            if (date.match(/[0-9]{6}$/)) dates.push(date);
            dates.sort();
        });
        var i = 0;
        var path;
        dates.forEach(function(date) {
            // Vérifer que le fichier existe
            path = imgsPath + date + '/' + target['category'] + '/' + target['name'];
            $.ajax({
                url: path,
                async: false,
                success: function() {
                    // L'ajouter au carousel
                    item = $(
                        '<div class="item">'+
                            '<img src="'+path+'" alt="'+target['name']+'">'+
                            '<div class="carousel-caption">'+
                                '<h3>'+date+'</h3>'+
                                '<p>'+target['name']+'</p>'+
                            '</div>'+
                        '</div>'
                    ).appendTo(items);
                    indicator = $('<li data-target="#carousel-example-generic" data-slide-to="'+i+'"></li>').appendTo(indicators);
                    // Afficher l'image cliquée
                    if (date == target['date']) {
                        item.addClass('active');
                        indicator.addClass('active');
                    }
                    i++;
                }
            });
        });
    }
});
});

和我想集成我的disqus脚本为我的每个图像在旋转木马:

disqus script:

    <div id="disqus_thread"></div>
<script type="text/javascript">
        var disqus_shortname = 'nedox149';
      (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>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>

我已经解决了我的问题,我使用这个例子为我的解决方案:https://github.com/disqus/DISQUS-API-Recipes/blob/master/snippets/js/disqus-reset/disqus_reset.html