WDX-180
Web Development X
Week 25 | Advanced JavaScript: Web APIs
Week 25 - Day 1 | Web Storage APIs
Schedule
- Watch the lectures
- Study the suggested material
- Practice on the topics and share your questions
Study Plan
Your instructor will share the video lectures with you. Here are the topics covered:
- Part 1: Web Storage APIs
- Part 2: Web Storage APIs
You can find the lecture code here and all other assets here.
Lecture Notes:
- The
localStorage
is a read-only property* of the window interface- Treat it as read-only.
- It’s part of the
window.localStorage
localStorage
data has no expiration time (unlike cookies)sessionStorage
: data gets cleared when the page session ends — that is, when the page is closed- CRUD Methods for
localStorage
andsessionStorage
: Create/Read/Update/DeletesetItem()
(C)getItem()
(R)setItem()
(U)remoteItem()
(D)
- “key(): “The order of keys is user-agent defined, so you should not rely on it.”
- Web Storage APIs work on per-origin and per-browser context.
Questions:
- Is it safe to store sensitive/private information in the browser’s storage?
- You have to be very careful about the things that you store.
- Avoid saving sensitive/private information.
- Try encrypting things before you save them.
- Will there be an error message when the storage limit is reached?
- Yes, we’ll get an error.name
QuotaExceededError
- Yes, we’ll get an error.name
References & Resources:
- Recommended Study: Using the Web Storage API (MDN)
- Make sure not to miss out on the Responding to storage changes with the StorageEvent section of the documentation.
-
https://developer.mozilla.org/en-US/docs/Web/API/Storage/key
-
Window: the
localStorage
property - Web Storage (interface)
Exercises
Become a discoverer: Experiment and find out how localStorage works with different origins
and when accessed from different browsers:
- Configure LiveServer to use a different default port (5500 => 5501) and see what happens with the localStorage. Also try both ports on a different browser. To find the setting, search for liveServer.settings.port
in VSCode Settings, Extensions.
Coding challenge #1: Use localStorage
to keep track of a web page’s horizontal position so that when the user reloads or opens up the page again, they should be looking at the last section. For this one you’ll have to dig out some other APIs (related to browser scrolling, current cursor height)
Coding challenge #2: Try localStorage with React. You might want to try useEffect
for running localStorage.
// Read:
useEffect(()=> { localStorage.getItem() }, []);
// Read/Write/Update/Remove:
onClick={()=> localStorage.getItem/setItem/removeItem }
IMPORTANT: Make sure to complete all the tasks found in the daily Progress Sheet and update the sheet accordingly. Once you’ve updated the sheet, don’t forget to commit
and push
. The progress draft sheet for this day is: /user/week25/progress/progress.draft.w25.d01.csv
You should NEVER update the draft
sheets directly, but rather work on a copy of them according to the instructions found here.
Week 25 - Day 2 | The Scrum Framework
Schedule
- Study the suggested material
Study Plan
According to the Atlassian website:
“Scrum is an agile project management framework that helps teams structure and manage their work through a set of values, principles, and practices. Much like a rugby team (where it gets its name) training for the big game, scrum encourages teams to learn through experiences, self-organize while working on a problem, and reflect on their wins and losses to continuously improve.”
In this module, we are going to explore one of the most common and popular project management frameworks. You will watch a series of YouTube videos to familiarize yourself with the Scrum framework and the following related concepts, since chances are that one of the companies or teams you are going to work with will employ this framework:
- Sprints
- Sprint Planning
- Sprint Reviews
- Ceremonies
- Backlog
- Stand-ups
- Scrum Roles
Suggested material for study and practice:
- 1. Scrum Framework in a Nutshell (6min)
- 2. Product Backlog Refinement in a Nutshell (5min)
- 3. Sprint Planning in a Nutshell (4min)
- 4. Daily Scrum in a Nutshell (3min)
- 5. Sprint Review in a Nutshell (2min)
- 6. Sprint Retrospective in a Nutshell (2min)
-
7. Scrum In A Nutshell (5min)
-
Read the Manifesto for Agile Software Development as “Scrum is a subset of Agile. It is a lightweight process framework for agile development, and the most widely-used one.” Source
- What is scrum and how to get started
Sources and Attributions
Photo by cottonbro studio
Week 25 - Day 3 | Web APIs: Geolocation
Schedule
- Watch the lectures
- Study the suggested material
- Practice on the topics and share your questions
Study Plan
Your instructor will share the video lectures with you. Here are the topics covered:
- Part 1: The Geolocation API
- Part 2: Combining the Geolocation API with OpenStreet Maps.
You can find the lecture code here
Lecture Notes:
Geolocation API
: a browser API for detecting and tracking the device’s location on Earth (geo === earth).- Uses two coordinates (think of them as the x and y on a coordinate map) that are called
latitude
andlongitude
(floating point numbers).
- Uses two coordinates (think of them as the x and y on a coordinate map) that are called
Navigator
(oruser-agent
,User Agent
): the technical term for the Browser. In JS, it is an object:navigator
.
Questions:
- How can we find a place/address from latitude/longitude?
- A: We will use more APIs to get more information about the lat/lon, for example, country, city, address, weather information, etc.
- Can this geo data be trusted?
- A: They can be easily changed by the user with geo-spoofing.
References & Resources:
- Geolocation (theory)
- Geolocation (Browser/Web) API:
- Geolocation API
- Geolocation Interface
- getCurrentPosition() method
- GeolocationPositionError
- GeolocationPosition Interface page (check it out)
- GeolocationCoordinates Interface page (check it out)
- Navigator Interface
- Open Source map: OpenStreetMaps
- Alternatives are the commercial services: Google Maps, Bing, MapBox, etc.
- Leaflet.js (open-source JS library for working with OpenStreetMaps)
- Search for ‘leaflet js quickstart’
- How to trick Google Maps
- DevTools => Command Palette (Ctrl/Cmd+Shift+P) => Search for “Show Sensors”
- https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition
- Lat/Lon to Address and vice versa. Also, more info about the location
Exercises
- Find more about the GeolocationCoordinates.accuracy property
- Share your cool ideas for using the Geolocation API (and combining it with other APIs, services or technologies)
- Air Pollution APIs, weather data, traffic, criminality rates, etc.
- Find info about beaches and display them (e.g. red for not good for swimming, green, etc.)
- Places to check for these kinds of data and APIS
- Ministries of X
- OpenData
- GeoData Greek Government
- Eydap OpenData
- Give this repo a star: https://github.com/Leaflet/Leaflet
- Leaflet JS Tutorial 101
- Maps: Google Maps, Bing, TomTom, MapBox, etc.
- 3D leaflet views
- Grab the bounding box from the geocode API and draw a bounding box around some address
- Search an address and show it on the map
- Get info from lat/lon
- Hardcoded lat/lon to countries
- Learn more about Geohashing:
- What is Geohashing?
- Geohash: Deep Intuitive Understanding in under 7 Minutes
-
Geohashing Algorithm Proximity Search Based Applications System Design
IMPORTANT: Make sure to complete all the tasks found in the daily Progress Sheet and update the sheet accordingly. Once you’ve updated the sheet, don’t forget to commit
and push
. The progress draft sheet for this day is: /user/week25/progress/progress.draft.w25.d03.csv
You should NEVER update the draft
sheets directly, but rather work on a copy of them according to the instructions found here.
Extra Resources
Week 25 - Day 4 | DOM API: Text & Comment Nodes
Schedule
- Watch the lectures
- Study the suggested material
- Practice on the topics and share your questions
Study Plan
Watch the lecture (40min) to learn more about DOM Nodes
and specifically about the Text
and Comment
Nodes.
Week 25 - Day 5 | Media API
Schedule
- Watch the lectures
- Study the suggested material
- Practice on the topics and share your questions
Study Plan
Your instructor will share the video lectures with you. Here are the topics covered:
- Part 1: Local Storage & Media Web APIs
- Part 2: Media Web API
Key points:
- Understand the basics of local storage and its limitations.
- Learn how to use the media API to control video and audio elements.
- Use custom HTML and CSS to create a unique interface for video playback.
- Take advantage of the media API’s methods and properties to enhance user experience.
- Don’t rely solely on local storage; consider using server-side storage solutions for more complex applications.
You can find the lecture code here and the diagrams here.
Questions:
- What about iframe-embedded videos or audio, e.g. Vimeo, YouTube?
- In this case you have to use the Vimeo/YouTube/* APIs.
- The Media API is only available for
<video>
and<audio>
directly accessible through the web page. The Media API won’t work with<iframe>
.
References & Resources:
- Slides
- The
<video>
element - HTMLMediaElement Interface
- iframe vs video/audio:
<video>
and<audio>
are HTML elements to play a video or audio file- You are loading a video or audio file(s)
<iframe>
is an HTML element to load a while web page- You are loading basically an HTML file through a URL.
- What makes https secure?
- It’s not the port (443) but the other technologies* that are working alongside the port and the server. *SSL/TLS.
- MIME Types: “A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) is a standard that indicates the nature and format of a document, file, or assortment of bytes.”
- How to change LiveServer port: search in settings for: “liveServer.settings.port”
- settings.json:
{ "settings": { "liveServer.settings.port": 5555 } }
Weekly feedback: Hey, it’s really important for us to know how your experience with the course has been so far, so don’t forget to fill in and submit your mandatory feedback form before the day ends. Thanks you!