]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/platform/src/data/sync/CS.js
2 Ext
.data
.CS
= Ext
.extend(Object
, { // Change Stamp
4 r
: 0, // replica_number
5 t
: 0, // time, in seconds since the epoch
6 s
: 0, // sequence number
8 constructor: function(config
) {
13 if (typeof x
=== 'string' || x
instanceof String
) {
15 } else if (typeof x
=== 'object') {
22 changeReplicaNumber: function(old_replica_number
,new_replica_number
) {
23 if (this.r
==old_replica_number
) {
24 this.r
= new_replica_number
;
30 greaterThan: function(x
) { return this.compare(x
)>0; },
31 lessThan: function(x
) { return this.compare(x
)<0; },
32 equals: function(x
) { return this.compare(x
)===0 },
33 compare: function(x
) {
45 var m
= t
.match(/(\d+)-(\d+)-?(\d+)?/)
46 if (m
&& m
.length
>0) {
47 this.r
= parseInt(m
[1])
48 this.t
= parseInt(m
[2])
49 this.s
= m
[3] ? parseInt(m
[3]) : 0
51 throw "Error - CS - Bad change stamp '"+t
+"'."
57 return this.r
+"-"+this.t
+(this.s
>0 ? "-"+this.s
: "");