client/js/full-json.js
changeset 293 fba23fde14ba
parent 282 12ee99b182cd
child 307 eaadfa988db4
equal deleted inserted replaced
292:f67047a16084 293:fba23fde14ba
     1 /* Saves the Full JSON at each modification */
     1 /* Saves the Full JSON at each modification */
     2 
     2 
     3 Rkns.jsonIO = function(_renkan, _opts) {
     3 Rkns.jsonIO = function(_renkan, _opts) {
     4     var _proj = _renkan.project;
     4     var _proj = _renkan.project;
     5     if (typeof _opts.http_method == "undefined") {
     5     if (typeof _opts.http_method === "undefined") {
     6         _opts.http_method = 'PUT';
     6         _opts.http_method = 'PUT';
     7     }
     7     }
     8     var _load = function() {
     8     var _load = function() {
     9         Rkns.$.getJSON(_opts.url, function(_data) {
     9         Rkns.$.getJSON(_opts.url, function(_data) {
    10             _proj.set(_data, {validate: true});
    10             _proj.set(_data, {validate: true});
    21                 data: JSON.stringify(_data),
    21                 data: JSON.stringify(_data),
    22                 success: function(data, textStatus, jqXHR) {
    22                 success: function(data, textStatus, jqXHR) {
    23                 }
    23                 }
    24             });
    24             });
    25         }
    25         }
    26         
    26 
    27     };
    27     };
    28     var _thrSave = Rkns._.throttle(
    28     var _thrSave = Rkns._.throttle(
    29         function() {
    29         function() {
    30             setTimeout(_save, 100);
    30             setTimeout(_save, 100);
    31         }, 1000);
    31         }, 1000);
    36         _thrSave();
    36         _thrSave();
    37     });
    37     });
    38     _proj.on("change", function() {
    38     _proj.on("change", function() {
    39         _thrSave();
    39         _thrSave();
    40     });
    40     });
    41         
    41 
    42     _load();
    42     _load();
    43 };
    43 };