IS 337: Website Administration

Lecture for December 5: Prototype

+
-

Topics

Why Your Own Server?

  • configure, make, make install: a good UNIX skill to have
  • Your server runs as yourself: won't take down a server others rely on
  • Different types of servers: development, testing, staging, deploy, educational

Dollar-Sign Functions (continued)

  • "Prototyping" elements toggle
    • Use $(), $F(), or any utility.
    • This adds methods from Prototype library to basic JavaScript DOM elements.
  • utilities toggle
    • $w('one two three') is an array ['one', 'two', 'three']
    • $A() converts arguments to an array (very magic!)
    • $H() converts arguments into a hash
    • $R(low, high) creates a range

JavaScript Object Literal Notation

  • Uses: toggle
    • Hash-like/struct-like
    • OOP
  • Syntax: toggle
    • JSON definition: { field1: value1, field2: value2, ... }
    • If valueI is a function, this refers to the current object.
    • Access field: variable.fieldI or variable.fieldI()
  • JSON is based on this: use strings for fieldIs.

Navigating and Manipulating the DOM

  • Using DOM functions toggle
    • Annoying API
    • Annoying iteration
    • Annoying nodes (including whitespace text nodes and comments!)
  • Navigating with Prototype toggle
    • down('CSS selector', index)
    • next('CSS selector', index)
    • previous('CSS selector', index)
    • up('CSS selector', index)
    • all: arguments are optional in all combinations
  • Manipulating with Prototype toggle
    • cleanWhitespace()
    • remove()
    • replace(HTML content) (replaces element)
    • update(HTML content) (replaces content of element)

Observing Events

  • element.observe(eventName, observer) toggle
    • element a Prototyped DOM element
    • eventName a string naming the event
    • observer a function to be executed for the event toggle
      • function () { ... }
      • function (event) { ... }

Readings and Resources

Creative © 2007 Calvin College and Jeremy D. Frens.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.