Top Banner
Creating Rajinikant Powered Site Markandey Singh
47

Creating Rajanikant Powered Site

May 10, 2015

Download

Technology

markandey

Html5 offline
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Creating Rajanikant Powered Site

Creating Rajinikant Powered Site

Markandey Singh

Page 2: Creating Rajanikant Powered Site

I am markandey

Page 3: Creating Rajanikant Powered Site

I am javascript hacker

Page 4: Creating Rajanikant Powered Site

So lets talk about rajinikant

Page 5: Creating Rajanikant Powered Site

What is gmail id of

rajinikanth?

Page 6: Creating Rajanikant Powered Site

gmail @ rajinikanth .com

Page 7: Creating Rajanikant Powered Site
Page 8: Creating Rajanikant Powered Site

Rajanikanth smoking in Dubai

Page 9: Creating Rajanikant Powered Site

recently I saw this site

http://www.desimartini.com/allaboutrajni.htm

Page 10: Creating Rajanikant Powered Site

Claims to be working offline.

Page 11: Creating Rajanikant Powered Site

I loved it! and hoped they are promoting

HTML5

Page 12: Creating Rajanikant Powered Site

But sad they were using FLASH

:(

Page 13: Creating Rajanikant Powered Site

Today we are going to create a site which does the magic of rajanikant in HTML5

Page 14: Creating Rajanikant Powered Site

A site which can work offline, even if your internet unplugged

Page 15: Creating Rajanikant Powered Site

A site which works no matter how your laptop is oriented!

Page 16: Creating Rajanikant Powered Site

and some more magic

Page 17: Creating Rajanikant Powered Site

DESCLAIMER

All characters and events in this talk -– even though based on real people –- are entirely

fictional.

Page 18: Creating Rajanikant Powered Site

offline web apps

Page 19: Creating Rajanikant Powered Site

HTML5 defines some Offline Application Caching APIs

Page 20: Creating Rajanikant Powered Site

Which allows you to cache entire app offline so that your app will be fully operational

even offline

Page 21: Creating Rajanikant Powered Site

Its very easy to do

Page 22: Creating Rajanikant Powered Site

<!DOCTYPE html> <html manifest="/cache-manifest-file"> ---- ----------------- --------------------- ---------------------

Declaration of cache manifest

Page 23: Creating Rajanikant Powered Site

CACHE MANIFEST

#comment goes here ./anything.js ./anything.css ./anything.png

NETWORK: *

Cache manifest file

Page 24: Creating Rajanikant Powered Site

Cache manifest MIME type has to be

text/cache-manifest

PHP header('Content-type: text/cache-manifest');

App Engine self.response.headers['Content-Type'] = "text/cache-

manifest"

Page 25: Creating Rajanikant Powered Site

WARNING Once you deploy offline capable

app , none of your files will update to user, untill you will update your cache-manifest

Page 26: Creating Rajanikant Powered Site

How to check connectivity??

navigator.onLine

Page 27: Creating Rajanikant Powered Site

Events??

document.body.addEventListener("offline", function () { -------- -------- }, false);

document.body.addEventListener("online", function () { -------- -------- }, false);

Page 28: Creating Rajanikant Powered Site

Canvas

Page 29: Creating Rajanikant Powered Site

Canvas

Page 30: Creating Rajanikant Powered Site

Canvas was here for long time

in non-IE browsers, and now avaialable in IE9 as well

Page 31: Creating Rajanikant Powered Site

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

Canvas APIs are simple

Page 32: Creating Rajanikant Powered Site

canvas.width=500; canvas.height=500;

Canvas APIs are simple

Page 33: Creating Rajanikant Powered Site

ctx.strokeStyle = '#0000FF'; ctx.lineWidth = 1;

Canvas APIs are simple

Page 34: Creating Rajanikant Powered Site

ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x, y);

ctx.arc(x,y,radius,startAngle,endAngle, clockwise);

ctx.stroke(); ctx.fill();

Canvas APIs are simple

Page 35: Creating Rajanikant Powered Site

DataUrl and Images

var dataURL = canvas.toDataURL("image/png");

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA

img = new Image(); img.src=imgurl; //data:image/

png;base64,iVBORw0

ctx.drawImage(img,0,0);

Page 36: Creating Rajanikant Powered Site

HTML Local Storage

Page 37: Creating Rajanikant Powered Site

its a way to store small size data on client side.

(around 15MB per origin in most of the browsers)

Page 38: Creating Rajanikant Powered Site

Large data on localStorage should be avoided & too many read/write should be avoided !! To keep your

app faster!!

Page 39: Creating Rajanikant Powered Site

HTML5 Local Storage API

localStorage.setItem('name',value);

value=localStorage.getItem('name');

Page 40: Creating Rajanikant Powered Site

Other APIs to store data locally are

1.  Indexed Database API 2. File API

Page 41: Creating Rajanikant Powered Site

CSS 3D transforms (only supported by webkit)

Page 42: Creating Rajanikant Powered Site

Eventually major mobile browsers are based on webkit, e.g. iPhone, Android etc...

Page 43: Creating Rajanikant Powered Site

-webkit-tr

ansform: r

otateY

(-11deg);

Page 44: Creating Rajanikant Powered Site

Device orientation

window.addEventListener('deviceorientation', function(event) { var a = event.alpha, b = event.beta,

g = event.gamma;

}, false);

Page 45: Creating Rajanikant Powered Site

Device orientation

Page 46: Creating Rajanikant Powered Site

Resources and people!!

@Codepo8

@rem @paul_irish

http://caniuse.com/

Page 47: Creating Rajanikant Powered Site

Thank you &

Questions!!

twitter: @markandey email: markandey.singh at gmail