Random number generation, Math object and methods, HTML elements in motion, setinterval and clearinterval

Size: px
Start display at page:

Download "Random number generation, Math object and methods, HTML elements in motion, setinterval and clearinterval"

Transcription

1 Lab04 - Page 1 of 6 Lab 04 Monsters in a Race Random number generation, Math object and methods, HTML elements in motion, setinterval and clearinterval Additional task: Understanding pass-by-value Introduction In this lab you will create an animation which shows 3 monsters in a race: moving with random speed in the browser window from left to right. Figure 1. Before the race Figure 2. The race is finished Winner: Monster 2 We can press the start button to begin. Then the monsters move in different velocities towards the right. (The button will be disabled when they start.) While the monsters are in racing, we can press the stop button to pause them. Then press the start button again to make them continue. When the fastest monster has passed the goal (red vertical border on the right), the game is ended. The winning alert box will be shown (Figure 2). After we click OK, the webpage is reloaded to resume like Figure 1 for the next game to start. I. The Design A. There are 3 image tags (<img>) which show the monster images monster1.gif, monster2.gif, monster3.gif. These image tags are contained within the divisions (<div>) which represent their tracks. B. We use global variables to keep track of monster locations (x1, x2, x3) and to store their velocities (v1, v2, v3). C. At the beginning, these monsters are at the left (all x1, x2, x3 equal 0). When we click the start button, we will run a function called startanim() which initiates the animation: Hide the button; Assign random velocities to v1, v2, v3; Start the animation schedule (see D below). D. The animation is done by repeatedly executing a function (named move_a_step()) every 100 milliseconds. The move_a_step() function updates x1, x2, x3 and advances the monsters by one step accordingly. It also checks whether any monster has just won: If any monster has passed the destination, it shows the winning alert box and stops the animation schedule. For simplicity, if two (or three) monsters arrive at the same time, just show any one of them. E. During the race, when we click the stop button, the animation schedule will be cancelled and monsters will stop moving.

2 Lab04 - Page 2 of 6 II. Your Task 1. Download the initial HTML file from the course web. You will complete it in this lab. 2. Open it in the browser and Komodo Edit Study the code (Figure 3). The html elements for the first monster and its track are given. <body> <hr/> <!-- horizontal line --> (The background color and the goal (red line) are controlled by the given CSS code. You do not need to handle them.) <div id="track1"> <img src="monster1.gif" id="m1" /> </div> <hr/> </body> Figure 3. The given HTML file for you to complete. 4. Add html elements for the other monsters and tracks. Give proper IDs to them. Make sure they appear correctly as in Figure Add one button element below the monsters: <button type="button">start</button> Make sure it appears correctly as in Figure Add an ID and the onclick event handler to the button: <button type="button" >start</button> id="btnstart" Later we need to hide the button when the race starts. To do so we will refer to the button using this id. onclick="startanim();" We will write this function in next step. 7. Add the global variables and the startanim() function into the <script> </script> section as follows: Add Code <script> //ID of the animation schedule var idinterval; //velocities of monsters var v1, v2, v3; //locations of monsters; initially at the left margin var x1=0, x2=0, x3=0; //Start the animation function startanim() We will add some code here The value of this ID will be obtained when the animation schedule starts. The ID is required for terminating the schedule when the race is finished. Values of random velocities will be assigned when the animation starts. This line combines the below as one statement: var x1, x2, x3; X1=0; X2=0; X3=0; </script>

3 Lab04 - Page 3 of 6 8. In the startanim() function, add the following code. Given Code function startanim() document.getelementbyid("btnstart").disabled = true; v1= Math.floor(Math.random()*20)+5; //pick a random integer from 0 to 19; then add 5 v2= Math.floor(Math.random()*20)+5; v3= Math.floor(Math.random()*20)+5; idinterval= setinterval('move_a_step()',100); </script> Study the explanations below: We change the.disabled property to "true" to disable the Start button The Math object provides useful methods (functions) for Mathematics tasks: Math.random() - return a random value among 0.0 to (less than 1.0). Math.floor(x) - returns the floor of x. (Definition of floor(x): largest integer not greater than x) We use the setinterval function to run a piece of JavaScript code every 100 milliseconds: setinterval('..', 100) State the interval, in millisecond Specify the JavaScript code to be scheduled Thus, we write setinterval('move_a_step()',100); to call move_a_step() every 100 milliseconds. An ID of the created schedule is returned by setinterval(). This ID is required later when we terminate the schedule at the end of the race. Thus, we write idinterval = setinterval(..); to save the ID in the global variable, idinterval, for later use. 9. Add the move_a_step() function after the startanim() function as follows: Given Code //Advance locations of the monsters and check who wins (if any). function move_a_step() //Check for winner (given in next step) //Advance the locations x1+=v1; x2+=v2; x3+=v3; //Position the monsters document.getelementbyid("m1").style.left= x1+"px"; document.getelementbyid("m2").style.left= x2+"px"; document.getelementbyid("m3").style.left= x3+"px"; Study the explanations below: x+=v; is the abbreviation for x = x+ v; The.style.left property is the location of the left edge of the element. We can change it so as to move the element. E.g. we set it to "200px" to move it to 200 pixels from the left margin of its containing box. TEST the webpage - Click start and see the three monsters move. There is no way to stop them. Just close the browser window. Need help? Find the Lab helpers.

4 Lab04 - Page 4 of Add the following code to check for winner inside the move_a_step() function. New Code to Add var goal =document.getelementbyid("track1").clientwidth; function move_a_step() if (x1>=goal && x1==math.max(x1,x2,x3)) clearinterval(idinterval); alert("winner: Monster 1"); window.location.reload(true); return; if (x2.. ).. if (x3.. ).. Your task: Fill in these parts (similar to the above!!) x1+=v1; x2+=v2; x3+=v3; document.getelementbyid(.. document.getelementbyid(.. document.getelementbyid(.. Study the explanations below: "track1" is the id of the track of the first monster (See Figure 3: <div id="track1">). We get its width by referring to the.clientwidth property, which will be used as the goal of the race track. For each monster, if x >= goal and it is the farthest among others, then it is the winner. Math.max(..) - compare the arguments and return the maximum value. && - means "and",.. clearinterval(idinterval); window.location.reload(); return; - The simplest usage of an if-statement is to control whether one statement will run. However, when a winner is found we need to run more than one statements (-). In cases like this we can use.. to group them as a compound statement so that they will execute as a statement block when the if-statement is satisfied. - call the clearinterval function to stop the schedule whose id is given as idinterval. - reload the current webpage for playing the game again. - skip the remaining code inside this function and finish the function call. TEST the webpage - Click start and see who is the winner!! Need help? Find the Lab helpers. 11. Add one more button stop next to the start button: <button type="button" disabled>stop</button> 12. Add an ID and the onclick event handler to this button: id="btnstop" onclick="stopanim();" We will write this function in next step. 13. Add the following code inside the startanim() function to enable the stop button. document.getelementbyid("btnstart").disabled = true; document.getelementbyid("btnstop").disabled = false; New code to add

5 Lab04 - Page 5 of Add a stopanim() function after the startanim() function. Complete the code inside to: 1 stop the schedule whose id is given as idinterval; 2 enable the Start button; 3 disable the Stop button. function stopanim() Your task: Finish this function (only 3 lines of code are needed) TEST the webpage - Click start and stop to start, pause and continue the race. Need help? Find the Lab helpers. Additional task: Understanding pass-by-value Download passbyvalue.html from the course web. Open it in the browser and Komodo Edit 7. It contains a button: Your task: <button type="button" onclick="testing();"> 1. Guess the result when line runs. It shows (10, 15, or..?) passbyvalue.html function addfive(input) input=input+5; function testing() var x; x=10; addfive(x); 2. Now click the button in the browser. What is shown? (10, 15, or..?) 3. Complete the following summary: [Given: passes, calls, a copy of x, the original value of x] alert(x); When the testing function the addfive function, it the value contained in x. The value of x is copied, and that copied value is named input within the addfive function. In the addfive function, changing the value of input is actually changing, which doesn't affect outside of the addfive function. So calling addfive doesn't accomplish anything. The above is known as pass-by-value. In most programming languages this is the default parameter-passing mechanism. Some require careful observations! Exit-Test - Complete the following summary. I. General Revision () - generate a random value between 0 and (less than 1.0) (x1, x2, x3) - return the largest value among x1, x2, x3 ("m()",100) - run m() every 100 millisecond (id) - stop a schedule whose ID is id - the x-coordinate of an element - the abbreviation for x = x+v; - rewrite var x; x=99; in one statement Given choices: Math.max Math.random clearinterval setinterval x+=v;.style.left var x=99; Pass-by-value - get a copy of the value of the argument only. Thus the caller's original value cannot be changed. - group several statements into one compound statement. continue on next page

6 Lab04 - Page 6 of 6 II. Mixing with return (Recall: return.. ; means return a value and stop the function; is or, && is and, == is for comparison) The function, compare1, is given on the right. It compares a, b, c and then returns "all same", "some same", or "all different". 1. Which one of the below will show "all same"? Put a in the box. alert( 'compare1("1,1,1")' ); alert( compare1("1,1,1") ); alert( "compare1(1,1,1)" ); alert( compare1(1,1,1) ); compare.html function compare1 (a,b,c) if (a==b && b==c) return "all same"; if (a==b b==c a==c) return "some same"; 2. Complete the descriptions below: 5 return "all different"; compare1(1,1,1): Run lines 1, 2 only (At line 1, it decides to enter line 2, at which it returns "all same" and the function is stopped) compare1(1,2,2): (At line 1, it decides to skip line 2 and proceed to line 3) Run lines 1, 3, 4 only compare1(1,2,3): Run lines only The function compare2, given on the right, always gives the same output as compare1. 3. Complete the descriptions below: compare2(1,1,2): Run lines 1,2,3,4,5,7; Change of the result variable: "all different" => "some same". Finally, "some same" is returned. compare2(1,2,3): Run lines ; Finally, " " is returned compare.html function compare2 (a,b,c) var result; result="all different"; if (a==b b==c a==c) result = "some same"; if (a==b && b==c) result = "all same"; return result; ** Show your answers to the Lab Helper. This is the end of the Lab. Please fill in and submit the Progress Sheet attached below. You have learnt a lot in this lab. If needed, please redo again and review all covered skills. You may then proceed to the Follow-up Reading and Activities for this Lab, which can be found at the course web. Lab04 - Progress Sheet Helper's signature : ( / ) dd mm Student name and EID : [E.g. Chan Siu Pang (spchan31)] Student belongs to : L (Lab session) e.g., L09 Remarks : e.g., late / not this group / join 2nd time Progress & performance - Rated by the student : [poor] [excellent] (Please circle) Rated by the helper : [poor] [excellent] References: 5: Very familiar with the contents. Easily complete the Exit-Test. 4: Spend effort to review through doing the Exit-Test. Afterwards, get 100% familiar with the contents. 3: Have basic ideas about all the contents after learning through the Exit-Test.

Task 1. Set up Coursework/Examination Weights

Task 1. Set up Coursework/Examination Weights Lab02 Page 1 of 6 Lab 02 Student Mark Calculation HTML table button textbox JavaScript comments function parameter and argument variable naming Number().toFixed() Introduction In this lab you will create

More information

Functions, Randomness and Libraries

Functions, Randomness and Libraries Functions, Randomness and Libraries 1 Predefined Functions recall: in mathematics, a function is a mapping from inputs to a single output e.g., the absolute value function: -5 5, 17.3 17.3 in JavaScript,

More information

INTRODUCTION TO JAVASCRIPT

INTRODUCTION TO JAVASCRIPT INTRODUCTION TO JAVASCRIPT Overview This course is designed to accommodate website designers who have some experience in building web pages. Lessons familiarize students with the ins and outs of basic

More information

JavaScript: Tutorial 5

JavaScript: Tutorial 5 JavaScript: Tutorial 5 In tutorial 1 you learned: 1. How to add javascript to your html code 2. How to write a function in js 3. How to call a function in your html using onclick() and buttons 4. How to

More information

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser. Controlled Assessment Task Question 1 - Describe how this HTML code produces the form displayed in the browser. The form s code is displayed in the tags; this creates the object which is the visible

More information

PIC 40A. Midterm 1 Review

PIC 40A. Midterm 1 Review PIC 40A Midterm 1 Review XHTML and HTML5 Know the structure of an XHTML/HTML5 document (head, body) and what goes in each section. Understand meta tags and be able to give an example of a meta tags. Know

More information

Best Practices Chapter 5

Best Practices Chapter 5 Best Practices Chapter 5 Chapter 5 CHRIS HOY 12/11/2015 COMW-283 Chapter 5 The DOM and BOM The BOM stand for the Browser Object Model, it s also the client-side of the web hierarchy. It is made up of a

More information

Lesson 7: If Statement and Comparison Operators

Lesson 7: If Statement and Comparison Operators JavaScript 101 7-1 Lesson 7: If Statement and Comparison Operators OBJECTIVES: In this lesson you will learn about Branching or conditional satements How to use the comparison operators: ==,!=, < ,

More information

CISC 1600 Lecture 2.4 Introduction to JavaScript

CISC 1600 Lecture 2.4 Introduction to JavaScript CISC 1600 Lecture 2.4 Introduction to JavaScript Topics: Javascript overview The DOM Variables and objects Selection and Repetition Functions A simple animation What is JavaScript? JavaScript is not Java

More information

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: CS1046 Lab 4 Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to: Define the terms: function, calling and user-defined function and predefined function

More information

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28

Programming Lab 1 (JS Hwk 3) Due Thursday, April 28 Programming Lab 1 (JS Hwk 3) Due Thursday, April 28 Lab You may work with partners for these problems. Make sure you put BOTH names on the problems. Create a folder named JSLab3, and place all of the web

More information

CSE 154: Web Programming Autumn 2018

CSE 154: Web Programming Autumn 2018 CSE 154: Web Programming Autumn 2018 Name: UWNet ID : TA (or section): Rules: @uw.edu You have 60 minutes to complete this exam. You will receive a deduction if you keep working after the instructor calls

More information

Problem 1: Textbook Questions [4 marks]

Problem 1: Textbook Questions [4 marks] Problem 1: Textbook Questions [4 marks] Answer the following questions from Fluency with Information Technology. Chapter 3, Short Answer #8: A company that supplies connections to the Internet is called

More information

A Balanced Introduction to Computer Science, 3/E

A Balanced Introduction to Computer Science, 3/E A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 4 JavaScript and Dynamic Web Pages 1 Static vs. Dynamic Pages

More information

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi Contents IN DeTAIl Acknowledgments xxi Introduction xxiii Who Should Read This Book?....xxiv How to Read This Book....xxiv What s in This Book?...xxv Have Fun!...xxvi Part I: Fundamentals 1 What Is JavaScript?

More information

By the end of this section of the practical, the students should be able to:

By the end of this section of the practical, the students should be able to: By the end of this section of the practical, the students should be able to: Write JavaScript to generate HTML Create simple scripts which include input and output statements, arithmetic, relational and

More information

Positioning in CSS: There are 5 different ways we can set our position:

Positioning in CSS: There are 5 different ways we can set our position: Positioning in CSS: So you know now how to change the color and style of the elements on your webpage but how do we get them exactly where we want them to be placed? There are 5 different ways we can set

More information

AIM. 10 September

AIM. 10 September AIM These two courses are aimed at introducing you to the World of Web Programming. These courses does NOT make you Master all the skills of a Web Programmer. You must learn and work MORE in this area

More information

Indian Institute of Technology Kharagpur. Javascript Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. Javascript Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur Javascript Part III Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 27: Javascript Part III On completion, the student

More information

Designing for Web Using Markup Language and Style Sheets

Designing for Web Using Markup Language and Style Sheets Module Presenter s Manual Designing for Web Using Markup Language and Style Sheets Effective from: July 2014 Ver. 1.0 Amendment Record Version No. Effective Date Change Replaced Pages 1.0 July 2014 New

More information

Project 2: After Image

Project 2: After Image Project 2: After Image FIT100 Winter 2007 Have you ever stared at an image and noticed that when it disappeared, a shadow of the image was still briefly visible. This is called an after image, and we experiment

More information

CSE 154: Web Programming Autumn 2018

CSE 154: Web Programming Autumn 2018 CSE 154: Web Programming Autumn 2018 Practice Midterm Exam 2 Note: We strongly recommend printing out practice exams and working through them with only your cheatsheet (provided on the course website)

More information

Lab 8 CSE 3,Fall 2017

Lab 8 CSE 3,Fall 2017 Lab 8 CSE 3,Fall 2017 In this lab we are going to take what we have learned about both HTML and JavaScript and use it to create an attractive interactive page. Today we will create a web page that lets

More information

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next.

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next. CoderDojo Activity Cards: How to use: Student comes to mentor, and together they choose a card to do next. The idea is always to choose a card that is interesting, and at the right level for the moment,

More information

Introduction to using HTML to design webpages

Introduction to using HTML to design webpages Introduction to using HTML to design webpages #HTML is the script that web pages are written in. It describes the content and structure of a web page so that a browser is able to interpret and render the

More information

Lesson 6: Introduction to Functions

Lesson 6: Introduction to Functions JavaScript 101 6-1 Lesson 6: Introduction to Functions OBJECTIVES: In this lesson you will learn about Functions Why functions are useful How to declare a function How to use a function Why functions are

More information

JS Lab 1: (Due Thurs, April 27)

JS Lab 1: (Due Thurs, April 27) JS Lab 1: (Due Thurs, April 27) For this lab, you may work with a partner, or you may work alone. If you choose a partner, this will be your partner for the final project. If you choose to do it with a

More information

SCRATCH MODULE 3: NUMBER CONVERSIONS

SCRATCH MODULE 3: NUMBER CONVERSIONS SCRATCH MODULE 3: NUMBER CONVERSIONS INTRODUCTION The purpose of this module is to experiment with user interactions, error checking input, and number conversion algorithms in Scratch. We will be exploring

More information

A Balanced Introduction to Computer Science, 3/E

A Balanced Introduction to Computer Science, 3/E A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 7 Functions and Randomness 1 Predefined Functions recall: in

More information

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 7 Functions and Randomness 1 Predefined Functions recall: in

More information

A340 Laboratory Session #5

A340 Laboratory Session #5 A340 Laboratory Session #5 LAB GOALS Creating multiplication table using JavaScript Creating Random numbers using the Math object Using your text editor (Notepad++ / TextWrangler) create a web page similar

More information

JQUERYUI - SORTABLE. axis This option indicates an axis of movement "x" is horizontal, "y" is vertical. By default its value is false.

JQUERYUI - SORTABLE. axis This option indicates an axis of movement x is horizontal, y is vertical. By default its value is false. JQUERYUI - SORTABLE http://www.tutorialspoint.com/jqueryui/jqueryui_sortable.htm Copyright tutorialspoint.com jqueryui provides sortable method to reorder elements in list or grid using the mouse. This

More information

University of Washington, CSE 154 Homework Assignment 8: Baby Names

University of Washington, CSE 154 Homework Assignment 8: Baby Names University of Washington, CSE 154 Homework Assignment 8: Baby Names This assignment is about using Ajax to fetch data in text, HTML, XML, and JSON formats. Every 10 years, the Social Security Administration

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

A Balanced Introduction to Computer Science, 3/E

A Balanced Introduction to Computer Science, 3/E A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 9 Abstraction and Libraries 1 Abstraction abstraction is the

More information

jquery Tutorial for Beginners: Nothing But the Goods

jquery Tutorial for Beginners: Nothing But the Goods jquery Tutorial for Beginners: Nothing But the Goods Not too long ago I wrote an article for Six Revisions called Getting Started with jquery that covered some important things (concept-wise) that beginning

More information

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate

More information

Elementary Computing CSC 100. M. Cheng, Computer Science

Elementary Computing CSC 100. M. Cheng, Computer Science Elementary Computing CSC 100 1 Basic Programming Concepts A computer is a kind of universal machine. By using different software, a computer can do different things. A program is a sequence of instructions

More information

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 5 JavaScript and User Interaction 1 Text Boxes HTML event handlers

More information

Loops/Confirm Tutorial:

Loops/Confirm Tutorial: Loops/Confirm Tutorial: What you ve learned so far: 3 ways to call a function how to write a function how to send values into parameters in a function How to create an array (of pictures, of sentences,

More information

ABOUT WEB TECHNOLOGY COURSE SCOPE:

ABOUT WEB TECHNOLOGY COURSE SCOPE: ABOUT WEB TECHNOLOGY COURSE SCOPE: The booming IT business across the globe, the web has become one in every of the foremost necessary suggests that of communication nowadays and websites are the lifelines

More information

(Refer Slide Time: 01:40)

(Refer Slide Time: 01:40) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #25 Javascript Part I Today will be talking about a language

More information

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style

More information

a.) All main headings should be italicized. h1 {font-style: italic;} Use an ordinary selector. HTML will need no alteration.

a.) All main headings should be italicized. h1 {font-style: italic;} Use an ordinary selector. HTML will need no alteration. This is an open-book, open-notes exam. FINAL EXAMINATION KEY MAY 2007 CSC 105 INTERACTIVE WEB DOCUMENTS NICHOLAS R. HOWE All answers should be written in your exam booklet(s). Start with the questions

More information

WELCOME TO JQUERY PROGRAMMING LANGUAGE ONLINE TUTORIAL

WELCOME TO JQUERY PROGRAMMING LANGUAGE ONLINE TUTORIAL WELCOME TO JQUERY PROGRAMMING LANGUAGE ONLINE TUTORIAL 1 The above website template represents the HTML/CSS previous studio project we have been working on. Today s lesson will focus on JQUERY programming

More information

1. Ask your account manager for your personal publisher ID. 2. Integrate the code on every game page.

1. Ask your account manager for your personal publisher ID. 2. Integrate the code on every game page. 1. Ask your account manager for your personal publisher ID. 2. Integrate the code on every game page. 3. Connect your game id s to the walkthrough code. Getting started Copy the following snippet within

More information

JAVASCRIPT LESSON 4: FUNCTIONS

JAVASCRIPT LESSON 4: FUNCTIONS JAVASCRIPT LESSON 4: FUNCTIONS 11.1 Introductio n Programs that solve realworld programs More complex than programs from previous chapters Best way to develop & maintain large program: Construct from small,

More information

Making a quiz. Javascript simple Quiz Jquery JSON data Quiz

Making a quiz. Javascript simple Quiz Jquery JSON data Quiz Making a quiz Javascript simple Quiz Jquery JSON data Quiz Making a quiz Javascript simple Quiz Jquery JSON data Quiz Making a quiz popquiz.htm HTML forms with questions results.htm - results/grades quizconfig.js

More information

Photo from DOM

Photo from  DOM Photo from http://www.flickr.com/photos/emraya/2861149369/ DOM 2 DOM When a browser reads an HTML file, it must interpret the file and render it onscreen. This process is sophisticated. Fetch Parse Flow

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Ch. 5: JavaScript An Object-Based Language Ch. 6: Programming the Browser Review Data Types & Variables Data Types Numeric String Boolean Variables Declaring

More information

Using Dreamweaver CS6

Using Dreamweaver CS6 Using Dreamweaver CS6 2 The World Wide Web is based on (Hypertext markup language). Although Dreamweaver is primarily a WYSIWYG editor, it is still worthwhile for Dreamweaver users to be familiar with

More information

ORB Education Quality Teaching Resources

ORB Education Quality Teaching Resources These basic resources aim to keep things simple and avoid HTML and CSS completely, whilst helping familiarise students with what can be a daunting interface. The final websites will not demonstrate best

More information

CS 110 Exam 2 Spring 2011

CS 110 Exam 2 Spring 2011 CS 110 Exam 2 Spring 2011 Name (print): Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in compliance

More information

Events: another simple example

Events: another simple example Internet t Software Technologies Dynamic HTML part two IMCNE A.A. 2008/09 Gabriele Cecchetti Events: another simple example Every element on a web page has certain events which can trigger JavaScript functions.

More information

Cascading Style Sheets for layout II CS7026

Cascading Style Sheets for layout II CS7026 Cascading Style Sheets for layout II CS7026 Understanding CSS float The CSS float property is also a very important property for layout. It allows you to position your Web page designs exactly as you want

More information

Let's see a couple of examples

Let's see a couple of examples Javascript Examples Let's see a couple of examples Last 2 sessions we talked about Javascript Today: - Review Javascript basics by going through some examples - In the process we will also learn some new

More information

Developing Apps for the BlackBerry PlayBook

Developing Apps for the BlackBerry PlayBook Developing Apps for the BlackBerry PlayBook Lab # 4: Getting Started with Ajax and jquery Part 2 The objective of this lab is to continue reviewing some of the concepts in communication with external data

More information

Introduction to WEB PROGRAMMING

Introduction to WEB PROGRAMMING Introduction to WEB PROGRAMMING Web Languages: Overview HTML CSS JavaScript content structure look & feel transitions/animation s (CSS3) interaction animation server communication Full-Stack Web Frameworks

More information

Integers and Rational Numbers

Integers and Rational Numbers A A Family Letter: Integers Dear Family, The student will be learning about integers and how these numbers relate to the coordinate plane. The set of integers includes the set of whole numbers (0, 1,,,...)

More information

JAVASCRIPT. Computer Science & Engineering LOGO

JAVASCRIPT. Computer Science & Engineering LOGO JAVASCRIPT JavaScript and Client-Side Scripting When HTML was first developed, Web pages were static Static Web pages cannot change after the browser renders them HTML and XHTML could only be used to produce

More information

Place User-Defined Functions in the HEAD Section

Place User-Defined Functions in the HEAD Section JavaScript Functions Notes (Modified from: w3schools.com) A function is a block of code that will be executed when "someone" calls it. In JavaScript, we can define our own functions, called user-defined

More information

A Brief Introduction to a web browser's HTML. and the Document Object Model (DOM) Lecture 28

A Brief Introduction to a web browser's HTML. and the Document Object Model (DOM) Lecture 28 A Brief Introduction to a web browser's HTML and the Document Object Model (DOM) Lecture 28 Document Object Model (DOM) Web pages are, similarly, made up of objects called the Document Object Model or

More information

COMP1000 Mid-Session Test 2017s1

COMP1000 Mid-Session Test 2017s1 COMP1000 Mid-Session Test 2017s1 Total Marks: 45 Duration: 55 minutes + 10 min reading time This examination has three parts: Part 1: 15 Multiple Choice Questions (15 marks /45) Part 2: Practical Excel

More information

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100

Problem Description Earned Max 1 HTML / CSS Tracing 20 2 CSS 20 3 PHP 20 4 JS / Ajax / JSON 20 5 SQL 20 X Extra Credit 1 TOTAL Total Points 100 CSE 154, Autumn 2012 Final Exam, Thursday, December 13, 2012 Name: Quiz Section: Student ID #: TA: Rules: You have 110 minutes to complete this exam. You may receive a deduction if you keep working after

More information

University of Washington, CSE 190 M Homework Assignment 8: Baby Names

University of Washington, CSE 190 M Homework Assignment 8: Baby Names University of Washington, CSE 190 M Homework Assignment 8: Baby Names This assignment is about using Ajax to fetch data from files and web services in text, HTML, XML, and JSON formats. You must match

More information

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

LAB MANUAL SUBJECT: WEB TECHNOLOGY CLASS : T.E (COMPUTER) SEMESTER: VI

LAB MANUAL SUBJECT: WEB TECHNOLOGY CLASS : T.E (COMPUTER) SEMESTER: VI LAB MANUAL SUBJECT: WEB TECHNOLOGY CLASS : T.E (COMPUTER) SEMESTER: VI INDEX No. Title Pag e No. 1 Implements Basic HTML Tags 3 2 Implementation Of Table Tag 4 3 Implementation Of FRAMES 5 4 Design A FORM

More information

Coding in JavaScript functions

Coding in JavaScript functions Coding in JavaScript functions A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if

More information

PIC 40A. Lecture 4b: New elements in HTML5. Copyright 2011 Jukka Virtanen UCLA 1 04/09/14

PIC 40A. Lecture 4b: New elements in HTML5. Copyright 2011 Jukka Virtanen UCLA 1 04/09/14 PIC 40A Lecture 4b: New elements in HTML5 04/09/14 Copyright 2011 Jukka Virtanen UCLA 1 Sectioning elements HTML 5 introduces a lot of sectioning elements. Meant to give more meaning to your pages. People

More information

JavaScript: Events, the DOM Tree, jquery and Timing

JavaScript: Events, the DOM Tree, jquery and Timing JavaScript: Events, the DOM Tree, jquery and Timing CISC 282 October 11, 2017 window.onload Conflict Can only set window.onload = function once What if you have multiple files for handlers? What if you're

More information

This is an open-book, open-notes, open-computer exam. You may not consult with anyone other than the instructor while working on this exam.

This is an open-book, open-notes, open-computer exam. You may not consult with anyone other than the instructor while working on this exam. FINAL EXAM KEY SPRING 2016 CSC 105 INTERACTIVE WEB DOCUMENTS NICHOLAS R. HOWE This is an open-book, open-notes, open-computer exam. You may not consult with anyone other than the instructor while working

More information

Laboratory 1. Part 1: Introduction to Spreadsheets

Laboratory 1. Part 1: Introduction to Spreadsheets Laboratory 1 Part 1: Introduction to Spreadsheets By the end of this laboratory session you should be familiar with: Navigating around a worksheet. Naming sheets and cells. Formatting. The use of formulae.

More information

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5

Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5 Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives

More information

The first sample. What is JavaScript?

The first sample. What is JavaScript? Java Script Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. In this lecture

More information

Using Dreamweaver CS6

Using Dreamweaver CS6 Using Dreamweaver CS6 7 Dynamic HTML Dynamic HTML (DHTML) is a term that refers to website that use a combination of HTML, scripting such as JavaScript, CSS and the Document Object Model (DOM). HTML and

More information

Using Excel and HTML Files to Supplement Mathematics & Statistics

Using Excel and HTML Files to Supplement Mathematics & Statistics Using Excel and HTML Files to Supplement Mathematics & Statistics Annual Conference of North Carolina Mathematical Association of Two-Year Colleges Durham Technical Community College Durham, NC March 10-11,

More information

16. HTML5, HTML Graphics, & HTML Media 웹프로그래밍 2016 년 1 학기 충남대학교컴퓨터공학과

16. HTML5, HTML Graphics, & HTML Media 웹프로그래밍 2016 년 1 학기 충남대학교컴퓨터공학과 16. HTML5, HTML Graphics, & HTML Media 웹프로그래밍 2016 년 1 학기 충남대학교컴퓨터공학과 목차 HTML5 Introduction HTML5 Browser Support HTML5 Semantic Elements HTML5 Canvas HTML5 SVG HTML5 Multimedia 2 HTML5 Introduction What

More information

Using Dreamweaver CS6

Using Dreamweaver CS6 Using Dreamweaver CS6 4 Creating a Template Now that the main page of our website is complete, we need to create the rest of the pages. Each of them will have a layout that follows the plan shown below.

More information

Modules Documentation ADMAN. Phaistos Networks

Modules Documentation ADMAN. Phaistos Networks Modules Documentation ADMAN Phaistos Networks Table of Contents TABLE OF CONTENTS... 2 KEYWORDS... 5 FLASH BANNERS... 6 Options... 6 Public methods... 6 Public events... 6 Example... 7 EXPANDING BANNERS...

More information

static String usersname; public static int numberofplayers; private static double velocity, time;

static String usersname; public static int numberofplayers; private static double velocity, time; A class can include other things besides subroutines. In particular, it can also include variable declarations. Of course, you can declare variables inside subroutines. Those are called local variables.

More information

Purpose of this doc. Most minimal. Start building your own portfolio page!

Purpose of this doc. Most minimal. Start building your own portfolio page! Purpose of this doc There are abundant online web editing tools, such as wordpress, squarespace, etc. This document is not meant to be a web editing tutorial. This simply just shows some minimal knowledge

More information

Late Penalty: Late assignments will not be accepted.

Late Penalty: Late assignments will not be accepted. CPSC 449 Assignment 1 Due: Monday, October 16, 2017 Sample Solution Length: Less than 100 lines to reach the A- level, including some comments Approximately 130 lines with the fill color being influenced

More information

Programming language components

Programming language components Programming language components syntax: grammar rules for defining legal statements what's grammatically legal? how are things built up from smaller things? semantics: what things mean what do they compute?

More information

Web Design II. Location: Anderson Building (333 S. Broad St.) Rm 728 Dates: June 2 August 4 (Mondays, 6 9PM)

Web Design II. Location: Anderson Building (333 S. Broad St.) Rm 728 Dates: June 2 August 4 (Mondays, 6 9PM) Web Design II [Pick the date][type the sender company name] CE 2413 01 Summer 2014 Course Information Location: Anderson Building (333 S. Broad St.) Rm 728 Dates: June 2 August 4 (Mondays, 6 9PM) Instructor

More information

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17 PIC 40A Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers 04/24/17 Copyright 2011 Jukka Virtanen UCLA 1 Objects in JS In C++ we have classes, in JS we have OBJECTS.

More information

Web Programming/Scripting: JavaScript

Web Programming/Scripting: JavaScript CS 312 Internet Concepts Web Programming/Scripting: JavaScript Dr. Michele Weigle Department of Computer Science Old Dominion University mweigle@cs.odu.edu http://www.cs.odu.edu/~mweigle/cs312-f11/ 1 Outline!

More information

HTML/CSS Lesson Plans

HTML/CSS Lesson Plans HTML/CSS Lesson Plans Course Outline 8 lessons x 1 hour Class size: 15-25 students Age: 10-12 years Requirements Computer for each student (or pair) and a classroom projector Pencil and paper Internet

More information

Using Dreamweaver 2 HTML

Using Dreamweaver 2 HTML Using Dreamweaver 2 The World Wide Web is based on (Hypertext markup language). Although Dreamweaver is primarily a WYSIWYG editor, it is still worthwhile for Dreamweaver users to be familiar with for

More information

CIS 408 Internet Computing Sunnie Chung

CIS 408 Internet Computing Sunnie Chung Project #2: CIS 408 Internet Computing Sunnie Chung Building a Personal Webpage in HTML and Java Script to Learn How to Communicate Your Web Browser as Client with a Form Element with a Web Server in URL

More information

Sample CS 142 Midterm Examination

Sample CS 142 Midterm Examination Sample CS 142 Midterm Examination Spring Quarter 2016 You have 1.5 hours (90 minutes) for this examination; the number of points for each question indicates roughly how many minutes you should spend on

More information

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 8. Worksheets for Intervention Classes

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 8. Worksheets for Intervention Classes The City School PAF Chapter Prep Section ICTech Class 8 2 nd Term Worksheets for Intervention Classes Name: Topic: Flowchart Date: Q. Write the name and description of the following symbol. Symbol Name

More information

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 7. Worksheets for Intervention Classes

The City School. Prep Section. ICTech. 2 nd Term. PAF Chapter. Class 7. Worksheets for Intervention Classes The City School PAF Chapter Prep Section ICTech Class 7 2 nd Term Worksheets for Intervention Classes Name: Topic: Scratch Date: Q.1: Label the diagram 1 2 3 4 5 6 7 12 8 9 11 10 1. 2. 3. 4. 5. 6. 7. 8.

More information

Taking Fireworks Template and Applying it to Dreamweaver

Taking Fireworks Template and Applying it to Dreamweaver Taking Fireworks Template and Applying it to Dreamweaver Part 1: Define a New Site in Dreamweaver The first step to creating a site in Dreamweaver CS4 is to Define a New Site. The object is to recreate

More information

Cascading style sheets

Cascading style sheets Cascading style sheets The best way to create websites is to keep the content separate from the presentation. The best way to create websites is to keep the content separate from the presentation. HTML

More information

CSE 115. Introduction to Computer Science I

CSE 115. Introduction to Computer Science I CSE 115 Introduction to Computer Science I Announcements Dr. Alphonce's e-mail glitched: not all unread e-mails were shown. Please be patient while he catches up. Announcements A sample midterm exam will

More information

OU EDUCATE TRAINING MANUAL

OU EDUCATE TRAINING MANUAL OU EDUCATE TRAINING MANUAL OmniUpdate Web Content Management System El Camino College Staff Development 310-660-3868 Course Topics: Section 1: OU Educate Overview and Login Section 2: The OmniUpdate Interface

More information

Assigning an Assessment for Online Delivery in Edusoft

Assigning an Assessment for Online Delivery in Edusoft Assigning an Assessment for Online Delivery in Edusoft The ability to assign assessments for online delivery depends on your level of access to Edusoft. Only the designated Edusoft Account Administrator

More information

Web Site Development with HTML/JavaScrip

Web Site Development with HTML/JavaScrip Hands-On Web Site Development with HTML/JavaScrip Course Description This Hands-On Web programming course provides a thorough introduction to implementing a full-featured Web site on the Internet or corporate

More information

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from BEFORE CLASS If you haven t already installed the Firebug extension for Firefox, download it now from http://getfirebug.com. If you don t already have the Firebug extension for Firefox, Safari, or Google

More information

Block & Inline Elements

Block & Inline Elements Block & Inline Elements Every tag in HTML can classified as a block or inline element. > Block elements always start on a new line (Paragraph, List items, Blockquotes, Tables) > Inline elements do not

More information