client/js/full-json.js
changeset 170 603ffa4c6fa5
parent 160 408da84d4dc0
child 282 12ee99b182cd
equal deleted inserted replaced
169:a60a450b8f3b 170:603ffa4c6fa5
     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});
    11             _renkan.renderer.autoScale();
    11             _renkan.renderer.autoScale();
    12         });
    12         });
    13     }
    13     };
    14     var _save = function() {
    14     var _save = function() {
    15         var _data = _proj.toJSON();
    15         var _data = _proj.toJSON();
    16         if (!_renkan.read_only) {
    16         if (!_renkan.read_only) {
    17             Rkns.$.ajax({
    17             Rkns.$.ajax({
    18                 type: _opts.http_method,
    18                 type: _opts.http_method,
    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);
    32     _proj.on("add:nodes add:edges add:users", function(_model) {
    32     _proj.on("add:nodes add:edges add:users", function(_model) {
    33         _model.on("change remove", function(_model) {
    33         _model.on("change remove", function(_model) {
    34             _thrSave();
    34             _thrSave();
    35         });
    35         });
    38     _proj.on("change", function() {
    38     _proj.on("change", function() {
    39         _thrSave();
    39         _thrSave();
    40     });
    40     });
    41         
    41         
    42     _load();
    42     _load();
    43 }
    43 };