Mediascripting on the Web (CSC 195 2014F) : EBoards

CSC 195 2014S, Class 06: Javascript (1)


Overview

Preliminaries

Admin

Questions

Web sites

About Javascript

Simple Javascript

Loading external libraries

Including code directly

Functions declared with

function NAME(PARAMS)
{
  BODY
} // NAME(PARAMS)

Variables declared with

var NAME;

Instructions look a lot like C, except that you can also tell things to do operations with THING.OPERATION.

var str = "Hello";
str.indexOf("ll") -> 2

You can call functions from the console. And that's a good place to start, particularly since smart consoles have autocomplete.

You can call functions in response to events. That's the most typical way of making things interactive.

onClick="INSTRUCTION"
onMouseOver="INSTRUCTION"
onMouseOut="INSTRUCTION"

Here are a few basic commands to get you started.

var obj = document.getElementById(ID)
obj.innerHTML = "TEXT";
obj.style.color = "red";
obj.style.backgroundColor = "black";

Grr ... sam can't get setTimeout to work.

Lab

Here's a series of operations a student tells me they found in Goedel, Escher, Bach

I believe Hofsteder (sp?) asks whether you can go from MI to MU, but that's irrelevant to our case.

Make a simple Web UI that lets someone explore this design space. Presumably, you'll have a button for each of the options.

Homework

Make a game. It can be animated, text, numeric, whatever. Upload the game in its own folder.

Copyright (c) 2014 Samuel A. Rebelsky.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.