Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (mobwrite.debug) {
window.console.warn("Patch failed: " + patches[x]);
}
} else {
// Found a match. :)
delta = start_loc - expected_loc;
var text2 = text.substring(start_loc, start_loc + text1.length);
// Run a diff to get a framework of equivalent indices.
var diffs = this.shareObj.dmp.diff_main(text1, text2, false);
var index1 = 0;
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 (mobwrite.debug) {
window.console.warn('Patch failed: ' + patches[x]);
}
} else {
// Found a match. :)
delta = start_loc - expected_loc;
var text2 = text.substring(start_loc, start_loc + text1.length);
// Run a diff to get a framework of equivalent indices.
var diffs = this.dmp.diff_main(text1, text2, false);
var index1 = 0;
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.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.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 (mobwrite.debug) {
window.console.warn('Patch failed: ' + patches[x]);
}
} else {
// Found a match. :)
delta = start_loc - expected_loc;
var text2 = text.substring(start_loc, start_loc + text1.length);
// Run a diff to get a framework of equivalent indices.
var diffs = this.dmp.diff_main(text1, text2, false);
var index1 = 0;
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.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.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 (mobwrite.debug) {
window.console.warn('Patch failed: ' + patches[x]);
}
} else {
// Found a match. :)
delta = start_loc - expected_loc;
var text2 = text.substring(start_loc, start_loc + text1.length);
// Run a diff to get a framework of equivalent indices.
var diffs = this.dmp.diff_main(text1, text2, false);
var index1 = 0;
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.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.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++) {
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),
* Unless required by applicable law or agreed to in writing, software
* 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/';
* 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("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/';