{"id":198666,"date":"2013-10-23T16:08:03","date_gmt":"2013-10-23T12:08:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=198666"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=198666","title":{"rendered":"<span class=\"post_title\">IndexedDB \u2014 \u0431\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e.<br \/>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 IndexedDB \u0438 \u0441 \u0447\u0435\u043c \u0435\u0433\u043e \u0435\u0434\u044f\u0442 \u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/117473\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0410 \u043c\u044b \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u0435\u0435. <\/p>\n<h2>\u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442<\/h2>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u043e\u0440\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0432\u044b\u0431\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043f\u0430\u043b \u043d\u0430 IndexedDB. <\/p>\n<p>  \u041d\u043e \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u00ab\u041d\u041e\u00bb, \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u00ab\u041d\u041e\u00bb \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0411\u0414 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 5 \u041c\u0411, \u0447\u0442\u043e \u043e\u0442\u043d\u044e\u0434\u044c \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432\u0441\u0435 \u044e\u0437\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 Google Chrome, \u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u0445\u043e\u0434\u0430 \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435-\u043f\u0440\u043e\u043a\u0441\u0438. \u041f\u0435\u0440\u0435\u043b\u043e\u043f\u0430\u0442\u0438\u0432 \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u044b \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f:<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"javascript\">&quot;permissions&quot;: [         &quot;unlimitedStorage&quot;,         &quot;unlimited_storage&quot;     ], <\/code><\/pre>\n<p>  <habracut\/><\/p>\n<h2>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0441\u0430\u0439\u0442-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435-\u0441\u0430\u0439\u0442<\/h2>\n<p>  \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u0435\u0435. \u0421 \u0431\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u044b\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u043e\u0439 \u0441\u0430\u043c\u043e\u0439 \u0431\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u043e\u0439 \u0411\u0414 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0441\u0430\u0439\u0442\u043e\u043c \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c (\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0432 \u0440\u043e\u043b\u0438 \u043f\u0440\u043e\u043a\u0441\u0438, \u043c\u0435\u0436\u0434\u0443 \u0441\u0430\u0439\u0442\u043e\u043c \u0438 \u0431\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u043e\u0439 \u0411\u0414). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u043b\u0430\u0433\u0438:<\/p>\n<pre><code class=\"javascript\">&quot;externally_connectable&quot;: {         &quot;matches&quot;: [             &quot;*:\/\/localhost\/*&quot;, \t&quot;\u0417\u0414\u0415\u0421\u042c_\u0414\u041e\u0411\u0410\u0412\u041b\u042f\u0415\u041c_\u0420\u0410\u0417\u0420\u0415\u0428\u0415\u041d\u041d\u042b\u0415_\u0428\u0410\u0411\u041b\u041e\u041d\u042b_URL &quot;         ]     } <\/code><\/pre>\n<p>  \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u0447\u0442\u043e \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c\u0438 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f URL \u0432\u0438\u0434\u0430: *:\/\/google.com\/* and http:\/\/*.chromium.org\/*, \u0430, http:\/\/ * \/ *, * :\/ \/ *. COM \/ \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f.<br \/>  \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e externally_connectable \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/developer.chrome.com\/extensions\/manifest\/externally_connectable.html\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>  \u041d\u0430\u0441\u0442\u0443\u043f\u0438\u043b \u044d\u0442\u0430\u043f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u00ab\u043c\u043e\u0441\u0442\u0430\u00bb \u043c\u0435\u0436\u0434\u0443 \u0441\u0430\u0439\u0442\u043e\u043c \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0411\u0414.<br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 IndexDB \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 db.js, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"http:\/\/aaronpowell.github.io\/db.js\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434, \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0430\u0439\u0442\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 db.js.<\/p>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0418 \u0442\u0430\u043a \u043f\u043e\u0435\u0445\u0430\u043b\u0438, \u0441\u043e\u0437\u0434\u0430\u0435\u043c background.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u043d\u0438\u0445. \u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"javascript\">var server;  chrome.runtime.onMessageExternal.addListener(     function (request, sender, sendResponse) {         var cmd = request.cmd,             params = request.params;         try {             switch (cmd) {                 case &quot;open&quot;:                     db.open(params).done(function (s) {                         server = s;                         var exclude = &quot;add close get query remove update&quot;.split(&quot; &quot;);                         var tables = new Array();                         for(var table in server){                             if(exclude.indexOf(table)==-1){                                 tables.push(table);                             }                         }                         sendResponse(tables);                     });                     break;                 case &quot;close&quot;:                     server.close();                     sendResponse({});                     break;                 case &quot;get&quot;:                     server[request.table].get(params).done(sendResponse)                     break;                 case &quot;add&quot;:                     server[request.table].add(params).done(sendResponse);                     break;                 case &quot;update&quot;:                     server[request.table].update(params).done(sendResponse);                     break;                 case &quot;remove&quot;:                     server[request.table].remove(params).done(sendResponse);                     break;                 case &quot;execute&quot;:                     var tmp_server = server[request.table];                     var query = tmp_server.query.apply(tmp_server, obj2arr(request.query));                     var flt;                     for (var i = 0; i &lt; request.filters.length; i++) {                         flt = request.filters[i];                         if (flt.type == &quot;filter&quot;) {                             flt.args = new Function(&quot;item&quot;, flt.args[0]);                         }                         query = query[flt.type].apply(query, obj2arr(flt.args));                     }                     query.execute().done(sendResponse);                     break;             }         } catch (error) {             if (error.name != &quot;TypeError&quot;) {                 sendResponse({RUNTIME_ERROR: error});             }         }         return true;     }); <\/code><\/pre>\n<p>  \u041d\u043e \u0442\u0443\u0442 \u043d\u0430\u0441 \u0436\u0434\u0430\u043b \u0441\u044e\u0440\u043f\u0440\u0438\u0437, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">flt.args = new Function(&quot;item&quot;, flt.args[0]); <\/code><\/pre>\n<p>  \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<p>  <code>Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: &quot;script-src 'self' chrome-extension-resource:&quot;.<\/code>.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442 \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e js \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"javascript\">&quot;content_security_policy&quot;: &quot;script-src 'self' 'unsafe-eval'; object-src 'self'&quot;<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0433\u043e\u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432, \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">var obj2arr = function (obj) {     if (typeof obj == 'object') {         var tmp_args = new Array();         for (var k in obj) {             tmp_args.push(obj[k]);         }         return tmp_args;     } else {         return [obj];     } } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 manifest.json<\/p>\n<pre><code class=\"javascript\">{     &quot;manifest_version&quot;: 2,      &quot;name&quot;: &quot;exDB&quot;,     &quot;description&quot;: &quot;This extension give proxy access to indexdb from page.&quot;,     &quot;version&quot;: &quot;1.0&quot;,      &quot;background&quot;: {         &quot;page&quot;: &quot;background.html&quot;     },     &quot;content_security_policy&quot;: &quot;script-src 'self' 'unsafe-eval'; object-src 'self'&quot;,     &quot;externally_connectable&quot;: {         &quot;matches&quot;: [             &quot;*:\/\/localhost\/*&quot;         ]     },     &quot;permissions&quot;: [         &quot;unlimitedStorage&quot;,         &quot;unlimited_storage&quot;     ],     &quot;icons&quot;: {         &quot;16&quot;: &quot;icons\/icon_016.png&quot;,         &quot;48&quot;: &quot;icons\/icon_048.png&quot;     }  } <\/code><\/pre>\n<h3>\u041a\u043b\u0438\u0435\u043d\u0442<\/h3>\n<p>  \u0421 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043b\u0438\u0435\u043d\u0442-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u043e\u043a\u0441\u0438-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c.<br \/>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043f\u0440\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u043c\u0443 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e id:<\/p>\n<pre><code class=\"javascript\">chrome.runtime.sendMessage(&quot;ID_\u0420\u0410\u0421\u0428\u0418\u0420\u0415\u041d\u0418\u042f&quot;, data, callback);<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"javascript\">(function (window, undefined) {     &quot;use strict&quot;;     function exDB() {         var self = this;         this.extensionId = arguments[0] || &quot;knpcnhfbafbjadcbeipdihdblfogiafm&quot;;         this.filterList = new Array();         this._table;         this._query;         self.sendMessage = function sendMessage(data, callback) {             chrome.runtime.sendMessage(self.extensionId, data, callback);         };          self.open = function (params, callback) {             self.sendMessage({&quot;cmd&quot;: &quot;open&quot;, &quot;params&quot;: params}, function(r){                 var tn;                 for(var i=0;i&lt; r.length;i++)                     tn = r[i];                     self.__defineGetter__(tn,function(){                         self._table = tn;                         return this;                     });                 callback();             });             return self;         };          self.close = function (callback) {             self.sendMessage({&quot;cmd&quot;: &quot;close&quot;, &quot;params&quot;: {}}, callback);             return self;         }          self.table = function (name) {             self._table = name;             return self;         };          self.query = function () {             self._query = arguments;             return self;         };          self.execute = function (callback) {             self.sendMessage({&quot;cmd&quot;: &quot;execute&quot;, &quot;table&quot;: self._table, &quot;query&quot;: self._query, &quot;filters&quot;: self.filterList}, function (result) {                 if (result && result.RUNTIME_ERROR) {                     console.error(result.RUNTIME_ERROR.message);                     result = null;                 }                 callback(result);             });             self._query = null;             self.filterList = [];         };          &quot;add update remove get&quot;.split(&quot; &quot;).forEach(function (fn) {             self[fn] = function (item, callback) {                 self.sendMessage({&quot;cmd&quot;: fn, &quot;table&quot;: self._table, &quot;params&quot;: item}, function (result) {                     if (result && result.RUNTIME_ERROR) {                         console.error(result.RUNTIME_ERROR.message);                         result = null;                     }                     callback(result);                 });                 return self;             }         });          &quot;all only lowerBound upperBound bound filter desc distinct keys count&quot;.split(&quot; &quot;).forEach(function (fn) {             self[fn] = function () {                 self.filterList.push({type: fn, args: arguments});                 return self;             }         });      }      window.exDB = exDB; })(window, undefined); <\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0435\u0437\u043b\u0438\u043c\u0438\u0442\u043d\u043e\u0439 indexDB \u0433\u043e\u0442\u043e\u0432. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h5>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\">    var db = new exDB();     db.open({         server: 'my-app',         version: 1,         schema: {             people: {                 key: { keyPath: 'id', autoIncrement: true },                 \/\/ Optionally add indexes                 indexes: {                     firstName: { },                     answer: { unique: true }                 }             }         }     }, function () {}); <\/code><\/pre>\n<h5>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\">db.table(&quot;people&quot;).add({  firstName: 'Aaron', lastName: 'Powell', answer: 142},function(r){ }); <\/code><\/pre>\n<h5>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 <\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\"> db.table(&quot;people&quot;).update({ id:1, firstName: 'Aaron', lastName: 'Powell', answer: 1242}, function (r) {});<\/code><\/pre>\n<h5>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e ID<\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\">db.table(&quot;people&quot;).remove(1,function(key){});<\/code><\/pre>\n<h5>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e ID<\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\">db.table(&quot;people3&quot;).get(111,function(r){ \tconsole.log(r);  }); <\/code><\/pre>\n<h5>\u0412\u044b\u0431\u043e\u0440\u043a\u0438 \/ \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438<\/h5>\n<p>  <\/p>\n<pre><code class=\"javascript\">db.people.query(&quot;firstName&quot;).only(&quot;Aaron2&quot;).execute(function(r){          console.log(&quot;GETTER&quot;,r); });  db.table(&quot;people&quot;).query(&quot;answer&quot;).all().desc().execute(function(r){          console.log(&quot;all&quot;,r);  }); db.table(&quot;people&quot;).query(&quot;answer&quot;).only(12642).count().execute(function(r){          console.log(&quot;only&quot;,r); }); db.table(&quot;people&quot;).query(&quot;answer&quot;).bound(20,45).execute(function(r){          console.log(&quot;bound&quot;,r); }); db.table(&quot;people&quot;).query(&quot;answer&quot;).lowerBound(50).keys().execute(function(r){          console.log(&quot;lowerBound&quot;,r); }); db.table(&quot;people&quot;).query(&quot;answer&quot;).upperBound(43).execute(function(r){          console.log(&quot;upperBound&quot;,r); });  db.table(&quot;people&quot;).query(&quot;answer&quot;).filter(&quot;return item.answer==42 && item.firstName=='Aaron'&quot;).execute(function(r){          console.log(&quot;filter&quot;,r); }); <\/code><\/pre>\n<h2>\u0412\u044b\u0432\u043e\u0434<\/h2>\n<p>  \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0431\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u043a\u0440\u0438\u0442\u0438\u043a\u0443 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e\u043c \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0445\u0430\u0431\u0440\u0435 \u043f\u0440\u043e\u0448\u0443 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u044c.<\/p>\n<p>  \u0421 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u043d\u0430 <a href=\"https:\/\/github.com\/andrusender\/idb.proxy\">github<\/a>. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/198666\/\"> http:\/\/habrahabr.ru\/post\/198666\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e.<br \/>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 IndexedDB \u0438 \u0441 \u0447\u0435\u043c \u0435\u0433\u043e \u0435\u0434\u044f\u0442 \u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/117473\/\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0410 \u043c\u044b \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u0435\u0435. <\/p>\n<h2>\u0411\u0435\u0437\u043b\u0438\u043c\u0438\u0442<\/h2>\n<p>  \u0412 \u043a\u043e\u043d\u0442\u043e\u0440\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0432\u044b\u0431\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043f\u0430\u043b \u043d\u0430 IndexedDB. <\/p>\n<p>  \u041d\u043e \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u00ab\u041d\u041e\u00bb, \u044d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u00ab\u041d\u041e\u00bb \u2014 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0411\u0414 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 5 \u041c\u0411, \u0447\u0442\u043e \u043e\u0442\u043d\u044e\u0434\u044c \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0432\u0441\u0435 \u044e\u0437\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0433\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 Google Chrome, \u0442\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u0445\u043e\u0434\u0430 \u0442\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435-\u043f\u0440\u043e\u043a\u0441\u0438. \u041f\u0435\u0440\u0435\u043b\u043e\u043f\u0430\u0442\u0438\u0432 \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u044b \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0411\u0414 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438 \u0432 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f:  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-198666","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/198666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198666"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/198666\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}