Escolar Documentos
Profissional Documentos
Cultura Documentos
• HTML 5
<meta charset="utf-8">
STYLESHEET
• <link rel="stylesheet" href="style-
original.css" type="text/css" />
• HTML 5
<link rel="stylesheet"
href="style-original.css" />
ELEMENTE NOI IN HTML5
Elementul Base
<head>
<base href=“url” target="_blank" />
</head>
-se introduce adresa de baza.
Elemente semantice de
sectionare
• HTML 4
Elemente semantice de
sectionare
• HTML 5
<HEADER>
HTML 4
<div id="header">
<h1>My Weblog</h1>
<p class="tagline">A lot of effort went into
making this effortless.</p>
</div>
HTML 5
<header>
<h1>My Weblog</h1>
<p class="tagline">A lot of effort went
into making this effortless.</p> …
</header>
<HGROUP>
HTML 4
<h1>My Weblog</h1>
<h2>A lot of effort went into making
this effortless.</h2>
HTML 5
<header>
<hgroup>
<h1>My Weblog</h1> <h2>A lot of effort
went into making this ffortless.</h2>
</hgroup> …
</header>
<FOOTER>
HTML 4
<div id="footer">
<p>§</p> <p>© 2001–9
<a href="#">Mark Pilgrim</a></p>
</div>
HTML 5
<footer>
<p>§</p>
<p>© 2001–9
<a href="#">Mark Pilgrim</a>
</p>
</footer>
<SECTION>
• HTML 5 (sectiune generica de aplicatie sau document)
<section>
<h1>Level 1</h1> <section> <h1>Level 2</h1>
<section> <h1>Level 3</h1> </section>
</section>
<ARTICLE>
HTML 4
<div class="entry">
<p class="post-date">October 22, 2009</p> <h2>
<a href="#" rel="bookmark" title="link to this
post"> Travel day </a> </h2>
</div>
HTML 5
<article>
<header>
<p class="post-date">October 22, 2009</p>
<h1> <a href="#" rel="bookmark" title="link to this
post"> Travel day </a> </h1> </header> …
</article>
<ASIDE>
HTML5
<aside>
<h1>Archives</h1>
<ul>
<li><a href="/2007/09/">September 2007</a></li>
<li><a href="/2007/08/">August 2007</a></li>
<li><a href="/2007/07/">July 2007</a></li>
</ul>
</aside>
<NAV>
HTML 4 HTML 5
<nav>
<div id="nav"> <ul>
<ul> <li><a
<li><a href="#">home</a></li>
<li><a
href="#">home</a></li> href="#">blog</a></li>
<li><a <li><a
href="#">blog</a></li> href="#">gallery</a></
<li><a li>
href="#">gallery</a></li> <li><a
href="#">about</a></li
<li><a >
href="#">about</a></li> </ul>
</ul> </nav>
</div>
<TIME>
• <time datetime="2009-10-22" pubdate>October 22,
2009</time>
• <time datetime="2009-10-22T13:59:47-04:00" pubdate>
October 22, 2009 1:59pm EDT </time>
• <article>
<header>
<time datetime="2009-10-22" pubdate> October 22, 2009 </time>
<h1> <a href="#" rel="bookmark" title="link to this post"> Travel day </a>
</h1>
</header>
<p>Lorem ipsum dolor sit amet…</p>
</article>
Exemple
• Exemplul1.html
a resolution-dependent bitmap canvas which can be used
for rendering graphs, game graphics, or other visual
images on the fly.
}
<CANVAS>
Desenarea in Canvas Context:
Sunt esentiale functiile:
beginPath()
closePath()
stroke()
fill()
Proprietati:
fillStyle = (CSS color,pattern,gradient)
strokeStyle= (CSS color,pattern,gradient)
<CANVAS>
• Alte functii de desenare in canvas context
o Desenare dreptunghiuri
• fillRect(x, y, width, height)
• strokeRect(x, y, width, height)
• clearRect(x, y, width, height)
o Desenare linii
o moveTo(x, y)
o lineTo(x, y)
<CANVAS>
o Desenare arce
• arc(x, y, radius, startAngle, endAngle, anticlockwise)
(pentru cerc startAngle=0, endAngle=Math.pi*2)
• quadraticCurveTo(cp1x, cp1y, x, y)
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)
• x,y coordonatele punctului de sfarsit
• cp1x,cp1y, cp2x,cp2y coordonatele primului si celui de al doilea punct de control.
Desenarea de text
o Proprietati context:
Context.font= {font}
Context.textAlign={start,end,left,right,center};
Context.textBaseline={top,hanging,middle,alphabetic,ideographic,bottom};
o Functia de desenare
o Context.fillText(text,x,y);
<CANVAS>
o Crearea unui gradient
• createLinearGradient(x0, y0, x1, y1)
• createRadialGradient(x0, y0, r0, x1, y1, r1)
• Exemple gradient:
1. var my_gradient = context.createLinearGradient(0, 0, 300, 0);
my_gradient.addColorStop(0, "black");
my_gradient.addColorStop(1, "white");
context.fillStyle = my_gradient;
context.fillRect(0, 0, 300, 225);
<CANVAS>
2. var my_gradient = context.createLinearGradient(0, 0, 0, 225);
my_gradient.addColorStop(0, "black");
my_gradient.addColorStop(1, "white");
context.fillStyle = my_gradient;
context.fillRect(0, 0, 300, 225);
• Scalarea: scale(x, y)
• Umbre
• Proprietati context:
• ShadowColor
• ShadowOffsetX
• ShadowOffsetY
• ShadowBlur
Exemple <CANVAS>
• http://html5demos.com/canvas-grad [FF]
• First person gifter
http://htmlfive.appspot.com/static/gifter.html [FF]
HTML5 API VIDEO & AUDIO
HTML5 API VIDEO & AUDIO
• Continut media fara plugin
• Multitudine de formate video:
• MPEG4
• FLASH VIDEO
• OGG
• AUDIO VIDEO INTERLACED
• HTML 4:
<video src="video.ogg">
<object data="videoplayer.swf" type="application/x-shockwave-
flash">
<param name="movie" value="video.swf"/>
</object>
</video>
HTML5 API VIDEO & AUDIO
• HTML5
<video src="video.ogg" controls>
Your browser does not support HTML5 video.
</video>
<audio controls src="johann_sebastian_bach_air.ogg">
An audio clip from Johann Sebastian Bach.
</audio> <video width="320" height="240" controls>
<source src="pr6.mp4" type='video/mp4;
• Functii media codecs="avc1.42E01E, mp4a.40.2"'>
<source src="pr6.webm" type='video/webm;
• Load() codecs="vp8, vorbis"'>
<source src="pr6.ogv" type='video/ogg;
• Play() codecs="theora, vorbis"'>
</video>
• Pause()
• canPlayType(type) <audio controls>
<source src="johann_sebastian_bach_air.ogg">
<source src="johann_sebastian_bach_air.mp3">
An audio clip from Johann Sebastian Bach.
</audio>
HTML5 API VIDEO & AUDIO
• Atribute ReadOnly
• Duration
• Paused
• Ended
• startTime
• Error
• currentSrc
• Atribute ce pot fi folosite in Javascript
• Autoplay
• Loop
• currentTime
• Controls
• Volume (0.0-1.0)
• Muted
• Preload
• Atribute legate de format
• Type=formatul containerului (e.g video/mp4);
• Codecs=“video codec, audio codec”.
Exemple audio/video
• Exemple/av
• Player HTML5 al fisierelor audio locale
http://antimatter15.github.com/player/player.html
HTML5 API - GEOLOCATIE
O noua proprietate a obiectului global navigator:
• Navigator.geoLocation
• Detecteaza locatia utilizatorului curent utilizand urmatoarele
informatii:
• -Adresa IP
• -Conexiunile la retele wireless
• -Turnul de comunicatii cu care comunica telefonul
• -hardware GPS
HTML5 API - GEOLOCATIE
• Exemplu de implementare:
function get_location() {
navigator.geolocation.getCurrentPosition(show_map); }
//determina afisarea unei bare de informatii ce intreaba
utilizatorul daca doreste sa isi dezvaluie locatia sa.
//show_map ->functia de callback
function show_map(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// let's show a map or do something interesting! }
HTML5 API - GEOLOCATIE
Exemplu de tratarea a erorilor:
navigator.geolocation.getCurrentPosition( show_map, handle_error)
function handle_error(err)
{ if (err.code == 1) { // user said no! } }
• handle_error este un obiect ce contine urmatoarele proprietati:
• code short an enumerated value
• PERMISSION_DENIED (1)
• POSITION_UNAVAILABLE (2)
• TIMEOUT (3)
• UNKNOWN_ERROR (0)
Exemplu de implementare
//pentru a crea un obiect baza de date
var db = window.openDatabase("NoteTest", "1.0","Example DB",200000);
function renderNote(row) {
// renders the note somewhere }
WEB WORKERS
WEB WORKERS
• Javascript ruleaza pe acelasi fir de executie cu browserul ceea ce poate face ca acesta din
urma sa nu mai poata raspunde la comenzile utilizatorului.
• „Muncitorii” Web definesc un API ce ruleaza scripturile in background.
• ! „muncitorii” trebuie sa se afle intr-un script extern.
• Exemplu de implementare
<script>
var worker = new Worker('worker.js');
worker.onmessage = function (event) {
console.log('Results: ' + event.data);
};
</script>
Muncitorii:
function findPrimes() {
// ... prime algorithm here
postMessage(nextPrime);
}
findPrimes();
EXEMPLU WEB WORKERS
• http://htmlfive.appspot.com/static/tracker1.html Motion tracker
• http://htmlfive.appspot.com/static/primes-good.html Good Primes
• http://htmlfive.appspot.com/static/primes-bad.html Bad Primes
Compatiblitatea browserelor
Ce mai ofera HTML5?
• Trasaturi noi formularelor (validare la nivelul clientului, date
pickers, sliders)
• Socket-uri Web
• Web storage
• Alte tag-uri noi
• Manipularea istoricului browserului
• Drag and Drop
Compatibilitatea browserelor
http://www.findmebyip.com/litmus/
Concluzii
• HTML5 stie unde te afli, stie ce scrii, unde esti si unde ai fost.
• HTML5 este viitorul si desi inca nu a ajuns la un stadiu final (se
preconizeaza ca in jurul anului 2022) el poate fi implementat si
utilizat in cadrul browserelor moderne.
Bibliografie
• Pro HTML5 Programming - Powerful APIs for Richer Internet
Application Development (Peter Lubbers, Brian Albers and
Frank Salim)
• Introduction cu HTML5 (Brad Neuberg)
• W3C HTML 5 Working Draft
• Dive into HTML5 (Mark Pilgrim)