JSFiddle - React, Tailwind, and code Playground

by gurkavcu

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/embedly-jquery/3.1.2/jquery.embedly.min.js"></script>
<div class="newscontainer">
    
<script src="http://feeds.feedburner.com/cnn/dHWG?format=sigpro" type="text/javascript" ></script>
    
</div>

CSS

img {
    max-height: 100px;
    width: 50px;
    float:left;
    padding: 5px;
}

.embed {
    padding-bottom: 50px;
}

JavaScript

$('document').ready(function() {

    $('div.newscontainer').embedly({
        key: ':3eccf441bf0f43acbb076da9817af27d',
        success: function(oembed, dict) {

            output = $(oembed['code']);
            description = $(oembed['code']).find(".description").text();           
            var regex =new RegExp(output.find('.provider').text(),"i");
            if(regex.exec(description) == null ) {              
                $(dict["node"]).parent().html(output);
            }
            
            output.find("a:eq(0)").text(); // First
            output.find("a:eq(1)").text(); // Provider


        }
    });




    $('.description').html(

    function() {
        return $.trim($(this).html()).substring(0, 100).split(" ").slice(0, -1).join(" ") + "...";
    });






});