JavaScript Programming B.Ramamurthy 6/113/2014B. Ramamurthy CSE6511.

Slides:



Advertisements
Similar presentations
1/7 ITApplications XML Module Session 8: Introduction to Programming with XML.
Advertisements

JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
Emerging technology and Platform#3: JavaScript Bina Ramamurthy.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
JavaScript 101 Lesson 01: Writing Your First JavaScript.
Web Page Development Identify elements of a Web Page Start Notepad
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Inline, Internal, and External FIle
® IBM Software Group © 2006 IBM Corporation JSF Tab Controls This Learning Module shows how to develop server-side EGL applications with dynamic content.
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 02 Types of Programming Language.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
BUILDING A FACEBOOK APP. STEP 1 Create a Developers License. Make sure to take note/record the app id/key.
JavaScript & jQuery the missing manual Chapter 11
Emerging Applications and Platform#3: JavaScript Bina Ramamurthy 7/4/2015CSE651C, B. Ramamurthy1.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
Google Maps API. Static Maps send an HTTP GET request receive an image (PNG, GIF, JPEG) no javascript needed encode params in URL example:
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Lecture 6 Rachel A Ober
DOM and JavaScript Aryo Pinandito.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
Javascript: More features B. Ramamurthy 7/4/2014B. Ramamurthy, CSE651C1.
Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
WEB API: WHY THEY MATTER ECOL 453/ Nirav Merchant
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Tutorial 10 Programming with JavaScript
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Computers and Scientific Thinking David Reed, Creighton University Functions and Libraries 1.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Working with Files. Learning Objectives By the end of this lecture, you should be able to: – Examine a file that contains code with unfamiliar material,
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
Modified from Moseley ’s sli desWeb Applications Development. Lecture 3 Slide 1 Lecture 3: Dynamic Web Pages – Introduction to JavaScript Instructor: Dr.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
12/7/2015B.Ramamurthy1 Exam2 Review CSE111 B.Ramamurthy.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
® IBM Software Group © 2006 IBM Corporation JSF Rich Text Area Component This Learning Module describes the use of the JSF Rich Text Area component – for.
Session 2: Basic HTML HTML Coding Spring 2009 The LIS Web Team Presents.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript Introduction inf385t Semantic Web 2/20/2006.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
XML DOM Week 11 Web site:
HTML Tutorial. What is HTML HTML is a markup language for describing web documents (web pages) HTML documents are described by HTML tags Each HTML tag.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
1 Using the Google Maps JavaScript API. 2 The Google Maps APIs Permit web applications to use functionality of google maps. Documentation:
Point Maps Peterson’s Chapter 11 & 12. Points and Point Maps Points – Datum and coordinate systems – geocoding Point Maps – Show where points are (just.
DHTML.
Programming Web Pages with JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Unit M Programming Web Pages with
Unit M Programming Web Pages with
The Document Object Model (DOM) is a W3C standard.
Exam3 Review CSE111 B.Ramamurthy 7/28/2018 B.Ramamurthy.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Introduction to JavaScript
JavaScript Programming Labs
Javascript and JQuery SRM DSC.
Introduction to Programming and JavaScript
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Presentation transcript:

JavaScript Programming B.Ramamurthy 6/113/2014B. Ramamurthy CSE6511

6/113/2014B. Ramamurthy CSE6512 Why JavaScript?

 JSON: Javascript Object notation  JSON based data exchange; JSON based webservices  From  JSON is built on two structures:  A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.  An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.  These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures. 6/113/2014B. Ramamurthy CSE6513 Why JavaScript? (contd.)

 Numerous third party libraries for data processing and visualization.  See this recent publication from IBM: JavaScript Everywhere and Three Amigos: Sept.2013 article by J. Cuomo  o/entry/javascript_everywhere_and_the_three_amigos?lang=en o/entry/javascript_everywhere_and_the_three_amigos?lang=en  Also look at Google Maps JavaScript library: script/ 6/113/2014B. Ramamurthy CSE6514 Why JavaScript? (Contd.)

Google Maps Example <script src=" var map; function initialize() { var mapOptions = { zoom: 8, center: new google.maps.LatLng(42.9, -79.8), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); } 6/113/2014B. Ramamurthy CSE6515 Try this code: in notepad++ save as ex3.html

 Now change the lat,long as shown below:  google.maps.LatLng(12.9, 77.56)  Change the lat long to (27.9, 86.9) 6/113/2014B. Ramamurthy CSE6516 More lat.long

 Lets learn some more features of JS and also how to power an application using JS functions.  Also we want to structure our applications in a modular fashion: no mix of HTML, CSS and JS: three separate files  Lets do that for this Google Map example 6/113/2014B. Ramamurthy CSE6517 On to JavaScript

 Lets add some widgets like buttons and textboxes and power them using JS functions  Only that we will separate the widgets and function in html and js file separately 6/113/2014B. Ramamurthy CSE6518 HTML+JS

6/113/2014B. Ramamurthy CSE6519 What do you? How will you center this panel/canvas for displaying the widgets? ex4.html

 Add a button within the dvi tags as shown below: understand the various properties of the button widget. 6/113/2014B. Ramamurthy CSE65110 Lets add some widgets

 Lets write a simple javascript and link it to the main html code  Simple Javascript file has these components 1.Data area 2.Functions  Lets add js function to the button. Save the code below in ex4.js and modify ex4.html to link to this file (as shown in the next slide) function first() { alert (" Button was clicked!"); } 6/113/2014B. Ramamurthy CSE65111 Lets respond to the click

 6/113/2014B. Ramamurthy CSE65112 Changes in ex4.html

 The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.  It is hierarchical. Here is the for the html table. 6/113/2014B. Ramamurthy CSE65113 Document Object Model (DOM)

document table iddiv id button id form id/index 6/113/2014B. Ramamurthy CSE65114 DOM for general HTML document

 In the HTML DOM (Document Object Model), everything is a node:  The document itself is a document node  All HTML elements are element nodes  All HTML attributes are attribute nodes  Text inside HTML elements are text nodes  Comments are comment nodes 6/113/2014B. Ramamurthy CSE65115 DOM nodes

 Using the DOM structure we can refer to the various elements of the html document using “OO” dot notation  Example: add this line to first function in the ex4.js file document.write (“Hello everyone!”); Save and run the e4.html 6/113/2014B. Ramamurthy CSE65116 DOM usage

 Many useful DOM objects are available; One that s of use to us is the Math object  You can use most any math function:  var x = Math.PI; // Returns PI  var y = Math.sqrt(64); // Returns the square root of 64 6/113/2014B. Ramamurthy CSE65117 DOM objects

 Lets add a text box, do some computation in the javascript and return to the document  Start a new exercise  Save ex4.html as ex5.html, ex4,js as ex5.js  Modify ex4.html to have a textbox element  Change the button to Get Random Number  Make sure to change script file linked to ex5.js  We have also introduced the “form” tag, that is a very useful tag  As shown in the code next 6/113/2014B. Ramamurthy CSE65118 Lets do some computation

 6/113/2014B. Ramamurthy CSE65119 Ex5.html

var rnum; function myrand() { alert (" Button was clicked!"); rnum = Math.floor(Math.random()*100 ); // a number between 0-99 inclusive alert(rnum); document.forms[0].randomNumber.value = rnum; } 6/113/2014B. Ramamurthy CSE65120 Ex5.js

 Where do the analytics come in?  Lets now make an application with html and js that is driven by one of our simplest statistical models: linear regression  This is basically a template for any other application you may write. 6/113/2014B. Ramamurthy CSE65121 JS driven by Analytics Html interface Javascript functions Analytics

 Lets plan the interface: y = a + bx  We need input boxes for a, b and x and an output box for displaying the result in y  A button to start the analytics (simple in this case)  Like mentioned before this example is simply a template, the analytics could me more complex than this.  This is an in-class exercise for you. 6/113/2014B. Ramamurthy CSE65122 Linear regression Application

 We looked basic features of Javascript working with html input interface  Any analytics module can be easily be made to power this workflow that we studied / practiced in this session  Study the material/paper given in the reference for more information on javascript. 6/113/2014B. Ramamurthy CSE65123 Summary

 Third Party JavaScript book  DOM standard: DOM /introduction.htmlhttp:// DOM /introduction.html  DOM: w3schools.com 6/113/2014B. Ramamurthy CSE65124 References