WebFund 2024F Lecture 13
Video
Video from the lecture for October 31, 2024 is now available:
Notes
Lecture 13
----------
For tutorial 6, you'll be playing with a (slightly) cleaned-up version of the validator application we've been using.
Note that I use the validator (and text formatted assignments) because the TA's grade the assignments per questions, not per assignment, and so I need a way to split up assignments into questions.
- this could be done directly through brightspace, but I don't think anyone likes doing things through brightspace if they can avoid it
Note that for Tutorial 6, we are doing *client side JavaScript* (and HTML, and CSS).
Web browsers are all about rendering HTML documents
- client-side JavaScript runs within the context of an HTML document
- this means that objects are defined that allow JavaScript code to access and modify the HTML of the document
- the object is "document" in JavaScript
- to manipulate the HTML, you normally need to selecct something on the page
- page is represented as a tree, with each HTML tag being a node
- to get a node in this tree, you normally use the getElementById method,
which will refer to a specific "id=" tag in the HTML
Two entry points to the code:
- hideAnalysis()
- run onload
- loadAssignment()
- run onchange of filename
onload events happen when the page (HTML tag) is finished loading
In C and JavaScript
- \n in a string represents newline (linefeed character, LF)
- \r in a string represents return (carriage return, CR)
UNIX text files end lines with LF
MS-DOS/Windows text files end lines with CRLF
So client-side JavaScript seems pretty powerful right?
- can load files, process them, and display results in a GUI
(by manipulating the HTML of the document)
But what can't you do?
- cannot save data anywhere, is living in a sandbox
- that's why we have web servers: to serve pages and save results/process data from users