SlideShare a Scribd company logo
1 of 15
Локальные хранилища
История: MicroSoft Internet Explorer.  UserData object.  64Kb per domain (x10 for trusted domains) Adobe Local Storage Objects AMASS (AJAX MAssive Storage System) Later AMASS->Dojo Toolkit (dojo.storage) Google.Gears (plugin, permissions)
HTML5 Storage   (DOM Storage, Web Storage, Local Storage) - хранение данных key -> value - данные не передаются на сервер - встроено в браузер, не нужно библиотек, плагинов... - 5Мб (в IE - 10Mb)  8.0 3.5 4.0 4.0 10.5
Все данные хранятся как строки Использовать ParseInt() & ParseFloat() window.localStorage vs. winsdow.sessionStorage - getItem() - setItem() - removeItem() localStorage['a'] && localStorage.a localStorage.key() localStorage.clear() localStorage.length IE : localStorage.remainingSpace
Web SQL DB - SQLite (SQL syntax) - SELECT, UPDATE, INSERT, DELETE... - - 4.0 4.0 10.5
dbh = openDatabase( "MyDB" ,  "1.0.0" ,  "My Database" , 1048576); dbh.transaction(function(tx) {     tx.executeSql(      ' CREATE TABLE table01 (id INTEGER PRIMARY KEY, name TEXT) ',      [],  //params       function(tx, rs){}, //result handler       function(tx, er){} //error handler     ); });
dbh.transaction(function(tx) {     tx.executeSql(      ' INSERT INTO TABLE table01 (id, name) VALUES (?, ?) ',      [i, name],      function(tx, rs){},      function(tx, er){}    ); });
dbh.transaction(function(tx) {    tx.executeSql(      ' SELECT * FROM table01 WHERE name = ? ',        [name],        function(tx, rs){},       function(tx, er){}    ); });
SQLResultSet    insertId :  Error: ... (SELECT QUERY)      rows : SQLResultSetRowList        length :  1        __proto__ : SQLResultSetRowList          constructor : function SQLResultSetRowList()...          item : function item() ...            arguments :  null            caller :  null            length :  0            name :  "item"            prototype : item            __proto__ : function Empty() {}          __proto__ : Object        rowsAffected :  1      __proto__ : SQLResultSet SQLError   code :  5   message :  "no such table: table01"   __proto__ : SQLError
IndexedDB IE9 ? 4.0 - 8.0 -
четыре типа транзакций:  READ_ONLY READ_WRITE SNAPSHOT_READ VERSION_CHANGED
idb = window.mozIndexedDB || window.webkitIndexedDB || null;   //new ActiveXObject("SQLCE.Factory.4.0"); //new ActiveXObject("SQLCE.FactorySync.4.0"); var request = window.indexedDB.open("DatabaseName", "DatabaseDescription");   request.onsuccess = function(event){    var database = event.result;    write("Database Opened", database); };   request.onerror = function(e){    writeError(e); };
WebDatabase   var  kids  =   [    {   name :   &quot;Anna&quot;   } ,      {   name :   &quot;Betty&quot;   } ,    {   name :   &quot;Christine&quot;   }   ] ;   var  db  =  window. openDatabase ( &quot;CandyDB&quot; ,   &quot;1&quot; ,   &quot;My candy store database&quot; ,   1024 ) ;     db. transaction ( function ( tx )   {    for   ( var  index  =   0 ;  index  <  kids. length ;  index ++ )   {      var  kid  =  kids [ index ] ;        tx. executeSql (          &quot;INSERT INTO kids (name) VALUES (?);&quot; ,            [ kid ] ,          function ( tx ,  results )   {            alert( &quot;Saved record for &quot;   +  kid. name   +   &quot; with id &quot;   +  results. insertId );        }      ) ;    } }) ;
IndexedDB   var  kids  =   [      {   name :   &quot;Anna&quot;   } ,        {   name :   &quot;Betty&quot;   } ,        {   name :   &quot;Christine&quot;   }     ] ;     var  request  =  window. indexedDB . open ( &quot;CandyDB&quot; ,   &quot;My candy store database&quot; ) ;     request. onsuccess   =   function ( event )   {    var  objectStore  =  event. result . objectStore ( &quot;kids&quot; ) ;      for   ( var  index  =   0 ;  index  <  kids. length ;  index ++ )   {        var  kid  =  kids [ index ] ;        objectStore. add ( kid ) . onsuccess   =   function ( event )   {          alert( &quot;Saved record for &quot;   +  kid. name   +   &quot; with id &quot;   +  event. result );          } ;        }   } ;
Почитать: http://dev.w3.org/html5/webstorage/ http://msdn.microsoft.com/en-us/library/cc197062%28VS.85%29.aspx http://htmlbook.ru/html5/storage / http://diveintohtml5.org/storage.html http://dev.w3.org/html5/webdatabase/ http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/  http://mikewest.org/2010/12/intro-to-indexeddb http://habrahabr.ru/blogs/webdev/117473/ http://msdn.microsoft.com/en-us/scriptjunkie/gg679063  

More Related Content

What's hot

2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung MosbachJohannes Hoppe
 
Юнит тестирование в Zend Framework 2.0
Юнит тестирование в Zend Framework 2.0Юнит тестирование в Zend Framework 2.0
Юнит тестирование в Zend Framework 2.0zfconfua
 
HTML5を使ったウェブアプリケーションの高速化
HTML5を使ったウェブアプリケーションの高速化HTML5を使ったウェブアプリケーションの高速化
HTML5を使ったウェブアプリケーションの高速化hagino 3000
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuerygoldoraf
 
Documentacion edderson callpa_ortiz
Documentacion edderson callpa_ortizDocumentacion edderson callpa_ortiz
Documentacion edderson callpa_ortizEdderson J. Ortiz
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.bhavesh lande
 
Php codigos interfaces fredy guzman cusihunca
Php codigos interfaces   fredy guzman cusihuncaPhp codigos interfaces   fredy guzman cusihunca
Php codigos interfaces fredy guzman cusihuncaTigger_Fred
 
KvZ Web Tasarım Hizmetleri
KvZ Web Tasarım HizmetleriKvZ Web Tasarım Hizmetleri
KvZ Web Tasarım HizmetleriAhmet Öztaş
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIAlex S
 
Dennis zapana perez
Dennis zapana perezDennis zapana perez
Dennis zapana perezdennis_elvis
 

What's hot (20)

Sis quiz
Sis quizSis quiz
Sis quiz
 
dojo.basix
dojo.basixdojo.basix
dojo.basix
 
2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach2017 - NoSQL Vorlesung Mosbach
2017 - NoSQL Vorlesung Mosbach
 
Юнит тестирование в Zend Framework 2.0
Юнит тестирование в Zend Framework 2.0Юнит тестирование в Zend Framework 2.0
Юнит тестирование в Zend Framework 2.0
 
Phpex3
Phpex3Phpex3
Phpex3
 
Javantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
Javantura Zagreb 2014 - Groovy-SQL - Dinko SrkočJavantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
Javantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
 
HTML5を使ったウェブアプリケーションの高速化
HTML5を使ったウェブアプリケーションの高速化HTML5を使ったウェブアプリケーションの高速化
HTML5を使ったウェブアプリケーションの高速化
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
 
Documentacion edderson callpa_ortiz
Documentacion edderson callpa_ortizDocumentacion edderson callpa_ortiz
Documentacion edderson callpa_ortiz
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
Php codigos interfaces fredy guzman cusihunca
Php codigos interfaces   fredy guzman cusihuncaPhp codigos interfaces   fredy guzman cusihunca
Php codigos interfaces fredy guzman cusihunca
 
KvZ Web Tasarım Hizmetleri
KvZ Web Tasarım HizmetleriKvZ Web Tasarım Hizmetleri
KvZ Web Tasarım Hizmetleri
 
Sumahex
SumahexSumahex
Sumahex
 
Miniray.php
Miniray.phpMiniray.php
Miniray.php
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
 
Wek14 mysql 2
Wek14 mysql 2Wek14 mysql 2
Wek14 mysql 2
 
Dennis zapana perez
Dennis zapana perezDennis zapana perez
Dennis zapana perez
 
Introducción a Bolt
Introducción a BoltIntroducción a Bolt
Introducción a Bolt
 
Jquery2
Jquery2Jquery2
Jquery2
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 

Local storages

  • 2. История: MicroSoft Internet Explorer.  UserData object.  64Kb per domain (x10 for trusted domains) Adobe Local Storage Objects AMASS (AJAX MAssive Storage System) Later AMASS->Dojo Toolkit (dojo.storage) Google.Gears (plugin, permissions)
  • 3. HTML5 Storage   (DOM Storage, Web Storage, Local Storage) - хранение данных key -> value - данные не передаются на сервер - встроено в браузер, не нужно библиотек, плагинов... - 5Мб (в IE - 10Mb) 8.0 3.5 4.0 4.0 10.5
  • 4. Все данные хранятся как строки Использовать ParseInt() & ParseFloat() window.localStorage vs. winsdow.sessionStorage - getItem() - setItem() - removeItem() localStorage['a'] && localStorage.a localStorage.key() localStorage.clear() localStorage.length IE : localStorage.remainingSpace
  • 5. Web SQL DB - SQLite (SQL syntax) - SELECT, UPDATE, INSERT, DELETE... - - 4.0 4.0 10.5
  • 6. dbh = openDatabase( &quot;MyDB&quot; , &quot;1.0.0&quot; , &quot;My Database&quot; , 1048576); dbh.transaction(function(tx) {    tx.executeSql(     ' CREATE TABLE table01 (id INTEGER PRIMARY KEY, name TEXT) ',     [],  //params      function(tx, rs){}, //result handler      function(tx, er){} //error handler    ); });
  • 7. dbh.transaction(function(tx) {    tx.executeSql(     ' INSERT INTO TABLE table01 (id, name) VALUES (?, ?) ',     [i, name],     function(tx, rs){},     function(tx, er){}   ); });
  • 8. dbh.transaction(function(tx) {   tx.executeSql(     ' SELECT * FROM table01 WHERE name = ? ',       [name],       function(tx, rs){},      function(tx, er){}   ); });
  • 9. SQLResultSet   insertId :  Error: ... (SELECT QUERY)     rows : SQLResultSetRowList       length :  1       __proto__ : SQLResultSetRowList         constructor : function SQLResultSetRowList()...         item : function item() ...           arguments :  null           caller :  null           length :  0           name :  &quot;item&quot;           prototype : item           __proto__ : function Empty() {}         __proto__ : Object       rowsAffected :  1     __proto__ : SQLResultSet SQLError   code :  5   message :  &quot;no such table: table01&quot;   __proto__ : SQLError
  • 10. IndexedDB IE9 ? 4.0 - 8.0 -
  • 11. четыре типа транзакций:  READ_ONLY READ_WRITE SNAPSHOT_READ VERSION_CHANGED
  • 12. idb = window.mozIndexedDB || window.webkitIndexedDB || null;   //new ActiveXObject(&quot;SQLCE.Factory.4.0&quot;); //new ActiveXObject(&quot;SQLCE.FactorySync.4.0&quot;); var request = window.indexedDB.open(&quot;DatabaseName&quot;, &quot;DatabaseDescription&quot;);   request.onsuccess = function(event){   var database = event.result;   write(&quot;Database Opened&quot;, database); };   request.onerror = function(e){   writeError(e); };
  • 13. WebDatabase   var kids = [   { name : &quot;Anna&quot; } ,     { name : &quot;Betty&quot; } ,   { name : &quot;Christine&quot; }   ] ;   var db = window. openDatabase ( &quot;CandyDB&quot; , &quot;1&quot; , &quot;My candy store database&quot; , 1024 ) ;     db. transaction ( function ( tx ) {   for ( var index = 0 ; index < kids. length ; index ++ ) {     var kid = kids [ index ] ;       tx. executeSql (         &quot;INSERT INTO kids (name) VALUES (?);&quot; ,         [ kid ] ,         function ( tx , results ) {           alert( &quot;Saved record for &quot; + kid. name + &quot; with id &quot; + results. insertId );       }     ) ;   } }) ;
  • 14. IndexedDB   var kids = [     { name : &quot;Anna&quot; } ,     { name : &quot;Betty&quot; } ,     { name : &quot;Christine&quot; }   ] ;     var request = window. indexedDB . open ( &quot;CandyDB&quot; , &quot;My candy store database&quot; ) ;     request. onsuccess = function ( event ) {   var objectStore = event. result . objectStore ( &quot;kids&quot; ) ;     for ( var index = 0 ; index < kids. length ; index ++ ) {       var kid = kids [ index ] ;       objectStore. add ( kid ) . onsuccess = function ( event ) {         alert( &quot;Saved record for &quot; + kid. name + &quot; with id &quot; + event. result );       } ;     }   } ;
  • 15. Почитать: http://dev.w3.org/html5/webstorage/ http://msdn.microsoft.com/en-us/library/cc197062%28VS.85%29.aspx http://htmlbook.ru/html5/storage / http://diveintohtml5.org/storage.html http://dev.w3.org/html5/webdatabase/ http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/ http://mikewest.org/2010/12/intro-to-indexeddb http://habrahabr.ru/blogs/webdev/117473/ http://msdn.microsoft.com/en-us/scriptjunkie/gg679063