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
//Sending Data to the Server using Fetch() | |
//using jsonplaceholder for the data | |
//GET - queryStrings | |
// http://jsonplaceholder.typicode.com/posts?userId=1&postId=65 | |
// http://jsonplaceholder.typicode.com/todos?userId=2 | |
//POST | |
// http://jsonplaceholder.typicode.com/posts | |
const root = 'http://jsonplaceholder.typicode.com/'; | |
let uri = root + 'posts'; |
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
// Date objects in JavaScript | |
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date | |
// moment.js | |
let log = console.log; | |
let d = new Date(); | |
log(d); | |
let num = 1000 * 60 * 60 * 24 * 365.25 * 40; | |
// approx 40 yrs |
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
// DarkSky API | |
// CORS requests are NOT allowed by the DarkSky server | |
// Requests from other Servers are allowed | |
// So, we would make a pass thru file on a server. | |
// Browser sends the fetch( ) AJAX request to OUR server | |
// OUR server sends the AJAX request to DarkSky server | |
// DarkSky responds to OUR Server | |
// OUR Server sends the DarkSky reply back to Browser | |
// Browser AJAX call => Our Server => DarkSky => Our Server => Browser AJAX call |
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
// Truthy and Falsy in JavaScript | |
// Boolean-ish | |
// null, undefined, 0, false, '', "", NaN - FALSEY | |
// | |
let log = console.log; | |
let es = ""; | |
let z = 0; | |
let n = null; | |
let u = undefined; |
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
//throwing Errors and Exceptions | |
//and | |
//using Try...Catch to handle thrown Errors and Exceptions | |
//Error Types: | |
// EvalError, InternalError, RangeError, ReferenceError, | |
// SyntaxError, TypeError, URIError | |
try{ | |
//throw 'Javelin'; | |
//throw {name:'Bubba', message:'Salmon'}; |
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
//fetch user data from jsonplaceholder | |
//generate a user list on the web page | |
//add a click event to the body that will | |
//refresh the list each time with a random | |
//number of users | |
const uri = 'http://jsonplaceholder.typicode.com/users'; | |
let req = new Request(uri, { | |
method: 'GET', |
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
*{ | |
padding: 0; | |
margin: 0; | |
box-sizing: border-box; | |
} | |
html{ | |
font-size: 16px; | |
line-height: 1.5; | |
font-family: sans-serif; | |
} |
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
// load the sample weather JSON data | |
// build a grid of temps over the next 24 hours | |
// blue background in hours where percipitation possibility is higher than 70% | |
let uri = './darksky-sample.json'; | |
let req = new Request(uri, {method:'GET'}); | |
let container, df; | |
document.addEventListener('DOMContentLoaded', init); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Tha Internetz</title> | |
<meta name="viewport" content="width=device-width"> | |
<style> | |
*{ | |
padding: 0; | |
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
{"latitude":45.3483, | |
"longitude":-75.7584, | |
"timezone":"America/Toronto", | |
"offset":-4, | |
"hourly":{ | |
"summary":"Rain starting overnight, continuing until morning.", | |
"icon":"rain", | |
"data":[ | |
{"time":1499918400,"summary":"Drizzle","icon":"rain","precipIntensity":0.1956,"precipProbability":0.56,"precipType":"rain","temperature":15.04,"apparentTemperature":15.04,"dewPoint":12.19,"humidity":0.83,"windSpeed":12.36,"windBearing":51,"visibility":15.95,"cloudCover":0.16,"pressure":1016.64,"uvIndex":0}, | |
{"time":1499922000,"summary":"Clear","icon":"clear-night","precipIntensity":0.0838,"precipProbability":0.02,"precipType":"rain","temperature":14.95,"apparentTemperature":14.95,"dewPoint":11.62,"humidity":0.8,"windSpeed":13.97,"windBearing":47,"visibility":15.66,"cloudCover":0.16,"pressure":1016.56,"uvIndex":0},{"time":1499925600,"summary":"Overcast","icon":"cloudy","precipIntensity":0.0965,"precipProbability":0.05,"precipType":"rain","temperature":14.33,"apparentTemperature":14.33,"dewPoi |