HTML5 – Hypertext Markup Language Version 5 – Themes



HTML5 – Hypertext Markup Language Version 5 – Themes

0 0


HTML5-Presentation

HTML5 Presentation & Examples

On Github cminhho / HTML5-Presentation

HTML5

Hypertext Markup Language Version 5

Created by hmchung / @tma.com.vn

Themes

Default - Sky - Beige - Simple - Serif - Night Moon - Solarized

Transition Styles

Cube - Page - Concave - Zoom - Linear - Fade - None - Default

Rough Timeline of Web Technologies

1991 HTML 1994 HTML 2 1996 CSS + JavaScript 1997 HTML 4 1998 CSS2 2000 XHTML 1 2002 Tableless Web Design 2005 AJAX 2009 HTML5 + CSS3

What is HTML5?

It’s open source. Standard technology (WHATWG + W3C). Successor of HTML v4.01 & XHTML v1.0 Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).

HTML5

~=

HTML

+ CSS

+ JS

Definition and Usage

HTML5

< !DOCTYPE HTML>

HTML 4.01 Strict

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

HTML 4.01 Transitional

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

Key Features of HTML5

Feature tag

Browsers

Today, we will cover...

Multimedia Realtime / Communication File / Hardware Access Semantics & Markup Graphics / Multimedia

Today, we will cover ...

Offline / Storage

Realtime / Communication

File / Hardware Access

Today, we will cover ...

Graphics / Multimedia

Semantics & Markup

CSS3

Offline / Storage

Web Storage

main.js
//LocalStorage Methods: 
//getItem: Retrieves the current value associated with the key.
	window.localStorage.getItem(key)
//setItem: Set a key/value pair
	window.localStorage.setItem(key, value);
//removeItem: Deletes a key/value pair from the DOM Storage collection
	window.localStorage.removeItem(key)
//clear: Removes all key/value pairs from the DOM Storage area.
	window.localStorage.clear();
//Key: Retrieves the key at the specified index in the collection
	window.localStorage.key(n)
//length: Retrieves the length of the key/value list
 constructor: Returns a reference to the contructor
	window.localStorage.contructor !== Storage
Save

Web SQL Database

main.js
// Creating and Opening a Database						
var db = window.openDatabase("DBTest", "1.0", "HTML5 Database API", '200000');
db.transaction(function(tx) {
  // Executing SQL Statements
  tx.executeSql("SELECT * FROM test", [], successCallback, errorCallback);
  
  // Creating table
  tx.executeSql("CREATE TABLE Employee (id REAL UNIQUE, text TEXT)", [], function(tx) {
    log.innerHTML = '<p>"Employee" created!</p>' },onError);
  });
  
  // Accessing  SQL Statements
  tx.executeSql("INSERT INTO Employee (id, text) VALUES (?, ?)", [number, "Value"],function(tx, result) {},onError);
  
  tx.executeSql("SELECT * FROM Employee", [], function(tx, result) {
    // TODO
  });
});
New to do item Create table Drop table

IndexedDB

main.js
var idbRequest = window.indexedDB.open('Database Name');
idbRequest.onsuccess = function(event) {
  var db = event.srcElement.result;
  var transaction = db.transaction([], IDBTransaction.READ_ONLY);
  var curRequest = transaction.objectStore('ObjectStore Name').openCursor();
  curRequest.onsuccess = ...;
};
Set Create objectStore Remove objectStore

Application Cache

index.html
< html manifest="cache.appcache" >
main.js
window.applicationCache.addEventListener('updateready', function(e) {
  if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
    window.applicationCache.swapCache();
    if (confirm('A new version of this site is available. Load it?')) {
      window.location.reload();
    }
  }
}, false);
cache.appcache:
CACHE MANIFEST
# version 1.0.0

CACHE:
/html5/src/logic.js
/html5/src/style.css
/html5/src/background.png

NETWORK:
*

Quota API

main.js
// Request Status
webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY, function(used, remaining) {
    console.log("Used quota: " + used + ", remaining quota: " + remaining);
  }
);

// Request Quota (only for File System API)
webkitStorageInfo.requestQuota(webkitStorageInfo.PERSISTENT, 10 * 1024 * 1024, function(used) {
    console.log("Used quota: " + used + ", remaining quota: " + remaining);
  }
);

Realtime / Communication

Web Workers

index.html
<p>Count numbers: <output id="result"></output></p>
main.js
var worker = new Worker('task.js');
worker.onmessage = function(event) { 
  document.getElementById("result").innerHTML = event.data;
};
task.js
var i=0;
function timedCount() {
    i=i+1;
    postMessage(i);
    setTimeout("timedCount()", 500);
}
timedCount();

Count numbers:

Start Worker Stop Worker Test

WebSocket

main.js
var socket = new WebSocket('ws://html5rocks.websocket.org/echo');
socket.onopen = function(event) {
  socket.send('Hello, WebSocket');
};
socket.onmessage = function(event) { alert(event.data); }
socket.onclose = function(event) { alert('closed'); }
https://www.websocket.org/echo.html

Notifications

main.js
Notification.requestPermission(function(permission){
  var notification = new Notification("Hi there!",{
    body:'I am here to talk about HTML5 Web Notification API',icon:'icon.png',dir:'auto'
  });
  
  setTimeout(function(){
    notification.close();
  },2000);
});
Notify me!

File / Hardware Access

Native Drag & Drop

index.html
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
  <img id="drag1" src="img/html5_logo_lrg.png" draggable="true" ondragstart="drag(event)">								</div>
main.js
function allowDrop(ev) {
  ev.preventDefault();
}

function drag(ev) {
  ev.dataTransfer.setData("text", ev.target.id);
}

function drop(ev) {
  ev.preventDefault();
  var data = ev.dataTransfer.getData("text");
  ev.target.appendChild(document.getElementById(data));
}
					

Desktop Drag-In (File API)

main.js
document.querySelector('#dropzone').addEventListener('drop', function(e) {
  var reader = new FileReader();
  reader.onload = function(evt) {
    document.querySelector('img').src = evt.target.result;
  };

  reader.readAsDataURL(e.dataTransfer.files[0]);
}, false);
					
Drop in images from your desktop

Geolocation

main.js
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    var latLng = new google.maps.LatLng(
        position.coords.latitude, position.coords.longitude);
    var marker = new google.maps.Marker({position: latLng, map: map});
    map.setCenter(latLng);
  }, errorHandler);
}
					
https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
Show Position

Semantics & Markup

Better semantic tags

HTML

HTML5

http://www.w3schools.com/html/html5_semantic_elements.asp

Markup for applications

http://www.w3schools.com/html/html5_new_elements.asp
<input list="cars">
<datalist id="cars">
  <option value="BMW">
  </option><option value="Ford">
  </option><option value="Volvo">
</option></datalist>
<details>
  <summary>HTML 5</summary>
  This slide deck teaches you everything you need to know about HTML 5.
</details>
HTML 5 This slide deck teaches you everything you need to know about HTML 5.
<meter min="0" max="100" low="40" high="90" optimum="100" value="91">A+</meter>
Your score is: A+
Your score is: <progress>working...</progress>
Download is: working...
<progress>working...</progress>
Goal is: 3/4 complete

Descriptive link relations

<pre>index.html</pre>
<link rel="alternate" type="application/rss+xml" href="http://myblog.com/feed">
<link rel="icon" href="/favicon.ico">
<link rel="pingback" href="http://myblog.com/xmlrpc.php">
<link rel="prefetch" href="http://myblog.com/main.php">
...

<a rel="archives" href="http://myblog.com/archives">old posts</a>
<a rel="external" href="http://notmysite.com">tutorial</a>
<a rel="license" href="http://www.apache.org/licenses/LICENSE-2.0">license</a>
<a rel="nofollow" href="http://notmysite.com/sample">wannabe</a>
<a rel="tag" href="http://myblog.com/category/games">games posts</a>
http://en.wikipedia.org/wiki/Link_relation

Microdata

<pre>index.html</pre>
<div itemscope="" itemtype="http://example.org/band">
 <p>My name is <span itemprop="name">Neil</span>.</p>
 <p>My band is called <span itemprop="band">Four Parts Water</span>.</p>
 <p>I am <span itemprop="nationality">British</span>.</p>
</div>
Rich Snippets Testing Tool at http://www.google.com/webmasters/tools/richsnippet

New form types

<input type="text" required="">
<input type="email" value="some@email.com">
<input type="date" min="2010-08-14" max="2011-08-14" value="2010-08-14">
<input type="range" min="0" max="50" value="10">
<input type="search" results="10" placeholder="Search...">
<input type="tel" placeholder="(555) 555-5555" pattern="^\(?\d{3}\)?[-\s]\d{3}[-\s]\d{4}.*?$">
<input type="color" placeholder="e.g. #bbbbbb">
<input type="number" step="1" min="-5" max="10" value="0">

Graphics / Multimedia

Audio + Video

main.js
<audio id="audio" src="videos/Google_Developer_Stories.webm" controls=""></audio>
document.getElementById("audio").muted = false;
main.js
<video id="video" src="videos/Google_Developer_Stories.webm" autoplay="" controls=""></video>
document.getElementById("video").play();
Your browser does not support the video tag

Track Element

<video width="390" id="clip" controls="">
  <source src="videos/Google_Developer_Stories.webm" type="video/webm; codecs="vp8, vorbis"">
  <track label="English subtitles" kind="subtitles" srclang="en" src="videos/video-subtitles-en.vtt" default=""></track>
</video>
Your browser does not support the video tag
WEBVTT FILE 1 00:00:00.500 --> 00:00:02.000 D:vertical A:start The Web is always changing 2 00:00:02.500 --> 00:00:04.300 and the way we access it is changing 3 00:00:05.000 --> 00:00:07.000 The source of that change is <c.highlight>you</c> 00:00:07.100 --> 00:00:11.000 Developers all around the world who are using our tools to create great new things 5 00:00:11.200 --> 00:00:13.200 and with so many tools, the sky is the limit 6 00:00:14.500 --> 00:00:16.500 But it cant happen without you and your ideas 7 00:00:17.500 --> 00:00:18.700 We want to know you better 8 00:00:18.700 --> 00:00:21.000 so we created a new place just for that 9 00:00:21.000 --> 00:00:22.000 to hear from <u>you</u> 10 00:00:22.500 --> 00:00:25.000 We want to hear what inspires you as a developer 11 00:00:25.500 --> 00:00:27.000 and how we can help. 12 00:00:27.000 --> 00:00:30.800 Here you can record a video, share stories with us and more 13 00:00:31.000 --> 00:00:34.000 Let us know what being a Google developer means to you 14 00:00:34.000 --> 00:00:38.200 and you can talk to us in person at Google Developer events all over the world. 15 00:00:38.500 --> 00:00:41.000 so we can learn how to support you better. 16 00:00:41.000 --> 00:00:44.600 Oh, btw, we also started rolling a new site for Google Developers 17 00:00:44.700 --> 00:00:49.400 Not just code but community, news, tools and other resources 18 00:00:49.400 --> 00:00:51.000 and cake 19 00:00:51.200 --> 00:00:54.000 Like any open source project it's a work in progress 20 00:00:54.100 --> 00:00:57.000 with your help it can be great 21 00:00:57.000 --> 00:01:00.000 L:12% developers.google.com/stories 21 00:01:00.500 --> 00:01:04.000 Change is important to the Web. Help us keep changing it together

FullScreen API

if (elem.webkitRequestFullScreen) {
  elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (elem.mozRequestFullScreen) {
  elem.mozRequestFullScreen();
} else if (elem.requestFullScreen){
  elem.requestFullScreen();
}
:-webkit-full-screen-ancestor:root {
  overflow: hidden;
}
:-webkit-full-screen-ancestor {
  z-index: auto;
  -webkit-transform: none;
  -webkit-transition: none;
}
pre:-webkit-full-screen {
  background-color: white;
}
Toggle slide fullscreen Toggle snippet fullscreen Test
close: 'ENTER' or 'ESC'

Canvas 2D

<canvas id="canvas" width="838" height="220"></canvas>

<script>
  var canvasContext = document.getElementById("canvas").getContext("2d");
  canvasContext.fillRect(250, 25, 150, 100);

  canvasContext.beginPath();
  canvasContext.arc(450, 110, 100, Math.PI * 1/2, Math.PI * 3/2);
  canvasContext.lineWidth = 15;
  canvasContext.lineCap = 'round';
  canvasContext.strokeStyle = 'rgba(255, 127, 0, 0.5)';
  canvasContext.stroke();
</script>
http://www.html5canvastutorials.com/
http://cheatsheetworld.com/programming/html5-canvas-cheat-sheet/

Canvas 3D (WebGL)

https://playcanvas.com/play
<canvas id="canvas" width="838" height="220"></canvas>
<script>
  var gl = document.getElementById("canvas").getContext("experimental-webgl");
  gl.viewport(0, 0, canvas.width, canvas.height);
  ...
</script>

Resources

THE END

BY HMCHUNG / TMA

0