non-important update

This commit is contained in:
DadaMonad
2015-04-14 17:14:43 +00:00
parent 4de979bc33
commit 5417ffb999
18 changed files with 13595 additions and 4665 deletions

View File

@@ -1,6 +1,6 @@
var slice = [].slice,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
var __slice = [].slice,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
module.exports = function() {
var execution_listener, ops;
@@ -51,19 +51,19 @@ module.exports = function() {
} else {
callon = this;
}
return this.forwardEvent.apply(this, [callon].concat(slice.call(arguments)));
return this.forwardEvent.apply(this, [callon].concat(__slice.call(arguments)));
};
Operation.prototype.forwardEvent = function() {
var args, f, j, len, op, ref, results;
op = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
ref = this.event_listeners;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
f = ref[j];
results.push(f.call.apply(f, [op].concat(slice.call(args))));
var args, f, op, _i, _len, _ref, _results;
op = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
_ref = this.event_listeners;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
f = _ref[_i];
_results.push(f.call.apply(f, [op].concat(__slice.call(args))));
}
return results;
return _results;
};
Operation.prototype.isDeleted = function() {
@@ -88,8 +88,8 @@ module.exports = function() {
return this.deleteAllObservers();
};
Operation.prototype.setParent = function(parent1) {
this.parent = parent1;
Operation.prototype.setParent = function(_at_parent) {
this.parent = _at_parent;
};
Operation.prototype.getParent = function() {
@@ -112,26 +112,26 @@ module.exports = function() {
};
Operation.prototype.cloneUid = function() {
var n, ref, uid, v;
var n, uid, v, _ref;
uid = {};
ref = this.getUid();
for (n in ref) {
v = ref[n];
_ref = this.getUid();
for (n in _ref) {
v = _ref[n];
uid[n] = v;
}
return uid;
};
Operation.prototype.execute = function() {
var j, l, len;
var l, _i, _len;
this.is_executed = true;
if (this.uid == null) {
this.uid = this.HB.getNextOperationIdentifier();
}
if (this.uid.noOperation == null) {
this.HB.addOperation(this);
for (j = 0, len = execution_listener.length; j < len; j++) {
l = execution_listener[j];
for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
l = execution_listener[_i];
l(this._encode());
}
}
@@ -168,12 +168,12 @@ module.exports = function() {
};
Operation.prototype.validateSavedOperations = function() {
var name, op, op_uid, ref, success, uninstantiated;
var name, op, op_uid, success, uninstantiated, _ref;
uninstantiated = {};
success = this;
ref = this.unchecked;
for (name in ref) {
op_uid = ref[name];
_ref = this.unchecked;
for (name in _ref) {
op_uid = _ref[name];
op = this.HB.getOperation(op_uid);
if (op) {
this[name] = op;
@@ -190,15 +190,15 @@ module.exports = function() {
};
Operation.prototype.getCustomType = function() {
var Type, j, len, ref, t;
var Type, t, _i, _len, _ref;
if (this.custom_type == null) {
return this;
} else {
if (this.custom_type.constructor === String) {
Type = this.custom_types;
ref = this.custom_type.split(".");
for (j = 0, len = ref.length; j < len; j++) {
t = ref[j];
_ref = this.custom_type.split(".");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
t = _ref[_i];
Type = Type[t];
}
this.custom_type = new Type();
@@ -211,8 +211,8 @@ module.exports = function() {
return Operation;
})();
ops.Delete = (function(superClass) {
extend(Delete, superClass);
ops.Delete = (function(_super) {
__extends(Delete, _super);
function Delete(custom_type, uid, deletes) {
this.saveOperation('deletes', deletes);
@@ -250,8 +250,8 @@ module.exports = function() {
uid = o['uid'], deletes_uid = o['deletes'];
return new this(null, uid, deletes_uid);
};
ops.Insert = (function(superClass) {
extend(Insert, superClass);
ops.Insert = (function(_super) {
__extends(Insert, _super);
function Insert(custom_type, content, parent, uid, prev_cl, next_cl, origin) {
if (content === void 0) {
@@ -282,30 +282,38 @@ module.exports = function() {
}
};
Insert.prototype.getNext = function() {
Insert.prototype.getNext = function(i) {
var n;
n = this.next_cl;
while (n.is_deleted && (n.next_cl != null)) {
if (i == null) {
i = 1;
}
n = this;
while (i > 0 && n.is_deleted && (n.next_cl != null)) {
n = n.next_cl;
if (!n.is_deleted) {
i--;
}
}
return n;
};
Insert.prototype.getPrev = function() {
Insert.prototype.getPrev = function(i) {
var n;
n((function(_this) {
return function() {
return _this.prev_cl;
};
})(this));
while (n.is_deleted && (n.prev_cl != null)) {
if (i == null) {
i = 1;
}
n = this;
while (i > 0 && n.is_deleted && (n.prev_cl != null)) {
n = n.prev_cl;
if (!n.is_deleted) {
i--;
}
}
return n;
};
Insert.prototype.applyDelete = function(o) {
var callLater, garbagecollect, ref;
var callLater, garbagecollect, _ref;
if (this.deleted_by == null) {
this.deleted_by = [];
}
@@ -324,17 +332,17 @@ module.exports = function() {
if (callLater) {
this.parent.callOperationSpecificDeleteEvents(this, o);
}
if ((ref = this.prev_cl) != null ? ref.isDeleted() : void 0) {
if ((_ref = this.prev_cl) != null ? _ref.isDeleted() : void 0) {
return this.prev_cl.applyDelete();
}
};
Insert.prototype.cleanup = function() {
var d, j, len, o, ref;
var d, o, _i, _len, _ref;
if (this.next_cl.isDeleted()) {
ref = this.deleted_by;
for (j = 0, len = ref.length; j < len; j++) {
d = ref[j];
_ref = this.deleted_by;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
d = _ref[_i];
d.cleanup();
}
o = this.next_cl;
@@ -372,14 +380,14 @@ module.exports = function() {
};
Insert.prototype.execute = function() {
var base, distance_to_origin, i, o;
var distance_to_origin, i, o, _base;
if (!this.validateSavedOperations()) {
return false;
} else {
if (this.content instanceof ops.Operation) {
this.content.insert_parent = this;
if ((base = this.content).referenced_by == null) {
base.referenced_by = 0;
if ((_base = this.content).referenced_by == null) {
_base.referenced_by = 0;
}
this.content.referenced_by++;
}
@@ -453,7 +461,7 @@ module.exports = function() {
};
Insert.prototype._encode = function(json) {
var ref;
var _ref;
if (json == null) {
json = {};
}
@@ -465,7 +473,7 @@ module.exports = function() {
} else if (this.origin !== this.prev_cl) {
json.origin = this.origin.getUid();
}
if (((ref = this.content) != null ? ref.getUid : void 0) != null) {
if (((_ref = this.content) != null ? _ref.getUid : void 0) != null) {
json['content'] = this.content.getUid();
} else {
json['content'] = JSON.stringify(this.content);
@@ -484,8 +492,8 @@ module.exports = function() {
}
return new this(null, content, parent, uid, prev, next, origin);
};
ops.Delimiter = (function(superClass) {
extend(Delimiter, superClass);
ops.Delimiter = (function(_super) {
__extends(Delimiter, _super);
function Delimiter(prev_cl, next_cl, origin) {
this.saveOperation('prev_cl', prev_cl);
@@ -514,10 +522,10 @@ module.exports = function() {
};
Delimiter.prototype.execute = function() {
var ref, ref1;
if (((ref = this.unchecked) != null ? ref['next_cl'] : void 0) != null) {
var _ref, _ref1;
if (((_ref = this.unchecked) != null ? _ref['next_cl'] : void 0) != null) {
return Delimiter.__super__.execute.apply(this, arguments);
} else if ((ref1 = this.unchecked) != null ? ref1['prev_cl'] : void 0) {
} else if ((_ref1 = this.unchecked) != null ? _ref1['prev_cl'] : void 0) {
if (this.validateSavedOperations()) {
if (this.prev_cl.next_cl != null) {
throw new Error("Probably duplicated operations");
@@ -537,12 +545,12 @@ module.exports = function() {
};
Delimiter.prototype._encode = function() {
var ref, ref1;
var _ref, _ref1;
return {
'type': this.type,
'uid': this.getUid(),
'prev': (ref = this.prev_cl) != null ? ref.getUid() : void 0,
'next': (ref1 = this.next_cl) != null ? ref1.getUid() : void 0
'prev': (_ref = this.prev_cl) != null ? _ref.getUid() : void 0,
'next': (_ref1 = this.next_cl) != null ? _ref1.getUid() : void 0
};
};

View File

@@ -1,6 +1,6 @@
var basic_ops_uninitialized,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
basic_ops_uninitialized = require("./Basic");
@@ -8,8 +8,8 @@ module.exports = function() {
var basic_ops, ops;
basic_ops = basic_ops_uninitialized();
ops = basic_ops.operations;
ops.MapManager = (function(superClass) {
extend(MapManager, superClass);
ops.MapManager = (function(_super) {
__extends(MapManager, _super);
function MapManager(custom_type, uid) {
this._map = {};
@@ -19,10 +19,10 @@ module.exports = function() {
MapManager.prototype.type = "MapManager";
MapManager.prototype.applyDelete = function() {
var name, p, ref;
ref = this._map;
for (name in ref) {
p = ref[name];
var name, p, _ref;
_ref = this._map;
for (name in _ref) {
p = _ref[name];
p.applyDelete();
}
return MapManager.__super__.applyDelete.call(this);
@@ -33,17 +33,17 @@ module.exports = function() {
};
MapManager.prototype.map = function(f) {
var n, ref, v;
ref = this._map;
for (n in ref) {
v = ref[n];
var n, v, _ref;
_ref = this._map;
for (n in _ref) {
v = _ref[n];
f(n, v);
}
return void 0;
};
MapManager.prototype.val = function(name, content) {
var o, prop, ref, rep, res, result;
var o, prop, rep, res, result, _ref;
if (arguments.length > 1) {
if ((content != null) && (content._getModel != null)) {
rep = content._getModel(this.custom_types, this.operations);
@@ -66,9 +66,9 @@ module.exports = function() {
}
} else {
result = {};
ref = this._map;
for (name in ref) {
o = ref[name];
_ref = this._map;
for (name in _ref) {
o = _ref[name];
if (!o.isContentDeleted()) {
result[name] = o.val();
}
@@ -78,9 +78,9 @@ module.exports = function() {
};
MapManager.prototype["delete"] = function(name) {
var ref;
if ((ref = this._map[name]) != null) {
ref.deleteContent();
var _ref;
if ((_ref = this._map[name]) != null) {
_ref.deleteContent();
}
return this;
};
@@ -113,8 +113,8 @@ module.exports = function() {
uid = json['uid'], custom_type = json['custom_type'];
return new this(custom_type, uid);
};
ops.ListManager = (function(superClass) {
extend(ListManager, superClass);
ops.ListManager = (function(_super) {
__extends(ListManager, _super);
function ListManager(custom_type, uid) {
this.beginning = new ops.Delimiter(void 0, void 0);
@@ -142,25 +142,25 @@ module.exports = function() {
};
ListManager.prototype.toJson = function(transform_to_value) {
var i, j, len, o, results, val;
var i, o, val, _i, _len, _results;
if (transform_to_value == null) {
transform_to_value = false;
}
val = this.val();
results = [];
for (o = j = 0, len = val.length; j < len; o = ++j) {
_results = [];
for (o = _i = 0, _len = val.length; _i < _len; o = ++_i) {
i = val[o];
if (o instanceof ops.Object) {
results.push(o.toJson(transform_to_value));
_results.push(o.toJson(transform_to_value));
} else if (o instanceof ops.ListManager) {
results.push(o.toJson(transform_to_value));
_results.push(o.toJson(transform_to_value));
} else if (transform_to_value && o instanceof ops.Operation) {
results.push(o.val());
_results.push(o.val());
} else {
results.push(o);
_results.push(o);
}
}
return results;
return _results;
};
ListManager.prototype.execute = function() {
@@ -274,7 +274,7 @@ module.exports = function() {
};
ListManager.prototype.insertAfter = function(left, contents) {
var c, j, len, right, tmp;
var c, right, tmp, _i, _len;
right = left.next_cl;
while (right.isDeleted()) {
right = right.next_cl;
@@ -283,8 +283,8 @@ module.exports = function() {
if (contents instanceof ops.Operation) {
(new ops.Insert(null, content, void 0, void 0, left, right)).execute();
} else {
for (j = 0, len = contents.length; j < len; j++) {
c = contents[j];
for (_i = 0, _len = contents.length; _i < _len; _i++) {
c = contents[_i];
if ((c != null) && (c._name != null) && (c._getModel != null)) {
c = c._getModel(this.custom_types, this.operations);
}
@@ -302,13 +302,13 @@ module.exports = function() {
};
ListManager.prototype["delete"] = function(position, length) {
var d, delete_ops, i, j, o, ref;
var d, delete_ops, i, o, _i;
if (length == null) {
length = 1;
}
o = this.getOperationByPosition(position + 1);
delete_ops = [];
for (i = j = 0, ref = length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {
if (o instanceof ops.Delimiter) {
break;
}
@@ -363,11 +363,11 @@ module.exports = function() {
uid = json['uid'], custom_type = json['custom_type'];
return new this(custom_type, uid);
};
ops.Composition = (function(superClass) {
extend(Composition, superClass);
ops.Composition = (function(_super) {
__extends(Composition, _super);
function Composition(custom_type, composition_value1, uid, composition_ref) {
this.composition_value = composition_value1;
function Composition(custom_type, _at_composition_value, uid, composition_ref) {
this.composition_value = _at_composition_value;
Composition.__super__.constructor.call(this, custom_type, uid);
if (composition_ref) {
this.saveOperation('composition_ref', composition_ref);
@@ -431,12 +431,12 @@ module.exports = function() {
uid = json['uid'], custom_type = json['custom_type'], composition_value = json['composition_value'], composition_ref = json['composition_ref'];
return new this(custom_type, JSON.parse(composition_value), uid, composition_ref);
};
ops.ReplaceManager = (function(superClass) {
extend(ReplaceManager, superClass);
ops.ReplaceManager = (function(_super) {
__extends(ReplaceManager, _super);
function ReplaceManager(custom_type, event_properties1, event_this1, uid) {
this.event_properties = event_properties1;
this.event_this = event_this1;
function ReplaceManager(custom_type, _at_event_properties, _at_event_this, uid) {
this.event_properties = _at_event_properties;
this.event_this = _at_event_this;
if (this.event_properties['object'] == null) {
this.event_properties['object'] = this.event_this.getCustomType();
}
@@ -446,13 +446,13 @@ module.exports = function() {
ReplaceManager.prototype.type = "ReplaceManager";
ReplaceManager.prototype.callEventDecorator = function(events) {
var event, j, len, name, prop, ref;
var event, name, prop, _i, _len, _ref;
if (!this.isDeleted()) {
for (j = 0, len = events.length; j < len; j++) {
event = events[j];
ref = this.event_properties;
for (name in ref) {
prop = ref[name];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
_ref = this.event_properties;
for (name in _ref) {
prop = _ref[name];
event[name] = prop;
}
}