Skip to Navigation | Skip to Content

MAT 175 - Web Design - JavaScript + jQuery

Menu

Class Schedule

Week 1 (8/20)

Topics and Learning Objectives

  • Overview/Introduction to the Class and Syllabus
  • Basic Programming Concepts
  • Overview of JavaScript and Programming
  • The Language of JavaScript

Required Assignments + Tasks

Recommended and/or supplemental tasks

Videos and tutorials

About Code

Code.org - Hour of Code

  • Hour of Code (~1 hour)
    Made for "kids of all ages" this is a simple and fun introduction to programming concepts and a good way to get your feet wet.

Overview of Our Class and JavaScript Programming :: Instructor Videos

Hello World - Getting Started with JavaScript :: Instructor Videos

  • Hello World - Where to Put Your Code 14:20)
    JavaScript and code editor basics, script tags, inline vs. external code, alert()
  • Output and Console (30:48)
    JavaScript basics, the console, debugging, <noscript>, working with 'defer', and output such as console.log(), document.write, innerHTML, and more.

Codecademy - Interactive Tutorials

LINKS & Resources

The Book

JavaScript Resources and Reference

> Go to Top

Week 2 (8/27)

Topics and Learning Objectives

  • Introduction to the HTML5 Canvas Exercise
  • Working with <canvas> and JavaScript APIs for drawing
  • Drawing primitive shapes with code
  • Defining drawing functions and making our own drawing plugin

Tasks

Recommended and/or supplemental tasks

  • Review this JavaScript Basics Crash Course/Documentation from the Mozilla Developer Network (recommended)
  • Check out some or all of The JavaScript Programming Language (1:49:54) - A good overview with some history of the JavaScript Programming language from one of the foremost experts, Doug Crockford (author of JavaScript: The Good Parts). This is from a course/presentation at Yahoo and oriented towards a programmer/developer audience. As such, you may not understand all of it, but that's okay. It's still worth watching if you're interested. (optional)

Videos and tutorials

Exercise #1 - Canvas Drawing - Instructor Videos

Codecademy - Interactive Tutorials

Codecademy - Interactive Tutorials

Exercise #1: Canvas Drawing Exercise (Due 9/3)

Explore drawing with the HTML5 <canvas> tag and JavaScript.

Adhere to the following guidelines:

  • Create 3 drawings/web pages that use the <canvas> tag and JavaScript.
    1. One of the drawings should represent your basic coding exploration of the <canvas> tag and JS for creating primitive shapes (lines, rectangles, circles, triangles) with varied fills, strokes, colors, and line-widths. It does not need to be particularly artistic, but should have sample code similar to (but not identical to/forked from) the video tutorial demos.
    2. One of your drawings should be sketched on paper first and then translated to code/canvas. Include a photo or scan of your paper sketch on the webpage along with the rendered canvas. Strive to create something compositionally interesting and well-balanced, but comprised of relatively simple/primitive shapes (rectangles, lines, circles, etc.).
    3. One of your drawings should be conceived of and made with code-only (not on paper first) using a drawing functions/plugin that you create (as discussed in the video tutorial on Creating Custom Functions for Drawing). Strive to create something artistic and somewhat more complex.
  • Design at minimum size of 300 x 300 and a maximum size of 1920 x 1080. Each drawing does not need to be the same size.
  • Perhaps, take inspiration from modernists such as Piet Mondrian or Wassily Kandinsky or artists and designers from the Suprematist or Bauhaus movements who creatively utilized primitive shapes within their artwork.
  • Put your name somewhere on the webpage(s).
  • Create an "exercise1" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpages(.html) and JavaScript(.js) files to this folder on the server. See FTP Information for details.
  • Choose your favorite from among your rendered canvas images, right-click on it to "Save Image As" and get a .png file, and include it in your reply to the Canvas Discussion Board set up for this purpose.
  • Be creative and have fun.

LINKS & Resources

JavaScript Resources and Reference

Canvas Resources

> Go to Top

Week 3 (9/3)

Topics and Learning Objectives

  • Core Programming Concepts
  • Variables and Datatypes
  • Numbers and Math
  • Math.random() and other Math object methods
  • Comparison and Logical Operators
  • If/Then Conditional Logic and Decision Making

Tasks

  • Complete Exercise # 1 (due 9/3) and participate in the Exercise #1 - Canvas Drawings Review and Reflection discussion
  • If you have not yet do so, create your "codeLibrary" folder on the MAT server and add at least one file to it to get it started. See the introduction to the code library video below for more information.
  • Read Chapter 3 on Functions (pp. 85 - 99) and Chapter 4 on Decisions (pp. 145 - 169) in the JavaScript & jQuery textbook by John Duckett (available for free through O'Reilly Books Online)
  • On Codecademy.com, complete the Introduction to JavaScript - Conditional Statements module (as per below)
  • Complete Quiz #2 (by 9/10) - Covers the Week #3 topics/videos
  • Reivew Exercise # 2 (due 9/24). Specific tutorials for this exercise will be provided in next week's module. But, the videos this week review the core concepts applied in the exercise.
  • View the Week #3 Videos and Tutorials below

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Introduction to Exrercise #2, my videos, and the codeLibrary

Linting and JavaScript Linting Errors in Dreamweaver (optional for Dreamwever users or others wanting to learn about linting and the ESLint extension)

Variables and Values

Numbers and Math

Conditional Logic and Decision Making

Codecademy - Interactive Tutorials

Exercise #2: SIMULATE THE GAME OF CRAPS (Due 9/24)

Rules of the game:

In the game of Craps, a "Pass Line" bet proceeds as follows. Using two six-sided dice, the first roll of the dice in a craps round is called the "Come Out Roll." The bet immediately wins when the come out roll is 7 or 11, and loses when the come out roll is 2, 3, or 12. If anything else is rolled (4, 5, 6, 8, 9, or 10) on the come out roll, that number becomes "the point." The player keeps rolling the dice until either 7 or the point is rolled. If the point is rolled first, then the player wins. If the player rolls a 7 first, then the player loses.

Your basic task (the threshold for a 'C'):

Write a JavaScript program that plays the game of craps using the rules stated above. The program should simulate a game and calculate if the player would win or lose.

1) Simulate one game of craps correctly and output the come out roll, the point roll (the final point roll, if there is one), and result of the game (if the player won or lost).

Include some styling (using CSS and/or JS) so that the output and interface is reasonably attractive and the game doesn't just output to console (such as representing the dice as images, styling the text output, or creating a visual interface for the game).

Even better (the threshold for a 'B'):

2) Make this interactive so that a user can play (i.e. initiate the dice roll and/or set a bet amount).

Better still (the threshold for an 'A'):

3) Make the UX and/or UI really nice. Make the user interface (UI) nice through graphic design, imagery/graphics, and CSS styling. Make the user experience (UX) nice through interaction design, such as providing engaging interactivity, user feedback, using animation to convey dice rolls or other activity, and generally creating a pleasant 'playing' experience.

Even better again (to the point of potential extra credit):

4) Allow a choice to "Simulate 1000 games" of craps based on $10 wagers and a $1000 starting bankroll and track/output the number won, the number lost, and the amount of money left in the bank roll after the 1000 games.

5) In addition to #4 above, create/draw a graph that tracks the bankroll across all 1000 games, updating the graph with each roll. (i.e. visualize the data).

6) Or, do other stuff... Such as simulating 10,000 games and computing the probability of winning (i.e. Wins / (Wins + Losses). Or do something else... fork the idea, take it in a different direction. Create a different game even.

Finally, turn in your exercise and reflect upon it:

Create an "exercise2" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpage(.html/.css) and JavaScript(.js) files to this folder on the server. See FTP Information for details.

Once you've completed your exercise, participate in the Exercise #2 Review and Reflection Discussion in Canvas.

To follow along with the videos tutorials, you are welcome to use my dice imagery as graphic resources (dice.zip).

LINKS & Resources

> Go to Top

Week 4 (9/10)

Topics and Learning Objectives

  • Working with Functions
  • Applying Programming Concepts to Simulate a Game of Craps
  • User Input
  • Visualizing Output
  • Making the Craps Game Interactive and Playable

Tasks

Videos and Tutorials

Working with Functions

  • Functions, Part 1 (11:12)
    Introduction to functions. Declaring and calling functions.
  • Functions, Part 2 (12:23)
    Using parameters and passing arguments. Working with multiple arguments (examples including a keepScore() function and a madLibs() generator)
  • Functions, Part 3 (17:06)
    Returning values from functions (examples including functions for inserting copyright dates and Celsius to Fahrenheit converters)
  • Functions, Part 4 (19:39)
    Function expressions, immediately invoked function expressions (iife), recursive functions.

Simulating a Game of Craps - Exercise #2 Demos

  • Craps, Part 1 (6:13)
    Variables and Math.random() to simulate a dice roll
  • Craps, Part 2 (19:47)
    Visualizing the output of the dice with text and image (image.src). Random images. (Feel free to download dice.zip to obtain the dice imagery).
  • Craps, Part 3 (15:24)
    Visualizing output with sprite sheet image and CSS background position (setAttribute)
  • Craps, Part 4 (21:17)
    Understanding the game logic, using if conditional statements and a rollDice() function
  • Craps, Part 5 (19:51)
    Making the game interactive so the user can play, using addEventListener to add click events
  • Craps, Part 6 (15:08)
    Adding user feedback, creating win() and lose() functions.
  • Craps, Part 7 (8:08)
    Tracking bets and the chip stack using variables.
  • Craps, Part 8 (19:41)
    Using an input field to enable the user to change the bet amount and extracting and validating the value of this field (value, paseInt, isNaN).
  • Also see bonus videos in Week #5

Codecademy - Interactive Tutorials

LINKS & Resources

> Go to Top

Week 5 (9/17)

Topics and Learning Objectives

  • Working with Functions
  • Working with Loops
  • Making the Craps Game Interactive and Playable

Tasks

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Simulating a Game of Craps - Bonus Videos

Looping and Iteration

CodeCademy - Interactive Tutorials

LOOPS Code Challenge - GOOD OR BAD DEAL (DUE 10/1)

This coding challenge is required (I want you to try to accomplish it and it will count towards your class participation), but it will not hurt your grade if you don't solve it. However, if you accomplish it and come up with the correct answer, I will provide extra credit (up to 2%).

The Scenario

In what you suspect is a trick, a mysterious man says he'll give you one million dollars with the caveat that you have to pay him back starting with 1 penny and then double that amount for 30 days. In other words, you would give him 1 penny (.01) on day 1, two (.02) pennies on day 2, 4 (.04) pennies on day 3, 8 pennies on day 4 etc. such that you continuously double the amount of the previous day's payment each day for a month (30 days).

Is the total sum that you would pay more or less than one million dollars? In other words, is this a good or bad deal? If a bad deal, on what day would it become so?

Your Task

Using JavaScript and loops (for, while, or do while), write some code to determine if this is a good or bad deal. If a bad deal, make your code output the day on which it would it become so. Respond with your solution in this discussion forum in Canvas (replies to which you will not be able to access until you post your own solution).

I will provide my own solution after 10/1 (so this is a hard deadline for this extra credit opportunity).

LINKS & Resources

> Go to Top

Week 6 (9/24)

Topics and Learning Objectives

  • Exercise #2 Review
  • Loops Code Challenge
  • Approaching Programming Problems: Computational Thinking, Algorithms, Pseudo-Code, FlowCharts
  • Generative Art — Drawing to <canvas> using JavaScript Variables, Loops, Functions, Conditionals, and Randomization

Tasks

Videos and Tutorials

On Computational Thinking and Problem Solving

Generative Art and Exercise #3 Demos— Drawing to <canvas> using JavaScript Variables, Loops, Functions, Conditionals, and Randomization

CodeCademy - Interactive Tutorials

Exercise #3: generative art with the html5 canvas and JavaScript (Due 10/8)

Generative art is art that creates itself, somewhat autonomously, while embracing randomness and chance as an organizing principle. Generative artists intentionally introduce randomness as part of the creation process, such that the same program (or process) in generative art will produce novel results each time it is run.

Your Task

Explore creating generative art by drawing to the HTML5 <canvas> using JavaScript variables, functions, loops, conditionals, and randomization techniques.

In this exercise, we will revisit and extend upon the topics from the Canvas Drawing Exercise (Exercise #1) by adding many of the programmatic concepts that we have learned since, such as working with Math randomization, variables, loops, conditionals, and functions.

Your task is to program a 'generative' artwork that builds upon what you have learned in the class thus far. Start by viewing the generative art video tutorials provided. Perhaps, draw insipration from this article on 'Why Love Generative Art" which provides a good overview and some historical context for generative art.

Then, try to make your own generative artwork using the HTML5 <canvas> and JavaScript. Your program/artwork can rely on relatively simple primitive shapes (lines, rectangles, triangles, circles, etc.), but should produce different results each time the browser is refreshed (or the artwork is 'clicked'). This means that it must use variables and randomization in some way. You are encouraged to also explore working with loops, functions, conditionals, etc. as appropriate to your program and creative vision. While generative artworks embrace some level of chaos, try to create something that you find artistically interesting and aesthetically appealing. Consider creating your own custom color palette that can be randomly applied and/or creating generative patterns, such as iterative tiling patterns that might be applied to wallpaper or fabric. Design at any size you wish up to a maximum size of 1920 x 1080.

Upload and Reflect

Create an "exercise3" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpages(.html) and JavaScript(.js) files to this folder on the server. See FTP Information for details.

Once you've completed your exercise, participate in the Exercise #3 Review and Reflection Discussion in Canvas.

To follow along with the videos tutorials related to generative art, you are welcome to use this starter file and code (generative.zip).

LINKS & Resources

> Go to Top

Week 7 (10/1) - Current Week

Topics and Learning Objectives

  • Strings and String Methods
  • Working with Arrays
  • Array Methods
  • Working with Arrays, Loops, Functions, Logic
  • Applying Arrays - Simple Interactive Quiz and Guessing Game Examples

Tasks

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Strings and String Methods

Working with Arrays

  • Arrays, Part 1 - Introduction (12:13)
    Introduction to arrays. Accessing array data. Arrays with values of varying types. Short intro to multidimensional arrays.
  • Arrays, Part 2 - Creating (11:26)
    Creating arrays. Array Constructors and Array Literals. Accessing array elements by their index.
  • Arrays, Part 3 - Looping (14:38)
    The array length property. Looping through arrays with the for loop and for in loop.
  • Arrays, Part 4 - Methods (16:41)
    Array methods including toString(), join(), sort(), reversw(), concat(), and slice().
  • Arrays, Part 5 - Methods (16:37)
    Array methods including push(), pop(), shift(), unshift(), and splice().

Interactive Quiz Example using Arrays, Loops, and Functions (and Prompt)

  • Quiz Example, Part 1 (10:42)
    Using prompt() for output/input and basic quiz logic.
  • Quiz Example, Part 2 (20:23)
    Using arrays and multidimensional arrays to store quiz questions, for loops to access the questions, and a custom function to ask the questions and check the answer logic.

Interactive Guessing Game Example

CodeCademy - Interactive Tutorials

LINKS & Resources

> Go to Top

Week 8 (10/8) - Preview of Upcoming Week

Topics and Learning Objectives

  • The Document Object Model (DOM)
  • Accessing and Modifying HTML and CSS content
  • Events, Event Handling, and Interactivity

> Go to Top