{"id":255352,"date":"2015-04-16T12:43:01","date_gmt":"2015-04-16T08:43:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=255352"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=255352","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 JavaScript"},"content":{"rendered":"<p> \t\t\t\u0412 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0445\u043e\u0447\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u0434\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u043f\u0440\u0438\u0447\u0435\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0444\u043e\u0440\u043c\u0443 \u044f \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0441\u044f, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f, \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u043e\u0435. \u041b\u043e\u0433\u0438\u043a\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0430 3 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 2 \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0443 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u043e\u0434\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u043d\u0430\u0432\u0440\u043e\u0434\u0435 Store \u0432 Ext js). \u0421\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 JSON \u0432 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0435\u0434\u0438\u043d\u0438\u0446\u0443. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0432\u0441\u0435 3 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u044e 3 \u0434\u0435\u0440\u0435\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u0443\u0437\u043b\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0432\u0443\u0447\u0438\u0442, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">var Customers = [   {     &quot;FirstName&quot;: &quot;Customer first name 1&quot;,     &quot;LastName&quot;: &quot;Customer second name 1&quot;,     &quot;Id&quot;: &quot;1&quot;,     &quot;JobSpecificsList&quot;: [       {         &quot;Id&quot;: &quot;1&quot;,         &quot;Name&quot;: &quot;Orders group 1&quot;       },       {         &quot;Id&quot;: &quot;2&quot;,         &quot;Name&quot;: &quot;Orders group 2&quot;       }     ],     &quot;WorkTypes&quot;: [       &quot;2&quot;,       &quot;0&quot;,       &quot;1&quot;     ],     &quot;PaymentTypes&quot;: [       &quot;1&quot;,       &quot;2&quot;,       &quot;3&quot;     ]   },   {     &quot;FirstName&quot;: &quot;Customer first name 2&quot;,     &quot;LastName&quot;: &quot;Customer second name 2&quot;,     &quot;Id&quot;: &quot;2&quot;,     &quot;JobSpecificsList&quot;: [       {         &quot;Id&quot;: &quot;1&quot;,         &quot;Name&quot;: &quot;Orders group 1&quot;       },       {         &quot;Id&quot;: &quot;61&quot;,         &quot;Name&quot;: &quot;Orders group 3&quot;       },       {         &quot;Id&quot;: &quot;58&quot;,         &quot;Name&quot;: &quot;Orders group 4&quot;       }     ],     &quot;WorkTypes&quot;: [       &quot;2&quot;,       &quot;0&quot;     ],     &quot;PaymentTypes&quot;: [       &quot;1&quot;     ]   } ]  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u043a\u0430\u0437\u044b<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">var orders = [   {     &quot;Id&quot;:&quot;1&quot;,     &quot;CustomerId&quot;: &quot;1&quot;,     &quot;OrderName&quot;: &quot;Order 1&quot;,     &quot;Start&quot;: &quot;2015-04-12T11:22:00.0000000&quot;,     &quot;End&quot;: &quot;2015-04-12T22:11:00.0000000&quot;   },   {     &quot;Id&quot;:&quot;2&quot;,     &quot;CustomerId&quot;: &quot;2&quot;,     &quot;OrderName&quot;: &quot;Order 2&quot;,     &quot;Start&quot;: &quot;2015-04-12T11:22:00.0000000&quot;,     &quot;End&quot;: &quot;2015-04-12T22:11:00.0000000&quot;   },   {     &quot;Id&quot;:&quot;3&quot;,     &quot;CustomerId&quot;: &quot;1&quot;,     &quot;OrderName&quot;: &quot;Order 3&quot;,     &quot;Start&quot;: &quot;2015-04-12T11:22:00.0000000&quot;,     &quot;End&quot;: &quot;2015-04-05T22:11:00.0000000&quot;   } ]  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">var schedule = [   {     &quot;CustomerId&quot;: &quot;1&quot;,     &quot;StartWeek&quot;: &quot;2015-04-13T00:00:00.000Z&quot;,     &quot;Schedule&quot;: [       {         &quot;Id&quot;: &quot;-1&quot;,         &quot;Start&quot;: &quot;2015-04-15T17:00:00+06:00&quot;,         &quot;End&quot;: &quot;2015-04-15T17:30:00+06:00&quot;,         &quot;WorkType&quot;: &quot;0&quot;         &quot;JobSpecificId&quot;: &quot;-1&quot;,         &quot;PaymentType&quot;: &quot;-1&quot;,       },       {         &quot;Id&quot;: &quot;-1&quot;,         &quot;Start&quot;: &quot;2015-04-16T19:00:00+06:00&quot;,         &quot;End&quot;: &quot;2015-04-16T20:30:00+06:00&quot;,         &quot;WorkType&quot;: &quot;2&quot;,         &quot;JobSpecificId&quot;: &quot;-1&quot;,         &quot;PaymentType&quot;: &quot;-1&quot;       },       {         &quot;Id&quot;: &quot;-1&quot;,         &quot;Start&quot;: &quot;2015-04-19T00:00:00+06:00&quot;,         &quot;End&quot;: &quot;2015-04-19T00:10:00+06:00&quot;,         &quot;WorkType&quot;: &quot;-1&quot;,         &quot;JobSpecificId&quot;: &quot;-1&quot;,         &quot;PaymentType&quot;: &quot;-1&quot;       }     ]   },   {     &quot;CustomerId&quot;: &quot;2&quot;,     &quot;StartWeek&quot;: &quot;2015-04-13T00:00:00.000Z&quot;,     &quot;Schedule&quot;: [       {         &quot;Id&quot;: &quot;-1&quot;,         &quot;Start&quot;: &quot;2015-04-13T00:00:00+06:00&quot;,         &quot;End&quot;: &quot;2015-04-13T00:00:00+06:00&quot;,         &quot;WorkType&quot;: &quot;-1&quot;,         &quot;JobSpecificId&quot;: &quot;-1&quot;,         &quot;PaymentType&quot;: &quot;-1&quot;       }     ]   },   {     &quot;CustomerId&quot;: &quot;25&quot;,     &quot;StartWeek&quot;: &quot;2015-04-13T00:00:00.000Z&quot;,     &quot;Schedule&quot;: [       {         &quot;Id&quot;: &quot;-1&quot;,         &quot;Start&quot;: &quot;2015-04-19T00:00:00+06:00&quot;,         &quot;End&quot;: &quot;2015-04-19T00:00:00+06:00&quot;,         &quot;WorkType&quot;: &quot;-1&quot;,         &quot;JobSpecificId&quot;: &quot;-1&quot;,         &quot;PaymentType&quot;: &quot;-1&quot;       }     ]   } ]  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u0432, \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u043a\u0430\u0437\u043e\u0432 \u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438. \u0412 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0443\u0440\u044c\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043d\u0435\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u044b. \u0412 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\/\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u0443\u0440\u044c\u0435\u0440\u0430. \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e. <\/p>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h4>\n<p>  \u041e\u0431\u044a\u0435\u043a\u0442 Store \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0430\u044f:<\/p>\n<pre><code class=\"javascript\">var Store = function(){     var wrapSchedule= undefined;     \u2026     this.loadScheduleList = function(){         ...         wrapSchedule = inMemory(serverResponse);     };     \u2026     this.getScheduleList = function(){ return wrapSchedule };     \u2026     this.saveScheduleList = function(){         var clientResponse= dumpAcc(wrapSchedule);         ...     }; } <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f InMemory \u043a\u0430\u043a \u0440\u0430\u0437 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f inMemory<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">   function inMemory(from) {             return (function getNode() {                 var that = this;                  function facade(innerValue) {                     function facadeArray(_innerValue) {                         return (function(context) {                             return {                                 get: function() {                                     return context;                                 },                                 set: function(value) {                                     context = clone(value);                                 },                                 indexOf: function(index) {                                     return context[index];                                 },                                 push: function (v) {                                     context.push(getNode.call(clone(v)));                                 },                                 splice: function(index, count) {                                     context.splice(index, count);                                 },                                 orderBy: function (comparator) {                                     context.sort(comparator);                                 },                                 filter: function (predicate) {                                     return facadeArray(context.filter(predicate));                                 }                             }                         })(_innerValue);                     }                      function facadeObject(_innerValue) {                         return (function(context) {                             return {                                 get: function() {                                     return context;                                 },                                 set: function(value) {                                     context = clone(value);                                 },                                 update: function(obj) {                                     var keys = Object.keys(obj);                                     for (var prop_i = 0; prop_i &lt; keys.length; prop_i++) {                                         if (context[keys[prop_i]]) {                                             context[keys[prop_i]] = clone(obj[keys[prop_i]]);                                         }                                     }                                 },                                 append: function(obj) {                                     var keys = Object.keys(obj);                                     for (var prop_i = 0; prop_i &lt; keys.length; prop_i++) {                                         context[keys[prop_i]] = clone(obj[keys[prop_i]]);                                     }                                 }                             }                         })(_innerValue);                     }                      function facadePrimitive(_innerValue) {                         return (function(context) {                             return {                                 get: function() {                                     return context;                                 },                                 set: function(value) {                                     context = value;                                 }                             }                         })(_innerValue);                     }                      if (innerValue instanceof Array) {                         return facadeArray(innerValue);                     }                      if (isPrimitive(innerValue)) {                         return facadePrimitive(innerValue);                     }                      return facadeObject(innerValue);                 }                  if (that instanceof Array) {                     for (var i = 0; i &lt; that.length; i++) {                         if (!isPrimitive(that[i]))                             that[i] = getNode.call(that[i]);                         else {                             that[i] = facade(that[i]);                         }                     }                 }                 if (!(that instanceof Array)) {                     for (var prop_i = 0; prop_i &lt; Object.keys(that).length; prop_i++) {                         var field = that[Object.keys(that)[prop_i]];                         if (!isPrimitive(field)) {                             that[Object.keys(that)[prop_i]] = getNode.call(field);                         } else {                             that[Object.keys(that)[prop_i]] = facade(field);                         }                     }                 }                 that = facade(that);                 return that;             }).call(from);     }; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 get, set \u0438\u043b\u0438 \u043b\u044e\u0431\u0443\u044e \u0434\u0440\u0443\u0433\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0443\u0437\u043b\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 facadeArray \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 first, \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u044c\u0435\u0440\u0430 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0435\u0434\u0435\u043b\u044e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0431\u044b \u0442\u0430\u043a: <\/p>\n<pre><code class=\"javascript\">var firstOnWeekPredicate = function(x){     return x.get().CustomerId.get() == &quot;1&quot; && x.get().StartWeek.get() == '2015-04-13T00:00:00.000Z'; }  var scheduleBy\u0421ourierIdAndWeek =  store.getScheduleList().get().first(firstOnWeekPredicate).get().Schedule <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0442\u0430\u043a\u0438\u0435 \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u0430\u043a where, first, last, union, map \u0438 \u0442.\u0434., \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c <a href=\"http:\/\/underscorejs.org\">underscorejs.org<\/a><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u043c\u0430\u0441\u0441\u0438\u0432) scheduleBy\u0421ourierIdAndWeek \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439. <\/p>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<pre><code class=\"javascript\">scheduleBy\u0421ourierIdAndWeek.push({     &quot;Id&quot;: &quot;-1&quot;,     &quot;Start&quot;: &quot;2015-04-15T00:00:00+06:00&quot;,     &quot;End&quot;: &quot;2015-04-15T00:00:00+06:00&quot;,     &quot;WorkType&quot;: &quot;0&quot;     &quot;JobSpecificId&quot;: &quot;-1&quot;,     &quot;PaymentType&quot;: &quot;-1&quot; })  scheduleBy\u0421ourierIdAndWeek.get()[0].update({WorkType: 2}) <\/code><\/pre>\n<p>  \u0412\u0435\u0441\u044c \u00ab\u0444\u0430\u0441\u0430\u0434\u00bb \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 getNode \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u043f\u043e\u0434 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u0434\u044b.<\/p>\n<p>  \u041d\u0443 \u0438 \u0447\u0442\u043e \u0436\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u0438\u0442\u043e\u0433\u0435? \u041c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0443\u0437\u043b\u044b. \u0420\u0430\u0437\u0434\u0430\u043b\u0438 \u0443\u0437\u043b\u044b \u0432 \u0443\u0447\u0430\u0441\u0442\u043a\u0438 \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u043a, \u043a\u0430\u043a \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f dumpAcc.<\/p>\n<pre><code class=\"javascript\">   function dumpAcc(storeAcc) {         return clone((function getNodeValue(acc) {             if (typeof (acc.get ? acc.get() : acc) === &quot;boolean&quot;                 || typeof (acc.get ? acc.get() : acc) === &quot;number&quot;                 || typeof (acc.get ? acc.get() : acc) === &quot;string&quot;) {                 return acc.get ? acc.get() : acc;             }             else if (acc.get() instanceof Array) {                 var _a = [];                 for (var _a_i = 0; _a_i &lt; acc.get().length; _a_i++) {                     _a.push(getNodeValue(acc.get()[_a_i]));                 }                 return _a;             } else {                 var _o = {};                 for (var prop in acc.get()) {                     if (acc.get().hasOwnProperty(prop))                         _o[prop] = getNodeValue(acc.get()[prop]);                 }                 return _o;             }         })(storeAcc));     } <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c clientResponse, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c JSON.stringify(dumpAcc(store.getScheduleList())). <br \/>  \u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 clone, isPrimitive, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b.<\/p>\n<pre><code class=\"javascript\">    function clone(a) {         return JSON.parse(JSON.stringify(a));     }      function isPrimitive(value) {         return typeof (value) === &quot;string&quot; || typeof (value) === &quot;number&quot; || typeof (value) === &quot;boolean&quot;;     } <\/code><\/pre>\n<div class=\"clear\"><\/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\/255881\/\"> http:\/\/habrahabr.ru\/post\/255881\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u0412 \u044d\u0442\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0445\u043e\u0447\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435 \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u0434\u0430\u043b\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043a\u0430\u0436\u0434\u0430\u044f \u044f\u0447\u0435\u0439\u043a\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u043f\u0440\u0438\u0447\u0435\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0443\u0436\u043d\u043e \u0433\u0434\u0435-\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\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-255352","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255352","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=255352"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/255352\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}