This repo houses example files for the JavaScript for Journalists course at UC Berkeley Graduate School of Journalism. These files each correspond to a different lesson during the class.
Remember, the tutorials for the class can be found on the Knight Digital Media Center Website
To use this Instagram API example, you must signup for an Instagram account using your iOS or Android device first. Then register an application on Instagram's Developer site.
Find the endpoint URL you wish to use, which should contain your access_key
as a parameter. (make sure it works in a browser) Set your endpoint to the endpoint
variable in the Instagram file. You can edit the processData
function however you wish, but it's currently set to display a new photo every time it's clicked.
NOTE: Twitter is deprecating their version 1 API soon. Their newer 1.1 api requires authentication for every call, which means you can't do it purely over JavaScript.
This sample script calls Tweets from a specific location using Twitter's search API. Edit the processData
function as needed. Currently, it is designed to go through and display tweets, profile images and screen names. There is also a handy linkify_tweet
method that is attached to String objects, which will link @username words, #hashtags and standard links.
A sample quiz template. Edit the JSON at the top of the document. Change the choices and question. The correct answer needs to match exactly with the correct choice (string matches).
{
"question" : "Q1: Who came up with theory of relativity?",
"choices" : [
"Sir Isaac Newton",
"Nicolaus Copernicus",
"Albert Einstein",
"Ralph Waldo Emmerson"
],
"correct" : "Albert Einstein",
"explanation" : "Albert Einstein drafted the special theory of relativity in 1905."
}
This example demonstrates how to use TableTop.js for retrieving information from Google Spreadsheet in JSON format. In this example, we built a simple bar chart. In order to use this, you need to first create a Google Spreadsheet with two columns, one of them numeric.
Example:
Name | Numerical value |
John Doe | 114325 |
Jane Doe | 894325 |
Peter Smith | 634325 |
Sarah Resig | 133525 |
Then, click File -> Publish To Web. Copy the URL and add it to your TableTop script in the public_spreadsheet_url
variable.
Timeline Example (DEMO)
Still forthcoming.