SYST10199 Final Exam Reference Sheet

This document is to be used for the syst10199 final exams.

Event Handling

element.addEventListener(eventType, handler)

Events: DOMContentLoaded, click, input, change, focus, blur

Event object properties: .target, .type, .clientX/.clientY, .offsetX/.offsetY

Forms

Document Properties:
document.forms

Form object properties:
.formName (name="") .elements

Element Collection properties:
elements.elementName (name="")

Element Properties:
element.form
element.value
element.checked (check, radio)
Selection Lists:
select.selectedIndex
select.index
select.options
option.selected
option.text

Creating options for a select list:
new Option(text, value, selectedAttrib, selectThis)

Constraint Validation API

Properties:
element.validationMessage
element.validity
Validity object properties:
.patternMismatch
.tooLong/.tooShort
.valueMissing
.valid

Methods:
form/element.checkValidity()
form/element.reportValidity()
form/element.setCustomValidityMessage(message)

Node.js

Basic headers, responsse codes:
200, 404
text/plain, text/html, text/css, image/png, img/jpg

Commands
npm init
npm install

Basics
require(moduleName)
exports/module.exports
process.env

HTTP module
createServer()
listen()

Request object
.url
.originalurl
.headers
req.headers.host

Response object
.statusCode
.setHeader()
.write()
.end()
.send()
.render()

fs module:
.readFile()
.existsSync()

path module:
.join()
__dirname

URL module:
new URL()
.searchParams

Express:
next/next()
express()
urlencoded()
static()

Express application object:
.set()
.use()
.get()
.post()
listen()

Forms:
req.query
req.body

EJS:
<% scriptlet %>
<%= output %>
<%=# comment %>