Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions test/manual-test-examples/async/loadJSON_callback/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ function getWeather() {

var cityName = userInput.value();
var URL =
'http://api.openweathermap.org/data/2.5/weather?q=' +
cityName +
'&units=metric';
'https://wttr.in/' + encodeURIComponent(cityName) + '?format=j1';

result = loadJSON(URL, displayWeather); // displayWeather is the callback
}

Expand All @@ -47,9 +46,9 @@ function displayWeather() {
print(result); // result is ready!

var location = result.name;
var currentTemp = result.main.temp;
var avgTemp = result.weather[0].avgtempC;
text(
'Current temperature in ' + location + ' is ' + currentTemp + ' celsius',
'Today\'s average temperature in ' + location + ' is ' + avgTemp + ' celsius',
width / 2,
height / 2
);
Expand Down
2 changes: 1 addition & 1 deletion test/manual-test-examples/async/loadJSON_options/sketch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function setup() {
noCanvas();
loadJSON(
'http://api.openweathermap.org/data/2.5/station?id=5091',
'https://wttr.in/Berlin?format=j1',
parseStuff,
'json'
);
Expand Down
10 changes: 5 additions & 5 deletions test/manual-test-examples/async/loadJSON_preload/sketch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// In this example, we want to load JSON (a JavaScript Object)
// from a URL at openweathermap.org, and display it in setup().
// from a URL at wttr.in, and display it in setup().
//
// Since setup() happens faster than you can load a website, the
// data does not have time to properly load before setup() is done.
Expand All @@ -13,7 +13,7 @@ var result;

function preload() {
result = loadJSON(
'http://api.openweathermap.org/data/2.5/weather?id=5128581&units=imperial'
'https://wttr.in/Berlin?format=j1'
);
console.log('In preload(), the result has not finished loading: ');
console.log(result);
Expand All @@ -29,10 +29,10 @@ function setup() {
console.log('In setup(), here is the result: ');
console.log(result);

var location = result.name;
var currentTemp = result.main.temp;
var location = result.nearest_area[0].areaName[0].value;
var avgTemp = result.weather[0].avgtempC;
text(
'Current temperature in ' + location + ' is ' + currentTemp + 'F',
'Today\'s average temperature in ' + location + ' is ' + avgTemp + ' celsius',
width / 2,
height / 2
);
Expand Down
6 changes: 3 additions & 3 deletions test/manual-test-examples/dom/radio_test/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ function setup() {
radio.id('test');
//radio = createSelect(); // for comparison

// just mucking around
// The first is the value; the second is the optional label
radio.option('apple', '1');
radio.option('orange', '2');
radio.option('pear');

// Set what it starts as
radio.selected('2');
radio.selected('orange');

radio.changed(mySelectEvent);
}
Expand All @@ -24,7 +24,7 @@ function draw() {
}

function mySelectEvent() {
var selected = this.selected();
var selected = this.selected().value;
console.log(this.value());
if (selected === 'pear') {
console.log("it's a pear!");
Expand Down
1 change: 1 addition & 0 deletions test/manual-test-examples/keyboard/keyIsPressed.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
</head>

<body>
<p>Press the arrow keys, colors should change.</p>
</body>
</html>
Loading