Skip to content

Instantly share code, notes, and snippets.

@jkishner
Created January 21, 2015 22:26
Show Gist options
  • Save jkishner/ddc226ba4ba04f39c487 to your computer and use it in GitHub Desktop.
Save jkishner/ddc226ba4ba04f39c487 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
function daveRiver(form) {
var xmlhttp = new XMLHttpRequest();
var url = form.item.value;
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myString = xmlhttp.responseText;
myString = myString.substring(18,myString.length-1);
var myArray = JSON.parse(myString);
count = myArray.updatedFeeds.updatedFeed.length;
var output = "";
var tab = "&nbsp;&nbsp;&nbsp;";
for (i=0;i<count;i++) {
output+= "<b>feedTitle:</b> " + myArray.updatedFeeds.updatedFeed[i].feedTitle + "<br>";
output+= "<b>feedUrl:</b> " + "<a href=" + myArray.updatedFeeds.updatedFeed[i].feedUrl + ">" + myArray.updatedFeeds.updatedFeed[i].feedUrl + "</a><br>";
output+= "<b>websiteUrl:</b> " + "<a href=" + myArray.updatedFeeds.updatedFeed[i].websiteUrl + ">" + myArray.updatedFeeds.updatedFeed[i].websiteUrl + "</a><br>";
output+= "<b>feedDescription:</b> " + myArray.updatedFeeds.updatedFeed[i].feedDescription + "<br>";
output+= "<b>whenLastUpdate:</b> " + myArray.updatedFeeds.updatedFeed[i].whenLastUpdate + "<br>";
output+= "<br>";
output+= tab + "<b>title:</b> " + myArray.updatedFeeds.updatedFeed[i].item[0].title + "<br>";
output+= tab + "<b>link:</b> <a href=" + myArray.updatedFeeds.updatedFeed[i].item[0].link + ">" + myArray.updatedFeeds.updatedFeed[i].item[0].link + "</a><br>";
output+= tab + "<b>body:</b> " + myArray.updatedFeeds.updatedFeed[i].item[0].body + "<br>";
output+= tab + "<b>pubDate:</b> " + myArray.updatedFeeds.updatedFeed[i].item[0].pubDate + "<br>";
output+= tab + "<b>permaLink:</b> <a href=" + myArray.updatedFeeds.updatedFeed[i].item[0].permaLink + ">" + myArray.updatedFeeds.updatedFeed[i].item[0].permaLink + "</a><br>";
output+= "<br><hr><br>";
} // end for i
document.getElementById("results").innerHTML=output;
} // end xmlhttp
} // end onreadystatechange
xmlhttp.open("GET", url, true);
xmlhttp.send();
} // end daveriver
</script>
<p>This script parses a JSON file produced by Dave Winer's <a
href="https://github.com/scripting/river4">River4</a>.</p>
<p>Enter one of the following URLs in the form, and then hit submit:</p>
<textarea rows="8" cols="50">http://rss.scripting.com/rivers/iowa.js
http://rss.scripting.com/rivers/nytRiver.js
http://rss.scripting.com/rivers/tech.js
http://rss.scripting.com/rivers/world.js
http://rss.scripting.com/rivers/podcasts.js
http://rss.scripting.com/rivers/nba.js
http://rss.scripting.com/rivers/movies.js
http://rss.scripting.com/rivers/dave.js</textarea>
<p><b>Note:</b> This script only works with JSON files that are allowed by cross-origin sharing.</p>
<form>
json url <input type="text" name="item" size="50"><br>
<input type="button" value="submit" onClick="daveRiver(this.form)">
</form>
<p id="results"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment