Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (mod[0] === diff_match_patch.DIFF_DELETE) {
var del_start = start_loc + index2;
var del_end = start_loc + this.dmp.diff_xIndex(diffs,
index1 + mod[1].length);
text = text.substring(0, del_start) + text.substring(del_end);
for (i = 0; i < offsets.length; i++) {
if (offsets[i] + nullPadding.length > del_start) {
if (offsets[i] + nullPadding.length < del_end) {
offsets[i] = del_start - nullPadding.length;
} else {
offsets[i] -= del_end - del_start;
}
}
}
}
if (mod[0] !== diff_match_patch.DIFF_DELETE) {
index1 += mod[1].length;
}
}
}
}
// Strip the padding off.
text = text.substring(nullPadding.length, text.length - nullPadding.length);
return text;
},
} else if (mod[0] === diff_match_patch.DIFF_DELETE) {
var del_start = start_loc + index2;
var del_end = start_loc + this.dmp.diff_xIndex(diffs,
index1 + mod[1].length);
text = text.substring(0, del_start) + text.substring(del_end);
for (i = 0; i < offsets.length; i++) {
if (offsets[i] + nullPadding.length > del_start) {
if (offsets[i] + nullPadding.length < del_end) {
offsets[i] = del_start - nullPadding.length;
} else {
offsets[i] -= del_end - del_start;
}
}
}
}
if (mod[0] !== diff_match_patch.DIFF_DELETE) {
index1 += mod[1].length;
}
}
}
}
// Strip the padding off.
text = text.substring(nullPadding.length, text.length - nullPadding.length);
return text;
},
} else if (mod[0] === diff_match_patch.DIFF_DELETE) {
var del_start = start_loc + index2;
var del_end = start_loc + this.dmp.diff_xIndex(diffs,
index1 + mod[1].length);
text = text.substring(0, del_start) + text.substring(del_end);
for (i = 0; i < offsets.length; i++) {
if (offsets[i] + nullPadding.length > del_start) {
if (offsets[i] + nullPadding.length < del_end) {
offsets[i] = del_start - nullPadding.length;
} else {
offsets[i] -= del_end - del_start;
}
}
}
}
if (mod[0] !== diff_match_patch.DIFF_DELETE) {
index1 += mod[1].length;
}
}
}
}
// Strip the padding off.
text = text.substring(nullPadding.length, text.length - nullPadding.length);
return text;
},
case diff_match_patch.DIFF_EQUAL:
offset += region[1].length;
break;
case diff_match_patch.DIFF_INSERT:
var end = offset + region[1].length;
changes.push({
type: diff_match_patch.DIFF_INSERT,
start: session.convertOffsetToRowCol(offset),
end: session.convertOffsetToRowCol(end)
});
offset = end;
console.log("insert", region[1].length, " chars");
break;
case diff_match_patch.DIFF_DELETE:
changes.push({
type: diff_match_patch.DIFF_DELETE,
start: session.convertOffsetToRowCol(offset),
end: session.convertOffsetToRowCol(offset)
});
console.log("delete", region[1].length, " chars");
break;
default:
console.error("delta region with unknown type");
}
});
delta.forEach(function(region) {
switch (region[0]) {
case diff_match_patch.DIFF_EQUAL:
offset += region[1].length;
break;
case diff_match_patch.DIFF_INSERT:
var end = offset + region[1].length;
changes.push({
type: diff_match_patch.DIFF_INSERT,
start: session.convertOffsetToRowCol(offset),
end: session.convertOffsetToRowCol(end)
});
offset = end;
console.log("insert", region[1].length, " chars");
break;
case diff_match_patch.DIFF_DELETE:
changes.push({
type: diff_match_patch.DIFF_DELETE,
start: session.convertOffsetToRowCol(offset),
end: session.convertOffsetToRowCol(offset)
});
console.log("delete", region[1].length, " chars");
break;
default:
console.error("delta region with unknown type");
}
});
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview This client-side code drives the synchronisation.
* @author fraser@google.com (Neil Fraser)
*/
var server = require("plugins").getObject("server");
var diff_match_patch = require("diff");
var DIFF_EQUAL = diff_match_patch.DIFF_EQUAL;
var DIFF_DELETE = diff_match_patch.DIFF_DELETE;
var DIFF_INSERT = diff_match_patch.DIFF_INSERT;
/**
* Singleton class containing all MobWrite code.
*/
var mobwrite = {};
/**
* URL of Ajax gateway.
* @type {string}
*/
mobwrite.syncGateway = '/mobwrite/';
/**
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview This client-side code drives the synchronisation.
* @author fraser@google.com (Neil Fraser)
*/
var server = require("bespin_server").server;
var diff_match_patch = require("diff");
var DIFF_EQUAL = diff_match_patch.DIFF_EQUAL;
var DIFF_DELETE = diff_match_patch.DIFF_DELETE;
var DIFF_INSERT = diff_match_patch.DIFF_INSERT;
/**
* Singleton class containing all MobWrite code.
*/
var mobwrite = {};
/**
* URL of Ajax gateway.
* @type {string}
*/
mobwrite.syncGateway = '/mobwrite/';
/**
var index2;
var i;
for (var y = 0; y < patches[x].diffs.length; y++) {
var mod = patches[x].diffs[y];
if (mod[0] !== diff_match_patch.DIFF_EQUAL) {
index2 = this.shareObj.dmp.diff_xIndex(diffs, index1);
}
if (mod[0] === diff_match_patch.DIFF_INSERT) {
text = text.substring(0, start_loc + index2) + mod[1] +
text.substring(start_loc + index2);
for (i = 0; i < offsets.length; i++) {
if (offsets[i] + nullPadding.length > start_loc + index2) {
offsets[i] += mod[1].length;
}
}
} else if (mod[0] === diff_match_patch.DIFF_DELETE) {
var del_start = start_loc + index2;
var del_end = start_loc + this.shareObj.dmp.diff_xIndex(diffs,
index1 + mod[1].length);
text = text.substring(0, del_start) + text.substring(del_end);
for (i = 0; i < offsets.length; i++) {
if (offsets[i] + nullPadding.length > del_start) {
if (offsets[i] + nullPadding.length < del_end) {
offsets[i] = del_start - nullPadding.length;
} else {
offsets[i] -= del_end - del_start;
}
}
}
}
if (mod[0] !== diff_match_patch.DIFF_DELETE) {
index1 += mod[1].length;