Added safe request wrapper for mitigating errors on mobile
This commit is contained in:
parent
570057a717
commit
a747f89b71
318
js-compiled.js
318
js-compiled.js
|
@ -102,7 +102,7 @@ function fa(a) {
|
||||||
if (x(h) || null != h.f && " " != w(h)) {
|
if (x(h) || null != h.f && " " != w(h)) {
|
||||||
a.context.fillStyle = null != h.f ? "#DEF" : "#F5F5F5", b.fillRect(9 * g - a.offset.x, 17 * (k - 1) - a.offset.y, 9, 17);
|
a.context.fillStyle = null != h.f ? "#DEF" : "#F5F5F5", b.fillRect(9 * g - a.offset.x, 17 * (k - 1) - a.offset.y, 9, 17);
|
||||||
}
|
}
|
||||||
var t = E(a.state, new l(g, k));
|
var t = ga(a.state, new l(g, k));
|
||||||
null == t || x(h) && !e || (a.context.fillStyle = "#000000", b.fillText(t, 9 * g - a.offset.x, 17 * k - a.offset.y - 3));
|
null == t || x(h) && !e || (a.context.fillStyle = "#000000", b.fillText(t, 9 * g - a.offset.x, 17 * k - a.offset.y - 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,62 +126,62 @@ function fa(a) {
|
||||||
function B(a, b) {
|
function B(a, b) {
|
||||||
return new l(Math.min(Math.max(1, Math.round(((new l((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).x - 4.5) / 9)), 1998), Math.min(Math.max(1, Math.round(((new l((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).y + 8.5) / 17)), 598));
|
return new l(Math.min(Math.max(1, Math.round(((new l((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).x - 4.5) / 9)), 1998), Math.min(Math.max(1, Math.round(((new l((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).y + 8.5) / 17)), 598));
|
||||||
}
|
}
|
||||||
;function F(a, b, c, d, e) {
|
;function E(a, b, c, d, e) {
|
||||||
e = e || "+";
|
e = e || "+";
|
||||||
var g = Math.min(b.x, c.x), k = Math.min(b.y, c.y), h = Math.max(b.x, c.x), t = Math.max(b.y, c.y), u = d ? c.x : b.x;
|
var g = Math.min(b.x, c.x), k = Math.min(b.y, c.y), h = Math.max(b.x, c.x), t = Math.max(b.y, c.y), u = d ? c.x : b.x;
|
||||||
for (d = d ? b.y : c.y;g++ < h;) {
|
for (d = d ? b.y : c.y;g++ < h;) {
|
||||||
var Q = new l(g, d), D = a.getContext(new l(g, d));
|
var Q = new l(g, d), D = a.getContext(new l(g, d));
|
||||||
" " == e && 2 == D.m + D.j || H(a, Q, e);
|
" " == e && 2 == D.m + D.j || F(a, Q, e);
|
||||||
}
|
}
|
||||||
for (;k++ < t;) {
|
for (;k++ < t;) {
|
||||||
Q = new l(u, k), D = a.getContext(new l(u, k)), " " == e && 2 == D.left + D.right || H(a, Q, e);
|
Q = new l(u, k), D = a.getContext(new l(u, k)), " " == e && 2 == D.left + D.right || F(a, Q, e);
|
||||||
}
|
}
|
||||||
I(a, b, e);
|
H(a, b, e);
|
||||||
I(a, c, e);
|
H(a, c, e);
|
||||||
H(a, new l(u, d), e);
|
F(a, new l(u, d), e);
|
||||||
}
|
}
|
||||||
function J(a) {
|
function I(a) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.a = null;
|
this.a = null;
|
||||||
}
|
}
|
||||||
J.prototype.start = function(a) {
|
I.prototype.start = function(a) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
};
|
};
|
||||||
J.prototype.move = function(a) {
|
I.prototype.move = function(a) {
|
||||||
this.g = a;
|
this.g = a;
|
||||||
|
J(this.state);
|
||||||
|
E(this.state, this.a, a, !0);
|
||||||
|
E(this.state, this.a, a, !1);
|
||||||
|
};
|
||||||
|
I.prototype.end = function() {
|
||||||
K(this.state);
|
K(this.state);
|
||||||
F(this.state, this.a, a, !0);
|
|
||||||
F(this.state, this.a, a, !1);
|
|
||||||
};
|
};
|
||||||
J.prototype.end = function() {
|
I.prototype.l = function() {
|
||||||
L(this.state);
|
|
||||||
};
|
|
||||||
J.prototype.l = function() {
|
|
||||||
return "crosshair";
|
return "crosshair";
|
||||||
};
|
};
|
||||||
J.prototype.e = function() {
|
I.prototype.e = function() {
|
||||||
};
|
};
|
||||||
function M(a) {
|
function L(a) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.a = null;
|
this.a = null;
|
||||||
}
|
}
|
||||||
M.prototype.start = function(a) {
|
L.prototype.start = function(a) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
};
|
};
|
||||||
M.prototype.move = function(a) {
|
L.prototype.move = function(a) {
|
||||||
K(this.state);
|
J(this.state);
|
||||||
var b = this.state.getContext(this.a), c = this.state.getContext(a);
|
var b = this.state.getContext(this.a), c = this.state.getContext(a);
|
||||||
F(this.state, this.a, a, b.m && b.j || c.left && c.right);
|
E(this.state, this.a, a, b.m && b.j || c.left && c.right);
|
||||||
};
|
};
|
||||||
M.prototype.end = function() {
|
L.prototype.end = function() {
|
||||||
L(this.state);
|
K(this.state);
|
||||||
};
|
};
|
||||||
M.prototype.l = function() {
|
L.prototype.l = function() {
|
||||||
return "crosshair";
|
return "crosshair";
|
||||||
};
|
};
|
||||||
M.prototype.e = function() {
|
L.prototype.e = function() {
|
||||||
};
|
};
|
||||||
function N(a, b) {
|
function M(a, b) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.value = b;
|
this.value = b;
|
||||||
f && ($("#freeform-tool-input").val(""), $("#freeform-tool-input").hide(0, function() {
|
f && ($("#freeform-tool-input").val(""), $("#freeform-tool-input").hide(0, function() {
|
||||||
|
@ -190,84 +190,84 @@ function N(a, b) {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
N.prototype.start = function(a) {
|
M.prototype.start = function(a) {
|
||||||
I(this.state, a, this.value);
|
H(this.state, a, this.value);
|
||||||
};
|
};
|
||||||
N.prototype.move = function(a) {
|
M.prototype.move = function(a) {
|
||||||
I(this.state, a, this.value);
|
H(this.state, a, this.value);
|
||||||
};
|
};
|
||||||
N.prototype.end = function() {
|
M.prototype.end = function() {
|
||||||
L(this.state);
|
K(this.state);
|
||||||
};
|
};
|
||||||
N.prototype.l = function() {
|
M.prototype.l = function() {
|
||||||
return "crosshair";
|
return "crosshair";
|
||||||
};
|
};
|
||||||
N.prototype.e = function(a) {
|
M.prototype.e = function(a) {
|
||||||
f && (this.value = $("#freeform-tool-input").val().substr(0, 1), $("#freeform-tool-input").blur(), $("#freeform-tool-input").hide(0));
|
f && (this.value = $("#freeform-tool-input").val().substr(0, 1), $("#freeform-tool-input").blur(), $("#freeform-tool-input").hide(0));
|
||||||
1 == a.length && (this.value = a);
|
1 == a.length && (this.value = a);
|
||||||
};
|
};
|
||||||
function O(a) {
|
function N(a) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.a = null;
|
this.a = null;
|
||||||
}
|
}
|
||||||
O.prototype.start = function(a) {
|
N.prototype.start = function(a) {
|
||||||
L(this.state);
|
K(this.state);
|
||||||
$("#text-tool-input").val("");
|
$("#text-tool-input").val("");
|
||||||
this.a = a;
|
this.a = a;
|
||||||
a = w(C(this.state, this.a));
|
a = w(C(this.state, this.a));
|
||||||
I(this.state, this.a, null == a ? "\u2009" : a);
|
H(this.state, this.a, null == a ? "\u2009" : a);
|
||||||
};
|
};
|
||||||
O.prototype.move = function() {
|
N.prototype.move = function() {
|
||||||
};
|
};
|
||||||
O.prototype.end = function() {
|
N.prototype.end = function() {
|
||||||
null != this.a && (this.g = this.a, this.a = null, $("#text-tool-widget").hide(0, function() {
|
null != this.a && (this.g = this.a, this.a = null, $("#text-tool-widget").hide(0, function() {
|
||||||
$("#text-tool-widget").show(0, function() {
|
$("#text-tool-widget").show(0, function() {
|
||||||
$("#text-tool-input").focus();
|
$("#text-tool-input").focus();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
O.prototype.l = function() {
|
N.prototype.l = function() {
|
||||||
return "pointer";
|
return "pointer";
|
||||||
};
|
};
|
||||||
O.prototype.e = function() {
|
N.prototype.e = function() {
|
||||||
var a = $("#text-tool-input").val();
|
var a = $("#text-tool-input").val();
|
||||||
K(this.state);
|
J(this.state);
|
||||||
for (var b = 0, c = 0, d = 0;d < a.length;d++) {
|
for (var b = 0, c = 0, d = 0;d < a.length;d++) {
|
||||||
"\n" == a[d] ? (c++, b = 0) : (I(this.state, this.g.add(new l(b, c)), a[d]), b++);
|
"\n" == a[d] ? (c++, b = 0) : (H(this.state, this.g.add(new l(b, c)), a[d]), b++);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function P(a) {
|
function O(a) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.g = this.a = null;
|
this.g = this.a = null;
|
||||||
}
|
}
|
||||||
P.prototype.start = function(a) {
|
O.prototype.start = function(a) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.move(a);
|
this.move(a);
|
||||||
};
|
};
|
||||||
P.prototype.move = function(a) {
|
O.prototype.move = function(a) {
|
||||||
K(this.state);
|
J(this.state);
|
||||||
this.g = a;
|
this.g = a;
|
||||||
var b = Math.min(this.a.x, this.g.x);
|
var b = Math.min(this.a.x, this.g.x);
|
||||||
a = Math.min(this.a.y, this.g.y);
|
a = Math.min(this.a.y, this.g.y);
|
||||||
for (var c = Math.max(this.a.x, this.g.x), d = Math.max(this.a.y, this.g.y);b <= c;b++) {
|
for (var c = Math.max(this.a.x, this.g.x), d = Math.max(this.a.y, this.g.y);b <= c;b++) {
|
||||||
for (var e = a;e <= d;e++) {
|
for (var e = a;e <= d;e++) {
|
||||||
I(this.state, new l(b, e), "\u2009");
|
H(this.state, new l(b, e), "\u2009");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
P.prototype.end = function() {
|
O.prototype.end = function() {
|
||||||
L(this.state);
|
K(this.state);
|
||||||
};
|
};
|
||||||
P.prototype.l = function() {
|
O.prototype.l = function() {
|
||||||
return "crosshair";
|
return "crosshair";
|
||||||
};
|
};
|
||||||
P.prototype.e = function() {
|
O.prototype.e = function() {
|
||||||
};
|
};
|
||||||
function R(a) {
|
function P(a) {
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.h = this.a = null;
|
this.h = this.a = null;
|
||||||
}
|
}
|
||||||
R.prototype.start = function(a) {
|
P.prototype.start = function(a) {
|
||||||
if (f && !x(C(this.state, a))) {
|
if (f && !x(C(this.state, a))) {
|
||||||
var b = v.concat([p.add(r), p.add(s), q.add(r), q.add(s)]), c = null, d = 0, e;
|
var b = v.concat([p.add(r), p.add(s), q.add(r), q.add(s)]), c = null, d = 0, e;
|
||||||
for (e in b) {
|
for (e in b) {
|
||||||
|
@ -282,13 +282,13 @@ R.prototype.start = function(a) {
|
||||||
this.state.getContext(this.a);
|
this.state.getContext(this.a);
|
||||||
a = [];
|
a = [];
|
||||||
for (var h in v) {
|
for (var h in v) {
|
||||||
var b = ga(this, this.a, v[h]), t;
|
var b = ha(this, this.a, v[h]), t;
|
||||||
for (t in b) {
|
for (t in b) {
|
||||||
if (c = b[t], d = 0 != v[h].x, 1 == y(this.state.getContext(c))) {
|
if (c = b[t], d = 0 != v[h].x, 1 == y(this.state.getContext(c))) {
|
||||||
a.push({position:c, v:d});
|
a.push({position:c, v:d});
|
||||||
} else {
|
} else {
|
||||||
for (var u in v) {
|
for (var u in v) {
|
||||||
0 != v[h].add(v[u]).length() && 2 != v[h].add(v[u]).length() && (e = ga(this, c, v[u]), 0 != e.length && a.push({position:e[e.length - 1], v:d}));
|
0 != v[h].add(v[u]).length() && 2 != v[h].add(v[u]).length() && (e = ha(this, c, v[u]), 0 != e.length && a.push({position:e[e.length - 1], v:d}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,19 +297,19 @@ R.prototype.start = function(a) {
|
||||||
this.move(this.a);
|
this.move(this.a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
R.prototype.move = function(a) {
|
P.prototype.move = function(a) {
|
||||||
K(this.state);
|
J(this.state);
|
||||||
for (var b in this.h) {
|
for (var b in this.h) {
|
||||||
F(this.state, this.a, this.h[b].position, this.h[b].v, " ");
|
E(this.state, this.a, this.h[b].position, this.h[b].v, " ");
|
||||||
}
|
}
|
||||||
for (b in this.h) {
|
for (b in this.h) {
|
||||||
F(this.state, a, this.h[b].position, this.h[b].v);
|
E(this.state, a, this.h[b].position, this.h[b].v);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
R.prototype.end = function() {
|
P.prototype.end = function() {
|
||||||
L(this.state);
|
K(this.state);
|
||||||
};
|
};
|
||||||
function ga(a, b, c) {
|
function ha(a, b, c) {
|
||||||
for (var d = b.clone(), e = [];;) {
|
for (var d = b.clone(), e = [];;) {
|
||||||
var g = d.add(c);
|
var g = d.add(c);
|
||||||
if (!x(C(a.state, g))) {
|
if (!x(C(a.state, g))) {
|
||||||
|
@ -319,12 +319,12 @@ function ga(a, b, c) {
|
||||||
3 == y(a.state.getContext(d)) && e.push(d);
|
3 == y(a.state.getContext(d)) && e.push(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.prototype.l = function(a) {
|
P.prototype.l = function(a) {
|
||||||
return x(C(this.state, a)) ? "pointer" : "default";
|
return x(C(this.state, a)) ? "pointer" : "default";
|
||||||
};
|
};
|
||||||
R.prototype.e = function() {
|
P.prototype.e = function() {
|
||||||
};
|
};
|
||||||
function S() {
|
function R() {
|
||||||
this.cells = Array(2E3);
|
this.cells = Array(2E3);
|
||||||
this.i = [];
|
this.i = [];
|
||||||
this.d = !0;
|
this.d = !0;
|
||||||
|
@ -337,33 +337,33 @@ function S() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
S.prototype.clear = function() {
|
R.prototype.clear = function() {
|
||||||
for (var a = 0;a < this.cells.length;a++) {
|
for (var a = 0;a < this.cells.length;a++) {
|
||||||
for (var b = 0;b < this.cells[a].length;b++) {
|
for (var b = 0;b < this.cells[a].length;b++) {
|
||||||
null != w(this.cells[a][b]) && I(this, new l(a, b), "\u2009");
|
null != w(this.cells[a][b]) && H(this, new l(a, b), "\u2009");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
L(this);
|
K(this);
|
||||||
};
|
};
|
||||||
function C(a, b) {
|
function C(a, b) {
|
||||||
return a.cells[b.x][b.y];
|
return a.cells[b.x][b.y];
|
||||||
}
|
}
|
||||||
function I(a, b, c) {
|
function H(a, b, c) {
|
||||||
var d = C(a, b);
|
var d = C(a, b);
|
||||||
a.i.push(new ea(b, d));
|
a.i.push(new ea(b, d));
|
||||||
d.f = c;
|
d.f = c;
|
||||||
a.d = !0;
|
a.d = !0;
|
||||||
}
|
}
|
||||||
function H(a, b, c) {
|
function F(a, b, c) {
|
||||||
w(C(a, b)) != c && I(a, b, c);
|
w(C(a, b)) != c && H(a, b, c);
|
||||||
}
|
}
|
||||||
function K(a) {
|
function J(a) {
|
||||||
for (var b in a.i) {
|
for (var b in a.i) {
|
||||||
a.i[b].F.f = null;
|
a.i[b].F.f = null;
|
||||||
}
|
}
|
||||||
a.i.length = 0;
|
a.i.length = 0;
|
||||||
}
|
}
|
||||||
function E(a, b) {
|
function ga(a, b) {
|
||||||
var c = C(a, b), c = null != c.f ? c.f : c.value;
|
var c = C(a, b), c = null != c.f ? c.f : c.value;
|
||||||
if ("+" != c) {
|
if ("+" != c) {
|
||||||
return c;
|
return c;
|
||||||
|
@ -371,12 +371,12 @@ function E(a, b) {
|
||||||
c = a.getContext(b);
|
c = a.getContext(b);
|
||||||
return c.left && c.right && !c.m && !c.j ? "\u2013" : !c.left && !c.right && c.m && c.j ? "|" : c.left && c.right && c.m && c.j ? "\u2013" : "+";
|
return c.left && c.right && !c.m && !c.j ? "\u2013" : !c.left && !c.right && c.m && c.j ? "|" : c.left && c.right && c.m && c.j ? "\u2013" : "+";
|
||||||
}
|
}
|
||||||
S.prototype.getContext = function(a) {
|
R.prototype.getContext = function(a) {
|
||||||
var b = x(C(this, a.add(p))), c = x(C(this, a.add(q))), d = x(C(this, a.add(r)));
|
var b = x(C(this, a.add(p))), c = x(C(this, a.add(q))), d = x(C(this, a.add(r)));
|
||||||
a = x(C(this, a.add(s)));
|
a = x(C(this, a.add(s)));
|
||||||
return new ca(b, c, d, a);
|
return new ca(b, c, d, a);
|
||||||
};
|
};
|
||||||
function L(a, b) {
|
function K(a, b) {
|
||||||
var c = [], d = a.i.map(function(a) {
|
var c = [], d = a.i.map(function(a) {
|
||||||
return a.position.x.toString() + a.position.y.toString();
|
return a.position.x.toString() + a.position.y.toString();
|
||||||
}), e = a.i.filter(function(a, b) {
|
}), e = a.i.filter(function(a, b) {
|
||||||
|
@ -397,27 +397,27 @@ function L(a, b) {
|
||||||
0 < c.length && (50 < e.length && e.shift(), e.push(c));
|
0 < c.length && (50 < e.length && e.shift(), e.push(c));
|
||||||
a.d = !0;
|
a.d = !0;
|
||||||
}
|
}
|
||||||
function ha(a) {
|
function ia(a) {
|
||||||
if (0 != a.D.length) {
|
if (0 != a.D.length) {
|
||||||
var b = a.D.pop(), c;
|
var b = a.D.pop(), c;
|
||||||
for (c in b) {
|
for (c in b) {
|
||||||
var d = b[c];
|
var d = b[c];
|
||||||
I(a, d.position, d.value);
|
H(a, d.position, d.value);
|
||||||
}
|
}
|
||||||
L(a, !0);
|
K(a, !0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function ia(a) {
|
function ja(a) {
|
||||||
if (0 != a.C.length) {
|
if (0 != a.C.length) {
|
||||||
var b = a.C.pop(), c;
|
var b = a.C.pop(), c;
|
||||||
for (c in b) {
|
for (c in b) {
|
||||||
var d = b[c];
|
var d = b[c];
|
||||||
I(a, d.position, d.value);
|
H(a, d.position, d.value);
|
||||||
}
|
}
|
||||||
L(a);
|
K(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function T(a) {
|
function S(a) {
|
||||||
for (var b = new l(Number.MAX_VALUE, Number.MAX_VALUE), c = new l(-1, -1), d = 0;d < a.cells.length;d++) {
|
for (var b = new l(Number.MAX_VALUE, Number.MAX_VALUE), c = new l(-1, -1), d = 0;d < a.cells.length;d++) {
|
||||||
for (var e = 0;e < a.cells[d].length;e++) {
|
for (var e = 0;e < a.cells[d].length;e++) {
|
||||||
null != w(a.cells[d][e]) && (d < b.x && (b.x = d), e < b.y && (b.y = e), d > c.x && (c.x = d), e > c.y && (c.y = e));
|
null != w(a.cells[d][e]) && (d < b.x && (b.x = d), e < b.y && (b.y = e), d > c.x && (c.x = d), e > c.y && (c.y = e));
|
||||||
|
@ -428,13 +428,13 @@ function T(a) {
|
||||||
}
|
}
|
||||||
for (var g = "", e = b.y;e <= c.y;e++) {
|
for (var g = "", e = b.y;e <= c.y;e++) {
|
||||||
for (var k = "", d = b.x;d <= c.x;d++) {
|
for (var k = "", d = b.x;d <= c.x;d++) {
|
||||||
var h = E(a, new l(d, e)), k = k + (null == h ? " " : h)
|
var h = ga(a, new l(d, e)), k = k + (null == h ? " " : h)
|
||||||
}
|
}
|
||||||
g += k.replace("\\s+$/g", "") + "\n";
|
g += k.replace("\\s+$/g", "") + "\n";
|
||||||
}
|
}
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
function ja(a, b, c) {
|
function ka(a, b, c) {
|
||||||
b = b.split("\n");
|
b = b.split("\n");
|
||||||
for (var d = new l(0, Math.round(b.length / 2)), e = 0;e < b.length;e++) {
|
for (var d = new l(0, Math.round(b.length / 2)), e = 0;e < b.length;e++) {
|
||||||
d.x = Math.max(d.x, Math.round(b[e].length / 2));
|
d.x = Math.max(d.x, Math.round(b[e].length / 2));
|
||||||
|
@ -445,19 +445,19 @@ function ja(a, b, c) {
|
||||||
if ("\u2013" == h || "|" == h) {
|
if ("\u2013" == h || "|" == h) {
|
||||||
h = "+";
|
h = "+";
|
||||||
}
|
}
|
||||||
I(a, n((new l(k, e)).add(c), d), h);
|
H(a, n((new l(k, e)).add(c), d), h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
L(a);
|
K(a);
|
||||||
}
|
}
|
||||||
;function U(a, b) {
|
;function T(a, b) {
|
||||||
this.view = a;
|
this.view = a;
|
||||||
this.state = b;
|
this.state = b;
|
||||||
this.c = new J(b);
|
this.c = new I(b);
|
||||||
this.mode = 0;
|
this.mode = 0;
|
||||||
this.n();
|
this.n();
|
||||||
}
|
}
|
||||||
U.prototype.r = function(a) {
|
T.prototype.r = function(a) {
|
||||||
var b = B(this.view, a);
|
var b = B(this.view, a);
|
||||||
null == this.o && (this.o = b);
|
null == this.o && (this.o = b);
|
||||||
m(b, this.o) || (this.view.canvas.style.cursor = this.c.l(b));
|
m(b, this.o) || (this.view.canvas.style.cursor = this.c.l(b));
|
||||||
|
@ -470,14 +470,14 @@ U.prototype.r = function(a) {
|
||||||
}
|
}
|
||||||
this.o = b;
|
this.o = b;
|
||||||
};
|
};
|
||||||
function V(a) {
|
function U(a) {
|
||||||
2 == a.mode && a.c.end();
|
2 == a.mode && a.c.end();
|
||||||
a.mode = 0;
|
a.mode = 0;
|
||||||
a.w = null;
|
a.w = null;
|
||||||
a.A = null;
|
a.A = null;
|
||||||
a.o = null;
|
a.o = null;
|
||||||
}
|
}
|
||||||
U.prototype.n = function() {
|
T.prototype.n = function() {
|
||||||
var a = this;
|
var a = this;
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
A(a.view);
|
A(a.view);
|
||||||
|
@ -488,30 +488,30 @@ U.prototype.n = function() {
|
||||||
$("#draw-tools > button.tool").removeClass("active");
|
$("#draw-tools > button.tool").removeClass("active");
|
||||||
$("#" + a).toggleClass("active");
|
$("#" + a).toggleClass("active");
|
||||||
$(".dialog").removeClass("visible");
|
$(".dialog").removeClass("visible");
|
||||||
"box-button" == a && (this.c = new J(this.state));
|
"box-button" == a && (this.c = new I(this.state));
|
||||||
"line-button" == a && (this.c = new M(this.state));
|
"line-button" == a && (this.c = new L(this.state));
|
||||||
"freeform-button" == a && (this.c = new N(this.state, "+"));
|
"freeform-button" == a && (this.c = new M(this.state, "+"));
|
||||||
"erase-button" == a && (this.c = new P(this.state));
|
"erase-button" == a && (this.c = new O(this.state));
|
||||||
"move-button" == a && (this.c = new R(this.state));
|
"move-button" == a && (this.c = new P(this.state));
|
||||||
"text-button" == a && (this.c = new O(this.state));
|
"text-button" == a && (this.c = new N(this.state));
|
||||||
L(this.state);
|
K(this.state);
|
||||||
this.view.canvas.focus();
|
this.view.canvas.focus();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#file-tools > button.tool").click(function(a) {
|
$("#file-tools > button.tool").click(function(a) {
|
||||||
a = a.target.id;
|
a = a.target.id;
|
||||||
$(".dialog").removeClass("visible");
|
$(".dialog").removeClass("visible");
|
||||||
$("#" + a + "-dialog").toggleClass("visible");
|
$("#" + a + "-dialog").toggleClass("visible");
|
||||||
"export-button" == a && ($("#export-area").val(T(this.state)), $("#export-area").focus(), $("#export-area").select());
|
"export-button" == a && ($("#export-area").val(S(this.state)), $("#export-area").focus(), $("#export-area").select());
|
||||||
"clear-button" == a && this.state.clear();
|
"clear-button" == a && this.state.clear();
|
||||||
"undo-button" == a && ha(this.state);
|
"undo-button" == a && ia(this.state);
|
||||||
"redo-button" == a && ia(this.state);
|
"redo-button" == a && ja(this.state);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("button.close-dialog-button").click(function() {
|
$("button.close-dialog-button").click(function() {
|
||||||
$(".dialog").removeClass("visible");
|
$(".dialog").removeClass("visible");
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#import-submit-button").click(function() {
|
$("#import-submit-button").click(function() {
|
||||||
this.state.clear();
|
this.state.clear();
|
||||||
ja(this.state, $("#import-area").val(), B(this.view, new l(this.view.canvas.width / 2, this.view.canvas.height / 2)));
|
ka(this.state, $("#import-area").val(), B(this.view, new l(this.view.canvas.width / 2, this.view.canvas.height / 2)));
|
||||||
$("#import-area").val("");
|
$("#import-area").val("");
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#use-lines-button").click(function() {
|
$("#use-lines-button").click(function() {
|
||||||
|
@ -532,7 +532,7 @@ U.prototype.n = function() {
|
||||||
$(window).keydown(function(a) {
|
$(window).keydown(function(a) {
|
||||||
var c = null;
|
var c = null;
|
||||||
if (a.ctrlKey || a.metaKey) {
|
if (a.ctrlKey || a.metaKey) {
|
||||||
67 == a.keyCode && (c = "<copy>"), 86 == a.keyCode && (c = "<paste>"), 90 == a.keyCode && ha(this.state), 89 == a.keyCode && ia(this.state), 88 == a.keyCode && (c = "<cut>");
|
67 == a.keyCode && (c = "<copy>"), 86 == a.keyCode && (c = "<paste>"), 90 == a.keyCode && ia(this.state), 89 == a.keyCode && ja(this.state), 88 == a.keyCode && (c = "<cut>");
|
||||||
}
|
}
|
||||||
8 == a.keyCode && (c = "<backspace>");
|
8 == a.keyCode && (c = "<backspace>");
|
||||||
13 == a.keyCode && (c = "<enter>");
|
13 == a.keyCode && (c = "<enter>");
|
||||||
|
@ -550,27 +550,27 @@ U.prototype.n = function() {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#text-tool-close").click(function() {
|
$("#text-tool-close").click(function() {
|
||||||
$("#text-tool-widget").hide();
|
$("#text-tool-widget").hide();
|
||||||
L(this.state);
|
K(this.state);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
function ka(a, b) {
|
function la(a, b) {
|
||||||
this.p = !1;
|
this.p = !1;
|
||||||
this.state = a;
|
this.state = a;
|
||||||
this.view = b;
|
this.view = b;
|
||||||
this.file = null;
|
this.file = null;
|
||||||
la(this);
|
ma(this);
|
||||||
$("#drive-button").click(function() {
|
$("#drive-button").click(function() {
|
||||||
this.p ? ma(this) : (W(this, !1), na(this));
|
this.p ? na(this) : (V(this, !1), oa(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#drive-filename").click(function() {
|
$("#drive-filename").click(function() {
|
||||||
var a = "" + $("#drive-filename").text(), a = prompt("Enter new filename:", a);
|
var a = "" + $("#drive-filename").text(), a = prompt("Enter new filename:", a);
|
||||||
this.file.title = a;
|
this.file.title = a;
|
||||||
this.save();
|
this.save();
|
||||||
oa(this);
|
pa(this);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
pa(this);
|
qa(this);
|
||||||
$(window).bind("hashchange", function() {
|
$(window).bind("hashchange", function() {
|
||||||
qa(this);
|
ra(this);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$("#drive-new-file-button").click(function() {
|
$("#drive-new-file-button").click(function() {
|
||||||
this.file = null;
|
this.file = null;
|
||||||
|
@ -580,34 +580,34 @@ function ka(a, b) {
|
||||||
$("#drive-dialog").removeClass("visible");
|
$("#drive-dialog").removeClass("visible");
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
function W(a, b) {
|
function V(a, b) {
|
||||||
window.gapi.auth.authorize({client_id:"125643747010-9s9n1ne2fnnuh5v967licfkt83r4vba5.apps.googleusercontent.com", scope:"https://www.googleapis.com/auth/drive", immediate:b}, function(a) {
|
window.gapi.auth.authorize({client_id:"125643747010-9s9n1ne2fnnuh5v967licfkt83r4vba5.apps.googleusercontent.com", scope:"https://www.googleapis.com/auth/drive", immediate:b}, function(a) {
|
||||||
!a || a.error || this.p || (this.p = !0, $("#drive-button").addClass("active"), qa(this));
|
!a || a.error || this.p || (this.p = !0, $("#drive-button").addClass("active"), ra(this));
|
||||||
}.bind(a));
|
}.bind(a));
|
||||||
}
|
}
|
||||||
function la(a) {
|
function ma(a) {
|
||||||
window.gapi && window.gapi.auth && window.gapi.auth.authorize ? W(a, !0) : window.setTimeout(function() {
|
window.gapi && window.gapi.auth && window.gapi.auth.authorize ? V(a, !0) : window.setTimeout(function() {
|
||||||
la(this);
|
ma(this);
|
||||||
}.bind(a), 500);
|
}.bind(a), 500);
|
||||||
}
|
}
|
||||||
function na(a) {
|
function oa(a) {
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
this.p ? ma(this) : (W(this, !0), na(this));
|
this.p ? na(this) : (V(this, !0), oa(this));
|
||||||
}.bind(a), 1E3);
|
}.bind(a), 1E3);
|
||||||
}
|
}
|
||||||
function ra(a, b) {
|
function sa(a, b) {
|
||||||
a.file = b;
|
a.file = b;
|
||||||
$("#drive-filename").text(b.title);
|
$("#drive-filename").text(b.title);
|
||||||
window.location.hash = b.id;
|
window.location.hash = b.id;
|
||||||
}
|
}
|
||||||
function ma(a) {
|
function na(a) {
|
||||||
$("#drive-dialog").addClass("visible");
|
$("#drive-dialog").addClass("visible");
|
||||||
var b = T(a.state);
|
var b = S(a.state);
|
||||||
5 < b.length && b != a.u && a.save();
|
5 < b.length && b != a.u && a.save();
|
||||||
oa(a);
|
pa(a);
|
||||||
}
|
}
|
||||||
function oa(a) {
|
function pa(a) {
|
||||||
window.gapi.client.request({path:"/drive/v2/files", params:{q:"mimeType = 'text/plain' and trashed = false"}, method:"GET"}).execute(function(a) {
|
W(window.gapi.client.request({path:"/drive/v2/files", params:{q:"mimeType = 'text/plain' and trashed = false"}, method:"GET"}), function(a) {
|
||||||
$("#drive-file-list").children().remove();
|
$("#drive-file-list").children().remove();
|
||||||
a = a.items;
|
a = a.items;
|
||||||
for (var c in a) {
|
for (var c in a) {
|
||||||
|
@ -617,40 +617,48 @@ function oa(a) {
|
||||||
}
|
}
|
||||||
}.bind(a));
|
}.bind(a));
|
||||||
}
|
}
|
||||||
function pa(a) {
|
function W(a, b) {
|
||||||
T(a.state) != a.u && a.file && a.file.editable && a.save();
|
try {
|
||||||
|
a.execute(function(a) {
|
||||||
|
a.error || b(a);
|
||||||
|
});
|
||||||
|
} catch (c) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function qa(a) {
|
||||||
|
S(a.state) != a.u && a.file && a.file.editable && a.save();
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
pa(this);
|
qa(this);
|
||||||
}.bind(a), 5E3);
|
}.bind(a), 5E3);
|
||||||
}
|
}
|
||||||
ka.prototype.save = function() {
|
la.prototype.save = function() {
|
||||||
var a = T(this.state);
|
var a = S(this.state);
|
||||||
$("#drive-save-state").text("Saving...");
|
$("#drive-save-state").text("Saving...");
|
||||||
sa(this, a).execute(function(b) {
|
W(ta(this, a), function(b) {
|
||||||
ra(this, b);
|
sa(this, b);
|
||||||
$("#drive-save-state").text("Saved");
|
$("#drive-save-state").text("Saved");
|
||||||
this.u = a;
|
this.u = a;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
function qa(a) {
|
function ra(a) {
|
||||||
1 < window.location.hash.length && ($("#drive-save-state").text("Loading..."), window.gapi.client.request({path:"/drive/v2/files/" + window.location.hash.substr(1, window.location.hash.length - 1), method:"GET"}).execute(function(a) {
|
1 < window.location.hash.length && ($("#drive-save-state").text("Loading..."), W(window.gapi.client.request({path:"/drive/v2/files/" + window.location.hash.substr(1, window.location.hash.length - 1), method:"GET"}), function(a) {
|
||||||
ra(this, a);
|
sa(this, a);
|
||||||
ta(this);
|
ua(this);
|
||||||
}.bind(a)));
|
}.bind(a)));
|
||||||
}
|
}
|
||||||
function ta(a) {
|
function ua(a) {
|
||||||
ua(a.file.downloadUrl, function(a) {
|
va(a.file.downloadUrl, function(a) {
|
||||||
$("#drive-save-state").text("Loaded");
|
$("#drive-save-state").text("Loaded");
|
||||||
this.state.clear();
|
this.state.clear();
|
||||||
ja(this.state, a, B(this.view, new l(this.view.canvas.width / 2, this.view.canvas.height / 2)));
|
ka(this.state, a, B(this.view, new l(this.view.canvas.width / 2, this.view.canvas.height / 2)));
|
||||||
this.u = T(this.state);
|
this.u = S(this.state);
|
||||||
}.bind(a));
|
}.bind(a));
|
||||||
}
|
}
|
||||||
function sa(a, b) {
|
function ta(a, b) {
|
||||||
var c = "\r\n---------314159265358979323846\r\nContent-Type: application/json\r\n\r\n" + JSON.stringify({title:null == a.file ? "Untitled ASCII Diagram" : a.file.title, mimeType:"text/plain"}) + "\r\n---------314159265358979323846\r\nContent-Type: text/plain\r\n\r\n" + b + "\r\n---------314159265358979323846--";
|
var c = "\r\n---------314159265358979323846\r\nContent-Type: application/json\r\n\r\n" + JSON.stringify({title:null == a.file ? "Untitled ASCII Diagram" : a.file.title, mimeType:"text/plain"}) + "\r\n---------314159265358979323846\r\nContent-Type: text/plain\r\n\r\n" + b + "\r\n---------314159265358979323846--";
|
||||||
return window.gapi.client.request({path:"/upload/drive/v2/files" + (null == a.file ? "" : "/" + a.file.id), method:null == a.file ? "POST" : "PUT", params:{uploadType:"multipart"}, headers:{"Content-Type":'multipart/mixed; boundary="-------314159265358979323846"'}, body:c});
|
return window.gapi.client.request({path:"/upload/drive/v2/files" + (null == a.file ? "" : "/" + a.file.id), method:null == a.file ? "POST" : "PUT", params:{uploadType:"multipart"}, headers:{"Content-Type":'multipart/mixed; boundary="-------314159265358979323846"'}, body:c});
|
||||||
}
|
}
|
||||||
function ua(a, b) {
|
function va(a, b) {
|
||||||
var c = window.gapi.auth.getToken().access_token, d = new XMLHttpRequest;
|
var c = window.gapi.auth.getToken().access_token, d = new XMLHttpRequest;
|
||||||
d.open("GET", a);
|
d.open("GET", a);
|
||||||
d.setRequestHeader("Authorization", "Bearer " + c);
|
d.setRequestHeader("Authorization", "Bearer " + c);
|
||||||
|
@ -662,11 +670,11 @@ function ua(a, b) {
|
||||||
};
|
};
|
||||||
d.send();
|
d.send();
|
||||||
}
|
}
|
||||||
;function va(a) {
|
;function wa(a) {
|
||||||
this.b = a;
|
this.b = a;
|
||||||
this.n();
|
this.n();
|
||||||
}
|
}
|
||||||
va.prototype.n = function() {
|
wa.prototype.n = function() {
|
||||||
var a = this.b.view.canvas;
|
var a = this.b.view.canvas;
|
||||||
$(a).bind("mousewheel", function(a) {
|
$(a).bind("mousewheel", function(a) {
|
||||||
a = this.b.view.zoom * (0 < a.originalEvent.wheelDelta ? 1.1 : 0.9);
|
a = this.b.view.zoom * (0 < a.originalEvent.wheelDelta ? 1.1 : 0.9);
|
||||||
|
@ -687,10 +695,10 @@ va.prototype.n = function() {
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$(a).mouseup(function() {
|
$(a).mouseup(function() {
|
||||||
V(this.b);
|
U(this.b);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$(a).mouseleave(function() {
|
$(a).mouseleave(function() {
|
||||||
V(this.b);
|
U(this.b);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
$(a).mousemove(function(a) {
|
$(a).mousemove(function(a) {
|
||||||
this.b.r(new l(a.clientX, a.clientY));
|
this.b.r(new l(a.clientX, a.clientY));
|
||||||
|
@ -701,7 +709,7 @@ function X(a) {
|
||||||
this.t = this.k = !1;
|
this.t = this.k = !1;
|
||||||
this.n();
|
this.n();
|
||||||
}
|
}
|
||||||
function wa(a, b) {
|
function xa(a, b) {
|
||||||
a.B = b;
|
a.B = b;
|
||||||
a.I = $.now();
|
a.I = $.now();
|
||||||
a.k = !1;
|
a.k = !1;
|
||||||
|
@ -732,12 +740,12 @@ X.prototype.n = function() {
|
||||||
$(a).bind("touchstart", function(a) {
|
$(a).bind("touchstart", function(a) {
|
||||||
a.preventDefault();
|
a.preventDefault();
|
||||||
if (1 == a.originalEvent.touches.length) {
|
if (1 == a.originalEvent.touches.length) {
|
||||||
wa(this, new l(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY));
|
xa(this, new l(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY));
|
||||||
} else {
|
} else {
|
||||||
if (1 < a.originalEvent.touches.length) {
|
if (1 < a.originalEvent.touches.length) {
|
||||||
var c = new l(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
|
var c = new l(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
|
||||||
a = new l(a.originalEvent.touches[1].pageX, a.originalEvent.touches[1].pageY);
|
a = new l(a.originalEvent.touches[1].pageX, a.originalEvent.touches[1].pageY);
|
||||||
V(this.b);
|
U(this.b);
|
||||||
this.t = !0;
|
this.t = !0;
|
||||||
this.k = !1;
|
this.k = !1;
|
||||||
this.J = n(c, a).length();
|
this.J = n(c, a).length();
|
||||||
|
@ -760,12 +768,12 @@ X.prototype.n = function() {
|
||||||
$(a).bind("touchend", function(a) {
|
$(a).bind("touchend", function(a) {
|
||||||
a.preventDefault();
|
a.preventDefault();
|
||||||
this.reset();
|
this.reset();
|
||||||
V(this.b);
|
U(this.b);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
var Y = new S, Z = new z(Y), xa = new U(Z, Y);
|
var Y = new R, Z = new z(Y), ya = new T(Z, Y);
|
||||||
new X(xa);
|
new X(ya);
|
||||||
new va(xa);
|
new wa(ya);
|
||||||
new ka(Y, Z);
|
new la(Y, Z);
|
||||||
Z.animate();
|
Z.animate();
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ ascii.DriveController.prototype.waitForFullAuth = function() {
|
||||||
ascii.DriveController.prototype.handleFile = function(file) {
|
ascii.DriveController.prototype.handleFile = function(file) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
$('#drive-filename').text(file['title']);
|
$('#drive-filename').text(file['title']);
|
||||||
window.location.hash = file.id;
|
window.location.hash = file['id'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ ascii.DriveController.prototype.loadDialog = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
ascii.DriveController.prototype.loadFileList = function() {
|
ascii.DriveController.prototype.loadFileList = function() {
|
||||||
this.getListRequest().execute(function(result) {
|
this.safeExecute(this.getListRequest(), function(result) {
|
||||||
$('#drive-file-list').children().remove();
|
$('#drive-file-list').children().remove();
|
||||||
var items = result['items'];
|
var items = result['items'];
|
||||||
for (var i in items) {
|
for (var i in items) {
|
||||||
|
@ -131,6 +131,18 @@ ascii.DriveController.prototype.loadFileList = function() {
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ascii.DriveController.prototype.safeExecute = function(request, callback) {
|
||||||
|
// Could make the API call, don't blow up tho (mobiles n stuff).
|
||||||
|
try {
|
||||||
|
request['execute'](function(result) {
|
||||||
|
if (!result['error']) {
|
||||||
|
callback(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repeatedly save the diagram if it is editable and loaded.
|
* Repeatedly save the diagram if it is editable and loaded.
|
||||||
*/
|
*/
|
||||||
|
@ -150,7 +162,7 @@ ascii.DriveController.prototype.loopSave = function() {
|
||||||
ascii.DriveController.prototype.save = function() {
|
ascii.DriveController.prototype.save = function() {
|
||||||
var text = this.state.outputText();
|
var text = this.state.outputText();
|
||||||
$('#drive-save-state').text('Saving...');
|
$('#drive-save-state').text('Saving...');
|
||||||
this.getSaveRequest(text).execute(function(result) {
|
this.safeExecute(this.getSaveRequest(text), function(result) {
|
||||||
this.handleFile(result);
|
this.handleFile(result);
|
||||||
$('#drive-save-state').text('Saved');
|
$('#drive-save-state').text('Saved');
|
||||||
this.cachedText = text;
|
this.cachedText = text;
|
||||||
|
@ -161,7 +173,7 @@ ascii.DriveController.prototype.loadFromHash = function() {
|
||||||
if (window.location.hash.length > 1) {
|
if (window.location.hash.length > 1) {
|
||||||
$('#drive-save-state').text('Loading...');
|
$('#drive-save-state').text('Loading...');
|
||||||
var fileId = window.location.hash.substr(1, window.location.hash.length - 1);
|
var fileId = window.location.hash.substr(1, window.location.hash.length - 1);
|
||||||
this.getLoadRequest(fileId).execute(function(result) {
|
this.safeExecute(this.getLoadRequest(fileId), function(result) {
|
||||||
this.handleFile(result);
|
this.handleFile(result);
|
||||||
this.reloadFileContent();
|
this.reloadFileContent();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
Loading…
Reference in New Issue