1 $.wiki.diff = function(a, b) {
11 for (D = 0; D < MAXD && endD === null; D++) {
14 for (k = -D; k <= D; k += 2) {
15 if (k == -D || (k != D && Vp[k-1] < Vp[k + 1])) {
22 while (x < N && y < M && a[x] == b[y]) {
26 // Avoid comparing long text character by character.
29 step = Math.min(step * 2, N - x, M - y);
31 if (a.substr(x, step) == b.substr(y, step)) {
41 if (x == N && y == M) {
48 // Max D limit reached, diff too big. Bail and just return the whole target text.
55 for (D = endD; D; --D) {
58 if (V[k - 1] === undefined || V[k + 1] > V[k - 1]) {
63 if (result.length && result[0][0] && result[0][1] == px) {
64 result[0][2] = b[py] + result[0][2];
75 if (result.length && !result[0][0] && result[0][1] == px + 1) {
91 $.wiki.patch = function(a, p) {
92 for (i = p.length - 1; i >= 0; -- i) {
95 a = a.substr(0, c[1]) + c[2] + a.substr(c[1]);
97 a = a.substr(0, c[1]) + a.substr(c[1] + c[2]);