Download - Basic html5 and javascript

Transcript
Page 1: Basic html5 and javascript

HTML5

Mark GutierrezWeb & Mobile DeveloperTowers Watson Inc.

Page 2: Basic html5 and javascript

Expectations?

2

Page 3: Basic html5 and javascript

3

Agenda

What is HTML5 Features Adoption Is HTML5 ready Now? Changes from previous HTMLs

What’s addedWhat’s deprecated

Exercise

Page 4: Basic html5 and javascript

What is HTML5?

HTML5 is is a language for structuring and presenting content for the World Wide Web, a core technology of the Internet. It is the fifth revision of the HTML standard (originally created in 1990 and most recently standardized as HTML4 in 1997[1]) and as of August 2011[update] is still under development. Its core aims have been to improve the language with support for the latest multimedia while keeping it easily readable by humans and consistently understood by computers and devices (web browsers, parsers etc.). HTML5 is intended to subsume not only HTML4, but XHTML1 and DOM2HTML (particularly JavaScript) as well.

4

Page 5: Basic html5 and javascript

Adoption

The biggest names in the Industry Disney Research In Motion Google Apple Microsoft

5

Page 6: Basic html5 and javascript

Is HTML5 ready now?Yes and No.

HTML5 is now ready for use by developers provided they use fallbacks since the specification for HTML5 is not yet finalized. According to the W3C, HTML5 is still in Draft. So expect changes to happen anytime. The expected completion is 2022 or later. Although many parts of the specifications are already stable and may be implemented.

6

Page 7: Basic html5 and javascript

What’s New Markup

FormsMultimediaGraphics

New APIsGraphicsMedia PlaybackGeoLocationWeb SocketsWeb Workers

Error Handling

7

Page 8: Basic html5 and javascript

Deprecated TagsLike any other evolving technologies. HTML5 also deprecates some outdated tags such as:basefontbigcenterfontsstrikettUframeframesetnoframes

8

Attributes:

• align• link, vlink, alink, and text attributes on the body tag• bgcolor• height and width• scrolling on the iframe element• valign• hspace and vspace• cellpadding, cellspacing, and border on table

Page 9: Basic html5 and javascript

New Structural Tags

<header> - Defines a header region of a page or section.

<footer> - Defines a footer region of a page or section.

<nav> - Defines a navigation region of a page or section.

<section> - Defines a logical region of a page or a grouping of content.

<article> - Defines an article or complete piece of content.

<aside> - Defines secondary or related content.

9

Page 10: Basic html5 and javascript

Form TagsNew Input Tags

<input type=“range”>

<input type=“number”>

<input type=“date”>

<input type=“email”>

<input type=“url”>

<input type=“color”>

<input type=“Search”>

10

Page 11: Basic html5 and javascript

Range Input

<input type="range" min="0" max="10"

name="priority" value="0" id="priority" >

11

Page 12: Basic html5 and javascript

Number Input

<input type="number" name="estimated_hours"

min="0" max="1000“ id="estimated_hours" >

12

Page 13: Basic html5 and javascript

Date Input

<input type="date" name="start_date" id="start_date"

value="2010-12-01" >

13

Page 14: Basic html5 and javascript

Email Input

<input type="email" name="email" id="email">

14

Page 15: Basic html5 and javascript

URL Input

<input type="url" name="url" id="url">

15

Page 16: Basic html5 and javascript

Color Input

<input type="color" name="project_color" id="project_color">

16

Page 17: Basic html5 and javascript

Search Input

<input type=“search” name=“textsearch” id=“searchfield” >

17

Page 18: Basic html5 and javascript

Tel Input

<input type="range" min="0" max="10"

name="priority" value="0" id="priority" >

18

Page 19: Basic html5 and javascript

Multimedia Support

Multimedia has become an integral part of our internet usage thus, HTML5 added support for both Video and Audio <Video> <Audio>

19

Page 20: Basic html5 and javascript

Audio SupportSupport for MP3, AAC, OGG

<audio id="drums" controls>

<source src="sounds/ogg/drums.ogg" type="audio/ogg">

<source src="sounds/mp3/drums.mp3" type="audio/mpeg">

<a href="sounds/mp3/drums.mp3">Download drums.mp3</a>

</audio>

20

Page 21: Basic html5 and javascript

Video SupportSupport for MP4, OGV, WebM format

<video controls> <source src="video/h264/01_blur.mp4"> <source src="video/theora/01_blur.ogv"> <source src="video/webm/01_blur.webm"> <p>Your browser does not support the video tag.</p></video> 21

Page 22: Basic html5 and javascript

GraphicsSupports creation of vector based graphics through the use of javascript

<canvas id="myCanvas">your browser does not support the canvas tag </canvas>

<script type="text/javascript">

var canvas=document.getElementById('myCanvas');

var ctx=canvas.getContext('2d');

ctx.fillStyle='#FF0000';

ctx.fillRect(0,0,80,100);

</script>

22

Page 23: Basic html5 and javascript

Questions?

23

Page 24: Basic html5 and javascript

HTML5 AND JAVASCRIPT

Page 25: Basic html5 and javascript

Agenda

New DOM Selectors Audio and Video Using the Canvas Knowing your Location Web Sockets

Page 26: Basic html5 and javascript

Essence of JS on HTML5? No minimum system requirements Easier to code Faster execution/response Extends the ability The completeness of HTML5

Page 27: Basic html5 and javascript

Select What?

getElementById() getElementsByTagName() getElementsByClassName() querySelector() querySelectorAll()

Page 28: Basic html5 and javascript

Wait, there’s no light and there’s no flash! How’s our party?

Page 29: Basic html5 and javascript

Audio and Video

Media FunctionsPlay()Pause()Load()

Page 30: Basic html5 and javascript

Audio and Video cont. Media Properties

VolumeDurationMutedPausedLoop

Page 31: Basic html5 and javascript

Audio and Video cont. Events

PlayPauseAbortEndedProgress

Page 32: Basic html5 and javascript

Ready your brushes… Drawing in the canvas

Preparing your workspaceCreating a simple path

○ beginPath();○ lineTo();○ moveTo();○ Stroke();

Page 33: Basic html5 and javascript

Ready your brushes… cont. Drawing simples shapes

Circle○ Arc();

Square○ fillRect();

Page 34: Basic html5 and javascript

Faster script, faster!

Web workersseparate JS processes() running in separate

threads,executes concurrently,doesn’t block the UI,allow you to extract up to the last drop of

juice from a multicore CPU,can be dedicated (single tab) or shared

among tabs/windows,

Page 35: Basic html5 and javascript

Working for one purpose

MainProc.js

Workers1.js

Workers2.js

Workers3.js

Page 36: Basic html5 and javascript

Web workers cont…

Put it to worknew Worker();onmessage();postmessage();

Page 37: Basic html5 and javascript

Where am I?

Using GeolocationRemember: Always ask for permission!I have no GPS!

○ IPAddress○ WiFi○ Cellphone

Page 38: Basic html5 and javascript

Location pls.

Hey! Mr. Navigator…coords.latitudecoords.longitudegetCurrentPosition()

Page 39: Basic html5 and javascript

Web Sockets

Communicate in a whole new wayTCP over the Web2-way communication for the Internet

○ Use a client browser that implements the WebSocket protocol.

○ Write code in a webpage that creates a client websocket.

○ Write code on a web server that responds to a client request through a websocket

Page 40: Basic html5 and javascript

Web Sockets

Tuning inURLwebsocket()open(), onopenclose(), oncloseonmessage()postmessage()

Page 41: Basic html5 and javascript

Remember…

Consider older browsersDetect BrowserDetect Feature availability

Page 42: Basic html5 and javascript

Thank you