A Pen by George White on CodePen.
Created
September 11, 2020 19:18
-
-
Save galexite/0bf6eb75d12ed0c5fa7bb22c0de884af to your computer and use it in GitHub Desktop.
MWyGKNy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <div class="row my-5"> | |
| <div class="col-md-6 mx-auto"> | |
| <div class="list-group" id="events"> | |
| <div class="list-group-item list-group-item-info">Podcast Society events</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stackoverflow.com/a/7394787/1738462 | |
| function decodeHtml(html) { | |
| var txt = document.createElement("textarea"); | |
| txt.innerHTML = html; | |
| return txt.value; | |
| } | |
| $.ajax("https://cors-anywhere.herokuapp.com/https://www.exeterguild.org/ents/rss/43904/", { | |
| success: function (data, _status, _xhr) { | |
| var $el = $("#events"), | |
| $items = $(data).find("item"); | |
| $items.each(function (_i) { | |
| var title = decodeHtml($(this).find("title").text()), | |
| description = decodeHtml($(this).find("description").text()), | |
| link = $(this).find("link").text(), | |
| flatTitle = $("<div>" + title + "</div>").text(), | |
| flatDescription = $("<div>" + description + "</div>").text(), | |
| splitTitle = flatTitle.match(/(.*) \(([0-9/]*), ([0-9:]*)\)$/), | |
| actualTitle = splitTitle[1], | |
| date = splitTitle[2], | |
| time = splitTitle[3], | |
| $a = $("<a></a>"), | |
| $h4 = $("<h4></h4>"), | |
| $h6 = $("<h6></h6>"), | |
| $p = $("<p></p>"); | |
| $h4.text(actualTitle); | |
| $a.append($h4); | |
| $h6.text(date + ", " + time); | |
| $a.append($h6); | |
| $p.text(flatDescription); | |
| $a.append($p); | |
| $a.addClass("list-group-item list-group-item-action"); | |
| $a.attr("href", link); | |
| $el.append($a); | |
| }); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| div#events .list-group-item p { | |
| margin: 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment