JavaScript Chapter 6 Note new scoring. spin.js (page 67) function spin() function spin() { var obj_style = document.getElementById("d1").style; var obj_style.

Slides:



Advertisements
Similar presentations
CSS3 OVERVIEW Owen Williams Owen at dynabooks daht com.
Advertisements

CS 142 Lecture Notes: EventsSlide 1 Access to Event Object ● event variable (HTML): ● Passed as argument to function (DOM/Firefox): element.onclick = mouseClick;
HTML and CSS. HTML Hyper Text Markup Language Tells browser how to display text and images.
Week 10 Creating Positioned Layouts
Bring Life to Your Web Pages with JavaScript and HTML5 Ole Ildsgaard Hougaard -
Bring Life to Your Web Pages with JavaScript and HTML5 Part 2 Ole Ildsgaard Hougaard -
Web Pages Week 10 This week: CSS Next week: CSS – Part 2.
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
Programming Club IIT Kanpur. Work environment Before you begin coding,always set up your work environment to your needs IDE Notepad++ Sublime Text 2.
Chapter 6 More CSS Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Layout using CSS. Using multiple classes In the head:.important{font-style:italic;}.title{color:red;} In the body: Here's a type of paragraph that is.
The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
Session 4: CSS Positioning Fall 2006 LIS Web Team.
Cascade Style Sheet Demo. Cascading Style Sheets Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
JavaScript- Processing HTML Forms. Event Handlers Begins with and ends with.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
CIS101 Introduction to Computing Week 10 Spring 2004.
CIS101 Introduction to Computing Week 10. Agenda Your questions Final exam and final project CIS101 Student Survey Class presentations: Your Mad Libs.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
4.01 Cascading Style Sheets
Introduction to touchdevelop math basic arithmetic operations Disclaimer: This document is provided “as-is”. Information and views expressed in this document,
Microsoft® Small Basic The Math Object Estimated time to complete this lesson: 1 hour.
Additional Topics. Tutorial #9 Review – Forms Forms Legend and fieldset Fields Text Password Radio buttons, check box, text area, select lists Buttons.
Technologies for web publishing Ing. Václav Freylich Lecture 7.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
1 Math Expressions and Operators. 2 Some C++ Operators Precedence OperatorDescription Higher ( )Function call +Positive - Negative *Multiplication / Division.
To begin click: File, New, then select Design Familiarize yourself with the controls on the page. Then use the maximise button the make the window fill.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Web Foundations WEDNESDAY, NOVEMBER 20, 2013 LECTURE 32: DREAMWEAVER SLIDE SHOW AND GOOGLE MAP.
Event-Driven Programming Chapter Page Section: Section or division of an HTML page Generic block element Example: What's the difference between.
Salary Calculator. Design a page like the following.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 17 - Dynamic HTML: Structured Graphics ActiveX Control Outline 17.1 Introduction 17.2 Shape Primitives.
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
SetTimeout()  What if you want to automatically cycle through the pics?  So you don’t have to keep clicking the button to see the next pic  Use the.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Let’s Learn 3. Modules Saenthong School, January – February 2016
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
The Box Model in CSS Web Design – Sec 4-8
4.01 Cascading Style Sheets
Looping SetTimeout is a loop
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
CSS3 Style of the HTML document CSS2+New Specifications Differences
The Box Model in CSS Web Design – Sec 4-8
Chapter 6 More CSS Basics Key Concepts
Style Sheet Create a new CSS called Cameras.CSS TD Web Authoring
Table CSS Create a new CSS called tablestyle.CSS Green Background
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
JavaScript Basics Topics Overview Syntactic Characteristics
CSS Borders and Margins.
HTML5 Level I Session III
HTML5 Level I Session III
Box model, spacing, borders, backgrounds
In Class Programming: Credit card payment
Creating a Webpage with External CSS
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
Chapter 17 - Dynamic HTML: Structured Graphics ActiveX Control
JavaScript Programming Labs
Web Development & Design Foundations with H T M L 5
How to use the CSS box model for spacing, borders, and backgrounds
JavaScript Basics Topics Review Important Methods Writing Functions
4.01 Cascading Style Sheets
Cascading Style Sheets
ITI 133: HTML5 Desktop and Mobile Level I
Presentation transcript:

JavaScript Chapter 6 Note new scoring

spin.js (page 67) function spin() function spin() { var obj_style = document.getElementById("d1").style; var obj_style = document.getElementById("d1").style; var radius = 40; var radius = 40; var x_offset = 50; var x_offset = 50; var y_offset = 50; var y_offset = 50; pos += 10; pos += 10; x = radius * Math.cos( pos * Math.PI/180 ); x = radius * Math.cos( pos * Math.PI/180 ); y = radius * Math.sin( pos * Math.PI/180 ); y = radius * Math.sin( pos * Math.PI/180 ); x += x_offset; x += x_offset; y += y_offset; y += y_offset; obj_style.left = x + "px"; obj_style.left = x + "px"; obj_style.top = y + "px"; obj_style.top = y + "px"; setTimeout( "spin()",100 ); setTimeout( "spin()",100 ); }

spin.html Using Math PI Using Math PI

spin.css #d1 #d1 { position:absolute; position:absolute; top:100px; top:100px; left:100px; left:100px; width:30px; width:30px; height:30px; height:30px; background-color: red; background-color: red; border:1px solid; black border:1px solid; black }

Math Functions Math.random (); //from 0.0 to 1.0 Math.round(n);Math.floor(n);Math.ceil(n); Lots of others…

Exercise 1 Square Root Calculator Create a form where you can enter a number and click a button to alert the square root. Use parseFloat on page 84.

Exercise 1 (HTML) Value: Value:

Exercise 1 (JavaScript) Function go(number) Function go(number) { Var realNumber = parseFloat(number); Var realNumber = parseFloat(number); alert(math.sqrt(realNumber)); alert(math.sqrt(realNumber)); }

Exercise 2 Round and round Create a form to input three numbers: Create a form to input three numbers: center (position) of circle, center (position) of circle, radius of circle, and radius of circle, and speed of rotation. speed of rotation. Starting with page 67 (spin) create a program that spins different size boxes at different radii and different speeds. Starting with page 67 (spin) create a program that spins different size boxes at different radii and different speeds.

The Generic Program Loop (aka Spin) Loop (aka Spin) State (radius, position, and speed) State (radius, position, and speed) User Interface or Event Handler User Interface or Event Handler Forms and functions for onclick etc. Forms and functions for onclick etc.

spin.js function spin() function spin() { var obj_style = document.getElementById("d1").style; var obj_style = document.getElementById("d1").style; var radius = 40; //radius **move to state** var radius = 40; //radius **move to state** var x_offset = 50; //position **move to state** var x_offset = 50; //position **move to state** var y_offset = 50; //position **move to state** var y_offset = 50; //position **move to state** pos += 10; //speed **move to state** pos += 10; //speed **move to state** x = radius * Math.cos( pos * Math.PI/180 ); x = radius * Math.cos( pos * Math.PI/180 ); y = radius * Math.sin( pos * Math.PI/180 ); y = radius * Math.sin( pos * Math.PI/180 ); x += x_offset; x += x_offset; y += y_offset; y += y_offset; obj_style.left = x + "px"; obj_style.left = x + "px"; obj_style.top = y + "px"; obj_style.top = y + "px"; setTimeout( "spin()",100 ); setTimeout( "spin()",100 ); }

spin.js with state var radius = 40; //radius **moved into state** var radius = 40; //radius **moved into state** var x_offset = 50; //position **moved into state** var x_offset = 50; //position **moved into state** var y_offset = 50; //position **moved into state** var y_offset = 50; //position **moved into state** var speed = 10; var speed = 10; function spin() function spin() { var obj_style = document.getElementById("d1").style; var obj_style = document.getElementById("d1").style; pos += speed; //speed **from state** pos += speed; //speed **from state** x = radius * Math.cos( pos * Math.PI/180 ); // radius **from state** x = radius * Math.cos( pos * Math.PI/180 ); // radius **from state** y = radius * Math.sin( pos * Math.PI/180 ); // radius **from state** y = radius * Math.sin( pos * Math.PI/180 ); // radius **from state** x += x_offset; //position **from state** x += x_offset; //position **from state** y += y_offset; //position **from state** y += y_offset; //position **from state** obj_style.left = x + "px"; obj_style.left = x + "px"; obj_style.top = y + "px"; obj_style.top = y + "px"; setTimeout( "spin()",100 ); setTimeout( "spin()",100 ); }

spin.js event handler var radius = 40; //radius **moved into state** var radius = 40; //radius **moved into state** var x_offset = 50; //position **moved into state** var x_offset = 50; //position **moved into state** var y_offset = 50; //position **moved into state** var y_offset = 50; //position **moved into state** var speed = 10; var speed = 10; function setPosition(xStringInput, yStringInput) function setPosition(xStringInput, yStringInput) { x_offset = parseFloat(xStringInput); x_offset = parseFloat(xStringInput); y_offset = parseFloat(yStringInput); y_offset = parseFloat(yStringInput); }

The Generic Program Loop (aka Spin) Loop (aka Spin) State (box size, position, and speed) State (box size, position, and speed) User Interface or Event Handler User Interface or Event Handler Forms and functions for onclick etc. Forms and functions for onclick etc.