This sample demonstrates getting the three most recent LIGO group articles from feeds.
Below is a HTML fragment that you could include in a web page to include recent articles titles for the group called LIGO using the JSON version of the article feed.
<div id="recent-3-articles">
Recent 3 Articles go here if JavaScript worked!</div>
<script src="https://feeds.library.caltech.edu/scripts/CL.js"></script>
<script>
let recent_3_articles = document.getElementById("recent-3-articles");
.getGroupJSON("LIGO", "recent/article", function(articles, err) {
CLif (err != "") {
console.log("ERROR", err);
return;
}let max_count = 3;
let i = 0;
.forEach(function (article) {
articles++;
iif (i > max_count) {
return;
}var elem = document.createElement("div"),
= document.createElement("h1"),
h1 = document.createElement("anchor"),
anchor = document.createElement("div");
div
/* Add CSS classes for styling */
.classList.add("article");
elem.classList.add("article-title");
h1.classList.add("article-abstract");
div/* Add content to create a composit element */
.setAttribute("href", article.official_url);
anchor.innerHTML = article.title;
anchor.appendChild(anchor);
h1.innerHTML = article.abstract;
div.appendChild(h1);
elem.appendChild(div);
elem/* Finally add our composit element to the list */
.appendChild(elem)
recent_3_articles;
});
})</script>
That example is rendered below–
Recent 3 Articles go here if JavaScript Worked.