im 215 intro to scripting languages

21
IM 215 Intro to Scripting Languages

Upload: cleta

Post on 05-Jan-2016

30 views

Category:

Documents


1 download

DESCRIPTION

IM 215 Intro to Scripting Languages. Objectives. The core objectives of this course are as follows: Students will understand basic foundations of JavaScript, including its usage in the web and application design and development. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: IM 215 Intro to Scripting Languages

IM 215Intro to Scripting

Languages

Page 2: IM 215 Intro to Scripting Languages

Objectives

The core objectives of this course are as follows:

• Students will understand basic foundations of JavaScript, including its usage in the web and application design and development.

• Students will understand basic foundations of Flash/ActionScript, including its usage in the web and application design and development.

• Students will understand the foundations of mobile applications development.

Page 3: IM 215 Intro to Scripting Languages

Academic policies

• Lab use

• Communication about grades

• Academic honesty

• Exam and quiz policy

• Late work

Page 4: IM 215 Intro to Scripting Languages

Assessment criteria

• Assessments:Class participation - 4 Quizzes – 25 points eachJavascript Assignment 1 – 40 pointsJavascript Assignment 2 – 40 pointsJavascript Assignment 3 – 50 pointsActionscript Assignment 1 – 20 pointsActionscript Assignment 2 – 25 pointsActionscript Assignment 3 – 35 pointsActionscript Assignment 4 – 50 pointsFinal Exam – 100 points

Page 5: IM 215 Intro to Scripting Languages

Grades/Resources

• >= 90% A Excellent

• >=80% and < 90% B Above Average

• >=70% and < 80% C Average

• >=60% and <70% D Below Average

• < 60% F Fails

• Javascript, A Beginner’s Guide, 3rd Edition by John Pollock

• Foundation Actionscript 3.0 by Yard, Webster and McSharry

Page 6: IM 215 Intro to Scripting Languages

Contact details

• Email: [email protected]

• AIM: marktee07

• Twitter: em_tee

• After lectures on Monday’s and Wednesday’s

Page 7: IM 215 Intro to Scripting Languages

JavascriptIntroduction

Page 8: IM 215 Intro to Scripting Languages

Javascript• Adds interactivity and effects to a static

HTML page

• Limited to client side actions

• Wikipedia.com – no javascript interactions

• Amazon.com – significant javascript enhancements

Page 9: IM 215 Intro to Scripting Languages

First steps..• Tools of the trade• A text editor

TextWrangler (http://www.barebones.com/products/TextWrangler/)Notepad++

(http://notepad-plus.sourceforge.net/uk/site.htm) • A browser

Firefox (current version 3.5.7)Internet Explorer (version 7)

• Edit code in your text editor

• When ready to try your code, open in the browser

Page 10: IM 215 Intro to Scripting Languages

Simple HTML page<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN“

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

<title>Simple static page</title>

</head>

<body>

<p>IM215 rocks</p>

</body>

</html>

Page 11: IM 215 Intro to Scripting Languages

First script

Add the following to our page:

<script type=“text/javascript”>document.write(‘<p>And so does Javascript</p>’);

</script>

Save the page and re-open it in your browser.

Page 12: IM 215 Intro to Scripting Languages

External script

Create a new file and insert the following line:

document.write(‘<p>Written in from outside</p>’);

Save it as external.js

Return to our original html file and insert the following:

<script type=“text/javascript” src=“external.js”></script>

Page 13: IM 215 Intro to Scripting Languages

Variables

• Variables are containers for data

• datum – individual piece of data

• name - label that identifies the piece of datum

• variable – consists of a name and a piece of data

• A variable’s datum is called its “value”

Page 14: IM 215 Intro to Scripting Languages

Variables (cont.)

1. Simplify code and save time, giving commonly referenced values a single name

2. Acts as a placeholder for unknown values, e.g. user input

3. Clarifies code, allowing you to give meaningful names to values used in code

Page 15: IM 215 Intro to Scripting Languages

Using Variables

• Defining:var variableName;

• Giving, or “Assigning”, a value:variableName=25;

Or, combined:var variableName=25;

Page 16: IM 215 Intro to Scripting Languages

Variable rules

• Variable names are case sensitive.

• Can only contain letters, numbers or underscores.

• Cannot begin with a number.

• Cannot be one of a set of Javascript reserved words.

• Use meaningful names.

Page 17: IM 215 Intro to Scripting Languages

Variable Data Types

• The current value of a variable has a “type”

• Javascript has 3 core data types• Number – Any number including decimal

numberse.g. var numVar=25;

• String – any sequence of characterse.g. var stringVar=“A string of text”;

• Boolean – true or false

Page 18: IM 215 Intro to Scripting Languages

Using Variables

• To reference a variable, include the name in the context of other code.

• For example,var ourString=“An assigned string”;document.write(ourString);

Page 19: IM 215 Intro to Scripting Languages

Comments

• Lines in code that get ignored by the JavaScript engine.

• Provide clarity, allowing you to explain the overall purpose of your code in plain english.

• Valuable when collaborating on code with others, and for your own future reference.

Page 20: IM 215 Intro to Scripting Languages

Comments

• Single line:// This line is a comment

• Multi-line:/*This is a multi-line commentEverything within here is ignored*/

Page 21: IM 215 Intro to Scripting Languages

Sources:

• “JavaScript: A Beginner’s Guide” by John Pollock