SlideShare a Scribd company logo
1 of 31
HTML 5 API: Documentation http://www.whatwg.org/specs/web-apps/current-work/multipage/ http://dev.w3.org/html5/
localStorage,sessionStorageAND YOU! DOM Storage:
DOM Storage: Why? Minimize HTTP Requests by not submitting unnecessary requests or statefullness Store data in browser across tabs, windows, and sessions Maintain functionality with unreliable connection by queuing data on reconnect  Great for mobile web apps Save user preferences Save session statefulness
DOM Storage: Browser Support Firefox 3.5, Safari 4, IE8, Chrome 4+, Opera 10.5: HTML5 localStorage; these modern browsers all support the core localStorage functionality defined in the HTML5 draft.
DOM Storage: Browser Support(cont’d) Firefox 2.x and 3.0: Gecko globalStorage, a very early implementation similar to HTML5’s localStorage. Safari 3.1 & 3.2: HTML5 Database Storage, because Safari 3.1 and 3.2 don’t support HTML5 localStorage.
DOM Storage: Browser Support(cont’d) IE6, IE7: userData persistence, a rarely used IE feature for associating string data with an element on a web page and persisting it between pageviews. Google Chrome Pre 4: Gears Database API, pre-installed into into earlier versions of Chrome
Storage Objects “Each domain and subdomain has its own separate local storage area. Domains can access the storage areas of subdomains, and subdomains can access the storage areas of parent domains.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx Important  For this origin check, HTTP and HTTPS are considered the same protocol.
Storage Objects (cont’d) Domains: localStorage['example.com'] is accessible to example.com localStorage[‘example.com’] is accessible to www.example.com Subdomains: localStorage['www.example.com'] is accessible to example.com localStorage['www.example.com'] is NOT accessible to mail.example.com
Storage Objects (cont’d) Properties stored as Strings Numbers, Booleans, and Objects must be converted If property name DNE, a key/value pair is automatically created to hold it It appears that all browsers delete local storage objects by deleting cookies IE is limited to only 5MB for localStorage and 5MB for sessionStorage "The current default on iPhone is 5.0 MB. If your database grows beyond this limit, the user will automatically be asked to allow or deny the size increase. If he allows the increase, the database size limit will be upped to 10.MB“- http://building-iphone-apps.labs.oreilly.com/ch05.html#ch05%5Fid35933104
localStorage “The local storage mechanism spans multiple windows and persists beyond the current session. ThelocalStorage attribute provides persistent storage areas for domains. It allows Web applications to store nearly 10 MB of user data, such as entire documents or a user's mailbox, on the client for performance reasons.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx
sessionStorage “Session storage is designed for scenarios where the user is carrying out a single transaction. ThesessionStorage attribute of the window object maintains key/value pairs for all pages loaded during the lifetime of a single tab (for the duration of the top-level browsing context). For example, a page might have a check box that the user selects to indicate that he wants insurance.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx
DOM Storage: API Storage Object localStorage and sessionStorage are both instances of the Storage object Methods clear getItem removeItem setItem Key Properties constructor length remainingSpace(IE Only)
DOM Storage: API Methods getItem: Retrieves the current value associated with the key. value = window.localStorage.getItem(key); setItem: Sets 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. keyValue = window.localStorage.key(n);
DOM Storage: API Properties constructor: Returns a reference to the constructor In FF, localStorage.constructor!== Storage ?? length: Retrieves the length of the key/value list. remainingSpace (IE Only): Retrieves the remaining memory space, in bytes, for the storage object.
DOM Storage: API Properties (cont’d) Getter/setters: key values can be used as properties of localStorage in place of getItem or setItem localStorage.x = ‘hey’ // localStorage.getItem(‘x’) === ‘hey’ localStorage.setItem(‘x’,’you’); // localStorage.x === ‘you’
Examples http://sammystodos.brandonaaron.net/#/list/0 sadf
Client-side SQL:  Currently only in Webkit& WebOS Chrome 3+ (3,4 via Gears), Safari 3.1+, iPhone, Palm, Android http://dev.w3.org/html5/webdatabase/ “The client-side SQL database in HTML 5 enables structured data storage.”
SQL API: Database Object Methods openDatabase transaction readTransaction changeVersion: Change the DB’s version. Properties version:  The DB’s current version.
SQL API: openDatabase window.openDatabase( DatabaseName, DatabaseVersion, DisplayName, EstimatedSize) DatabaseName: non-empty String DatabaseVersion: If not the most recent version, openDatabase will fail. DisplayName: any valid String (can be empty) EstimatedSize: an estimated size in bytes vardb = openDatabase(“DallasJS", “1.0", “DallasJS’ sweet DB", 1024*1024);
SQL API:transaction & readTransaction db.transaction(transactionCallback, errorCallback) db.transaction(function(tx) {	// EXECUTE SQL CODE VIA tx HERE}, function(e) {	alert(tx,e);}); The SQLTransactionObject has only method: executeSql
SQL API: executeSql transaction.executeSQL( SQLStatement, SQLParameters, ResultsetCallback, ErrorCallback); SQLStatement: A valid SQLite statement SQLParameters: Array of values “Replace each ? placeholder with the value of the argument in the arguments array with the same position.“ ResultsetCallback: Method to handle the returned results ErrorCallback: Method to handle a failed execution
SQL API: executeSql (cont’d) db.transaction(function(tx) { tx.executeSql("SELECT * FROM MyTb WHERE id = ?”,[1],function(tx,SQLResultSet) {	console.log(result.rows.item(0)['id']);}); });
SQL API: SQLResultSet Properties insertId: The id of the of the inserted row. rowsAffected: Number of rows affected by the statement. rows: The resulting data list.
SQL: Examples http://webkit.org/demos/sticky-notes/index.html db.transaction(function(tx) {tx.executeSql("CREATE TABLE t1 (t1key INTEGER PRIMARY KEY,dataTEXT,numdouble,timeEnter DATE); INSERT INTO 't1' VALUES(1, 'This is sample data', 3, NULL); INSERT INTO 't1' VALUES(2, 'More sample data', 6, NULL); INSERT INTO 't1' VALUES(3, 'And a little more', 9, NULL);");});
Cache Manifest “The mechanism for ensuring Web applications are available even when the user is not connected to their network is the manifest attribute on the html element.” Build WebApp in the form of HTML, CSS, JS, IMG files, etc… You don’t need to include the current HTML file Add link to manifest in html<html manifest=“example.manifest”> Make manifest file with MIME type “text/cache-manifest” with paths to resources to be cached:
Cache Manifest: Example CACHE MANIFEST # versionNumber CACHE example.html example.css example.js example.png FALLBACK: * /sorry-i-am-offline.html #give 404 page for all non-cached items when offline NETWORK: /important.html # never cache
Cache Manifest: Events checking: Fired whenever a manifest is present, regardless if page has been visited. downloading: If this cache manifest has never been seen before. progress: Fired during downloading phase giving updates regarding progress. cached: Fired on completion. WebApp is now fully cached noupdate: Fired if cache manifest has been seen, but is not new. downloading & progress: See above. updateready: New manifest has been cached, but your current app is not utilizing it yet. error: 404, 410, Failed to download manifest or a resource obsolete: The manifest was found to have become a 404 or 410 page, so the application cache is being deleted.
Cache Manifest:applicationCache Object The application cache automatically updates only if the manifest file changes. It does not automatically update if resources listed in the manifest file change  applicationCache.status: 0-5, corresponds with the following: UNCACHED // === 0 IDLE // === 1 CHECKING // === 2 DOWNLOADING // === 3 UPDATEREADY // === 4 OBSOLETE // === 5 applicationCache.update() applicationCache.swapCache()
Cache Manifest: iPhone EX http://www.technetra.com/2009/08/17/countdown-html5-cache-version/
Are we Offline? “The navigator.onLine attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail)...”- http://www.whatwg.org/specs/web-apps/current-work/#offline navigator.onLine === true window.addEventListener('online',function(){console.log(‘We’re online!');},true); window.addEventListener(‘offline',function(){console.log(‘We’ve lost power!');},true);
Additional Citations http://html5demos.com/drag http://www.w3.org/TR/webstorage/ http://dev.w3.org/html5/ https://developer.mozilla.org/en/dom/storage http://www.sqlite.org/docs.html http://www.w3.org/TR/2008/WD-html5-20080610/structured.html

More Related Content

What's hot

Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handlingAbhishekMondal42
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScriptT11 Sessions
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6Rob Eisenberg
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용KyeongMook "Kay" Cha
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects  jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects WebStackAcademy
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Julien Truffaut
 

What's hot (20)

Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Jquery
JqueryJquery
Jquery
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
Java script
Java scriptJava script
Java script
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
날로 먹는 Django admin 활용
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects  jQuery - Chapter 3 - Effects
jQuery - Chapter 3 - Effects
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Callback Function
Callback FunctionCallback Function
Callback Function
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Xml http request
Xml http requestXml http request
Xml http request
 
Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!
 

Viewers also liked

Local Storage for Web Applications
Local Storage for Web ApplicationsLocal Storage for Web Applications
Local Storage for Web ApplicationsMarkku Laine
 
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...CambridgeIP Ltd
 
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...Mohammad Subhan
 
TodiCastle: villa rentals & historic hotel in Umbria
TodiCastle: villa rentals & historic hotel in UmbriaTodiCastle: villa rentals & historic hotel in Umbria
TodiCastle: villa rentals & historic hotel in UmbriaMario Santoro
 
The Original Adjustable Door Hinge
The Original Adjustable Door HingeThe Original Adjustable Door Hinge
The Original Adjustable Door HingeBill Bragman
 
Baccetti tx timing_for_twin_block_therapy
Baccetti tx timing_for_twin_block_therapyBaccetti tx timing_for_twin_block_therapy
Baccetti tx timing_for_twin_block_therapyConsultório Particular
 
Blowin In The Wind
Blowin In The  WindBlowin In The  Wind
Blowin In The Windgoznevi
 
Final review presentation
Final review presentationFinal review presentation
Final review presentationArvind Krishnaa
 
Parasta mitä digillä saa nyt
Parasta mitä digillä saa nytParasta mitä digillä saa nyt
Parasta mitä digillä saa nytDarwin Oy
 
Resume M Pitcher 2010 08 27
Resume   M Pitcher 2010 08 27Resume   M Pitcher 2010 08 27
Resume M Pitcher 2010 08 27Michael Pitcher
 
Third review presentation
Third review presentationThird review presentation
Third review presentationArvind Krishnaa
 
Accelerating innovation and diffusion of renewable energy technologies: techn...
Accelerating innovation and diffusion of renewable energy technologies: techn...Accelerating innovation and diffusion of renewable energy technologies: techn...
Accelerating innovation and diffusion of renewable energy technologies: techn...CambridgeIP Ltd
 
Sosiaalisen median case-kimara
Sosiaalisen median case-kimaraSosiaalisen median case-kimara
Sosiaalisen median case-kimaraDarwin Oy
 

Viewers also liked (20)

Local Storage for Web Applications
Local Storage for Web ApplicationsLocal Storage for Web Applications
Local Storage for Web Applications
 
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...
Technology Transfer in the Renewable Energy Space: Key Challenges and Opportu...
 
Picture Essay
Picture EssayPicture Essay
Picture Essay
 
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...
Bahan asdep standarisasi jabatan sosialisasi permenpan 13 2014 surabaya 26 ju...
 
Kap3 balansering av likninger
Kap3 balansering av likningerKap3 balansering av likninger
Kap3 balansering av likninger
 
Ch25
Ch25Ch25
Ch25
 
Peta persoalan
Peta persoalanPeta persoalan
Peta persoalan
 
TodiCastle: villa rentals & historic hotel in Umbria
TodiCastle: villa rentals & historic hotel in UmbriaTodiCastle: villa rentals & historic hotel in Umbria
TodiCastle: villa rentals & historic hotel in Umbria
 
History of films
History of filmsHistory of films
History of films
 
The Original Adjustable Door Hinge
The Original Adjustable Door HingeThe Original Adjustable Door Hinge
The Original Adjustable Door Hinge
 
Baccetti tx timing_for_twin_block_therapy
Baccetti tx timing_for_twin_block_therapyBaccetti tx timing_for_twin_block_therapy
Baccetti tx timing_for_twin_block_therapy
 
On Becoming A Marketing Tour de Force
On Becoming A Marketing Tour de Force On Becoming A Marketing Tour de Force
On Becoming A Marketing Tour de Force
 
Blowin In The Wind
Blowin In The  WindBlowin In The  Wind
Blowin In The Wind
 
Final review presentation
Final review presentationFinal review presentation
Final review presentation
 
Parasta mitä digillä saa nyt
Parasta mitä digillä saa nytParasta mitä digillä saa nyt
Parasta mitä digillä saa nyt
 
Unit 0
Unit 0Unit 0
Unit 0
 
Resume M Pitcher 2010 08 27
Resume   M Pitcher 2010 08 27Resume   M Pitcher 2010 08 27
Resume M Pitcher 2010 08 27
 
Third review presentation
Third review presentationThird review presentation
Third review presentation
 
Accelerating innovation and diffusion of renewable energy technologies: techn...
Accelerating innovation and diffusion of renewable energy technologies: techn...Accelerating innovation and diffusion of renewable energy technologies: techn...
Accelerating innovation and diffusion of renewable energy technologies: techn...
 
Sosiaalisen median case-kimara
Sosiaalisen median case-kimaraSosiaalisen median case-kimara
Sosiaalisen median case-kimara
 

Similar to Local storage

Persistent Offline Storage White
Persistent Offline Storage WhitePersistent Offline Storage White
Persistent Offline Storage WhiteAlexei White
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Web Directions
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storageSendhil Kumar Kannan
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Browser security
Browser securityBrowser security
Browser securityUday Anand
 
Your browser, your storage (extended version)
Your browser, your storage (extended version)Your browser, your storage (extended version)
Your browser, your storage (extended version)Francesco Fullone
 
Taking Web Applications Offline
Taking Web Applications OfflineTaking Web Applications Offline
Taking Web Applications OfflineMatt Casto
 
Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Sho Ito
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs SilverlightMatt Casto
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Stephan Hochdörfer
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesStoyan Stefanov
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowshwetank
 

Similar to Local storage (20)

Persistent Offline Storage White
Persistent Offline Storage WhitePersistent Offline Storage White
Persistent Offline Storage White
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5
 
your browser, my storage
your browser, my storageyour browser, my storage
your browser, my storage
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Html5
Html5Html5
Html5
 
your browser, your storage
your browser, your storageyour browser, your storage
your browser, your storage
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Browser security
Browser securityBrowser security
Browser security
 
Your browser, your storage (extended version)
Your browser, your storage (extended version)Your browser, your storage (extended version)
Your browser, your storage (extended version)
 
Html5 & less css
Html5 & less cssHtml5 & less css
Html5 & less css
 
Taking Web Applications Offline
Taking Web Applications OfflineTaking Web Applications Offline
Taking Web Applications Offline
 
Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12
 
High Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practicesHigh Performance Web Pages - 20 new best practices
High Performance Web Pages - 20 new best practices
 
Browser Security
Browser SecurityBrowser Security
Browser Security
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 

Local storage

  • 1. HTML 5 API: Documentation http://www.whatwg.org/specs/web-apps/current-work/multipage/ http://dev.w3.org/html5/
  • 3. DOM Storage: Why? Minimize HTTP Requests by not submitting unnecessary requests or statefullness Store data in browser across tabs, windows, and sessions Maintain functionality with unreliable connection by queuing data on reconnect Great for mobile web apps Save user preferences Save session statefulness
  • 4. DOM Storage: Browser Support Firefox 3.5, Safari 4, IE8, Chrome 4+, Opera 10.5: HTML5 localStorage; these modern browsers all support the core localStorage functionality defined in the HTML5 draft.
  • 5. DOM Storage: Browser Support(cont’d) Firefox 2.x and 3.0: Gecko globalStorage, a very early implementation similar to HTML5’s localStorage. Safari 3.1 & 3.2: HTML5 Database Storage, because Safari 3.1 and 3.2 don’t support HTML5 localStorage.
  • 6. DOM Storage: Browser Support(cont’d) IE6, IE7: userData persistence, a rarely used IE feature for associating string data with an element on a web page and persisting it between pageviews. Google Chrome Pre 4: Gears Database API, pre-installed into into earlier versions of Chrome
  • 7. Storage Objects “Each domain and subdomain has its own separate local storage area. Domains can access the storage areas of subdomains, and subdomains can access the storage areas of parent domains.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx Important  For this origin check, HTTP and HTTPS are considered the same protocol.
  • 8. Storage Objects (cont’d) Domains: localStorage['example.com'] is accessible to example.com localStorage[‘example.com’] is accessible to www.example.com Subdomains: localStorage['www.example.com'] is accessible to example.com localStorage['www.example.com'] is NOT accessible to mail.example.com
  • 9. Storage Objects (cont’d) Properties stored as Strings Numbers, Booleans, and Objects must be converted If property name DNE, a key/value pair is automatically created to hold it It appears that all browsers delete local storage objects by deleting cookies IE is limited to only 5MB for localStorage and 5MB for sessionStorage "The current default on iPhone is 5.0 MB. If your database grows beyond this limit, the user will automatically be asked to allow or deny the size increase. If he allows the increase, the database size limit will be upped to 10.MB“- http://building-iphone-apps.labs.oreilly.com/ch05.html#ch05%5Fid35933104
  • 10. localStorage “The local storage mechanism spans multiple windows and persists beyond the current session. ThelocalStorage attribute provides persistent storage areas for domains. It allows Web applications to store nearly 10 MB of user data, such as entire documents or a user's mailbox, on the client for performance reasons.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx
  • 11. sessionStorage “Session storage is designed for scenarios where the user is carrying out a single transaction. ThesessionStorage attribute of the window object maintains key/value pairs for all pages loaded during the lifetime of a single tab (for the duration of the top-level browsing context). For example, a page might have a check box that the user selects to indicate that he wants insurance.” - http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx
  • 12. DOM Storage: API Storage Object localStorage and sessionStorage are both instances of the Storage object Methods clear getItem removeItem setItem Key Properties constructor length remainingSpace(IE Only)
  • 13. DOM Storage: API Methods getItem: Retrieves the current value associated with the key. value = window.localStorage.getItem(key); setItem: Sets 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. keyValue = window.localStorage.key(n);
  • 14. DOM Storage: API Properties constructor: Returns a reference to the constructor In FF, localStorage.constructor!== Storage ?? length: Retrieves the length of the key/value list. remainingSpace (IE Only): Retrieves the remaining memory space, in bytes, for the storage object.
  • 15. DOM Storage: API Properties (cont’d) Getter/setters: key values can be used as properties of localStorage in place of getItem or setItem localStorage.x = ‘hey’ // localStorage.getItem(‘x’) === ‘hey’ localStorage.setItem(‘x’,’you’); // localStorage.x === ‘you’
  • 17. Client-side SQL: Currently only in Webkit& WebOS Chrome 3+ (3,4 via Gears), Safari 3.1+, iPhone, Palm, Android http://dev.w3.org/html5/webdatabase/ “The client-side SQL database in HTML 5 enables structured data storage.”
  • 18. SQL API: Database Object Methods openDatabase transaction readTransaction changeVersion: Change the DB’s version. Properties version: The DB’s current version.
  • 19. SQL API: openDatabase window.openDatabase( DatabaseName, DatabaseVersion, DisplayName, EstimatedSize) DatabaseName: non-empty String DatabaseVersion: If not the most recent version, openDatabase will fail. DisplayName: any valid String (can be empty) EstimatedSize: an estimated size in bytes vardb = openDatabase(“DallasJS", “1.0", “DallasJS’ sweet DB", 1024*1024);
  • 20. SQL API:transaction & readTransaction db.transaction(transactionCallback, errorCallback) db.transaction(function(tx) { // EXECUTE SQL CODE VIA tx HERE}, function(e) { alert(tx,e);}); The SQLTransactionObject has only method: executeSql
  • 21. SQL API: executeSql transaction.executeSQL( SQLStatement, SQLParameters, ResultsetCallback, ErrorCallback); SQLStatement: A valid SQLite statement SQLParameters: Array of values “Replace each ? placeholder with the value of the argument in the arguments array with the same position.“ ResultsetCallback: Method to handle the returned results ErrorCallback: Method to handle a failed execution
  • 22. SQL API: executeSql (cont’d) db.transaction(function(tx) { tx.executeSql("SELECT * FROM MyTb WHERE id = ?”,[1],function(tx,SQLResultSet) { console.log(result.rows.item(0)['id']);}); });
  • 23. SQL API: SQLResultSet Properties insertId: The id of the of the inserted row. rowsAffected: Number of rows affected by the statement. rows: The resulting data list.
  • 24. SQL: Examples http://webkit.org/demos/sticky-notes/index.html db.transaction(function(tx) {tx.executeSql("CREATE TABLE t1 (t1key INTEGER PRIMARY KEY,dataTEXT,numdouble,timeEnter DATE); INSERT INTO 't1' VALUES(1, 'This is sample data', 3, NULL); INSERT INTO 't1' VALUES(2, 'More sample data', 6, NULL); INSERT INTO 't1' VALUES(3, 'And a little more', 9, NULL);");});
  • 25. Cache Manifest “The mechanism for ensuring Web applications are available even when the user is not connected to their network is the manifest attribute on the html element.” Build WebApp in the form of HTML, CSS, JS, IMG files, etc… You don’t need to include the current HTML file Add link to manifest in html<html manifest=“example.manifest”> Make manifest file with MIME type “text/cache-manifest” with paths to resources to be cached:
  • 26. Cache Manifest: Example CACHE MANIFEST # versionNumber CACHE example.html example.css example.js example.png FALLBACK: * /sorry-i-am-offline.html #give 404 page for all non-cached items when offline NETWORK: /important.html # never cache
  • 27. Cache Manifest: Events checking: Fired whenever a manifest is present, regardless if page has been visited. downloading: If this cache manifest has never been seen before. progress: Fired during downloading phase giving updates regarding progress. cached: Fired on completion. WebApp is now fully cached noupdate: Fired if cache manifest has been seen, but is not new. downloading & progress: See above. updateready: New manifest has been cached, but your current app is not utilizing it yet. error: 404, 410, Failed to download manifest or a resource obsolete: The manifest was found to have become a 404 or 410 page, so the application cache is being deleted.
  • 28. Cache Manifest:applicationCache Object The application cache automatically updates only if the manifest file changes. It does not automatically update if resources listed in the manifest file change applicationCache.status: 0-5, corresponds with the following: UNCACHED // === 0 IDLE // === 1 CHECKING // === 2 DOWNLOADING // === 3 UPDATEREADY // === 4 OBSOLETE // === 5 applicationCache.update() applicationCache.swapCache()
  • 29. Cache Manifest: iPhone EX http://www.technetra.com/2009/08/17/countdown-html5-cache-version/
  • 30. Are we Offline? “The navigator.onLine attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail)...”- http://www.whatwg.org/specs/web-apps/current-work/#offline navigator.onLine === true window.addEventListener('online',function(){console.log(‘We’re online!');},true); window.addEventListener(‘offline',function(){console.log(‘We’ve lost power!');},true);
  • 31. Additional Citations http://html5demos.com/drag http://www.w3.org/TR/webstorage/ http://dev.w3.org/html5/ https://developer.mozilla.org/en/dom/storage http://www.sqlite.org/docs.html http://www.w3.org/TR/2008/WD-html5-20080610/structured.html