Browse Source

Compile with --jscomp_warning=lintChecks and fix almost all warnings

Note: The remaining warnings aren't actually problems.
master
LMLB 3 years ago
parent
commit
56e8fbe278
21 changed files with 261 additions and 245 deletions
  1. +1
    -0
      compile.bat
  2. +23
    -21
      index.js
  3. +28
    -28
      js-compiled.js
  4. +2
    -2
      js-compiled.js.map
  5. +14
    -11
      js-lib/common.js
  6. +3
    -2
      js-lib/constants.js
  7. +29
    -28
      js-lib/controller.js
  8. +7
    -7
      js-lib/draw/box.js
  9. +7
    -7
      js-lib/draw/erase.js
  10. +4
    -4
      js-lib/draw/freeform.js
  11. +5
    -5
      js-lib/draw/function.js
  12. +6
    -6
      js-lib/draw/line.js
  13. +12
    -11
      js-lib/draw/move.js
  14. +22
    -24
      js-lib/draw/select.js
  15. +8
    -8
      js-lib/draw/text.js
  16. +7
    -7
      js-lib/draw/utils.js
  17. +20
    -20
      js-lib/input-controller.js
  18. +3
    -3
      js-lib/launch.js
  19. +22
    -18
      js-lib/state.js
  20. +12
    -12
      js-lib/vector.js
  21. +26
    -21
      js-lib/view.js

+ 1
- 0
compile.bat View File

@ -12,6 +12,7 @@ set CMDLINE=%CMDLINE% --warning_level=VERBOSE
set CMDLINE=%CMDLINE% --language_in=ECMASCRIPT6
set CMDLINE=%CMDLINE% --compilation_level=ADVANCED_OPTIMIZATIONS
set CMDLINE=%CMDLINE% --output_wrapper_file compile-output-wrapper.js
set CMDLINE=%CMDLINE% --jscomp_warning=lintChecks
:: This will expand CMDLINE first, then execute endlocal, then run the command
endlocal && call %CMDLINE%
popd %~dp0


+ 23
- 21
index.js View File

@ -1,30 +1,32 @@
// Very simple electron wrapper script that allows us to use asciiflow2 as a desktop application
"use strict";
// Very simple electron wrapper script that allows us to use asciiflow2 as a
// desktop application
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const electron = require("electron");
const path = require('path')
const url = require('url')
const path = require("path");
const url = require("url");
let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({width: 800, height: 600, icon: path.join(__dirname, 'images', 'favicon.png')});
electron.app.on("ready", () => {
mainWindow = new electron.BrowserWindow({
width: 800,
height: 600,
icon: path.join(__dirname, "images", "favicon.png"),
});
mainWindow.setMenu(null);
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
pathname: path.join(__dirname, "index.html"),
protocol: "file:",
slashes: true,
}));
mainWindow.on('closed', function () {
mainWindow = null
})
}
mainWindow.on("closed", () => {
mainWindow = null;
});
});
app.on('ready', createWindow)
app.on('window-all-closed', function () {
app.quit()
})
electron.app.on("window-all-closed", () => {
electron.app.quit();
});

+ 28
- 28
js-compiled.js View File

@ -1,37 +1,37 @@
(function(){var h;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}function k(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}var ba="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ca="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;
function m(a,b){if(b){var c=ca;a=a.split(".");for(var f=0;f<a.length-1;f++){var e=a[f];e in c||(c[e]={});c=c[e]}a=a[a.length-1];f=c[a];b=b(f);b!=f&&null!=b&&ba(c,a,{configurable:!0,writable:!0,value:b})}}m("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}});
m("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var e=b.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var d=b[c];if(d===a||Object.is(d,a))return!0}return!1}});m("Math.sign",function(a){return a?a:function(a){a=Number(a);return 0===a||isNaN(a)?a:0<a?1:-1}});function p(a,b){this.x=a;this.y=b}function r(a,b){a=a.touches[void 0===b?0:b];return new p(a.pageX,a.pageY)}
function t(a,b){return null!==b&&void 0!==b&&a.x===b.x&&a.y===b.y}function u(a,b){return new p(a.x-b.x,a.y-b.y)}p.prototype.add=function(a){return new p(this.x+a.x,this.y+a.y)};p.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};p.prototype.scale=function(a){return new p(this.x*a,this.y*a)};function v(a){return new p(a.x,a.y-1)}function x(a){return new p(a.x,a.y+1)}function y(a){return new p(a.x-1,a.y)}function z(a){return new p(a.x+1,a.y)};var A=["+","\u2012","\u2013","-","|"],B=[">","<","^","v"],da=A.concat(B),C="ontouchstart"in window||"onmsgesturechange"in window,E=new p(-1,0),F=new p(1,0),G=new p(0,-1),H=new p(0,1),I=[E,F,G,H];function J(a,b){this.a=Math.min(a.x,b.x);this.b=Math.min(a.y,b.y);this.c=Math.max(a.x,b.x);this.f=Math.max(a.y,b.y)}function ea(a){return new p(a.a,a.b)}J.prototype.contains=function(a){return a.x>=this.a&&a.x<=this.c&&a.y>=this.b&&a.y<=this.f};function fa(){this.a=this.value=null}function K(a){return null===a.a?a.value:a.a}function L(a){return da.includes(K(a))}function M(a){return null===a.value&&null===a.a}
function ha(a,b,c,f){this.a=a;this.b=b;this.f=c;this.c=f;this.i=this.g=this.u=this.h=!1}function N(a){return a.a+a.b+a.f+a.c}function ia(a,b){this.position=a;this.value=b}function ja(a,b){this.position=a;this.a=b};function ka(){this.a=Array(2E3);this.b=[];this.c=!0;this.g=[];this.f=[];for(var a=0;a<this.a.length;a++){this.a[a]=Array(600);for(var b=0;b<this.a[a].length;b++)this.a[a][b]=new fa}}function la(a){for(var b=0;b<a.a.length;b++)for(var c=0;c<a.a[b].length;c++)null!==K(a.a[b][c])&&O(a,new p(b,c),"\u2009");P(a)}function Q(a,b){return a.a[b.x][b.y]}function O(a,b,c){var f=Q(a,b);a.b.push(new ja(b,f));f.a=c;a.c=!0}function R(a,b,c){K(Q(a,b))!==c&&O(a,b,c)}
function S(a){for(var b=k(a.b),c=b.next();!c.done;c=b.next())c.value.a.a=null;a.b.length=0}
function T(a,b){var c=K(Q(a,b)),f=A.includes(c),e=B.includes(c);if(!f&&!e)return c;var d=U(a,b);if(f&&d.a&&d.b&&!d.f&&!d.c)return"-";if(f&&!d.a&&!d.b&&d.f&&d.c)return"|";if(4===N(d))return"-";if(e&&3===N(d)){if(!d.a)return"<";if(!d.f)return"^";if(!d.c)return"v";if(!d.b)return">"}if((f||e)&&3===N(d)){d.h=L(Q(a,v(y(b))));d.u=L(Q(a,v(z(b))));d.g=L(Q(a,x(y(b))));d.i=L(Q(a,x(z(b))));if(!d.b&&d.h&&d.g||!d.a&&d.u&&d.i)return"|";if(!d.c&&d.h&&d.u||!d.f&&d.i&&d.g)return"-";c=M(Q(a,v(y(b))));f=M(Q(a,v(z(b))));
if(d.f&&d.a&&d.b&&(!c||!f))return"-";c=M(Q(a,x(y(b))));a=M(Q(a,x(z(b))));return!(d.c&&d.a&&d.b)||c&&a?"+":"-"}if(e&&1===N(d)){if(d.a)return">";if(d.f)return"v";if(d.c)return"^";if(d.b)return"<"}return c}function U(a,b){var c=L(Q(a,y(b))),f=L(Q(a,z(b))),e=L(Q(a,v(b)));a=L(Q(a,x(b)));return new ha(c,f,e,a)}
function P(a,b){var c=[],f=a.b.map(function(a){return a.position.x.toString()+a.position.y.toString()}),e=a.b.filter(function(a,b){return f.indexOf(f[b])===b});a.b.length=0;e=k(e);for(var d=e.next();!d.done;d=e.next()){var g=d.value;d=g.position;g=g.a;c.push(new ia(d,null===g.value?" ":g.value));var l=K(g);if("\u2009"===l||" "===l)l=null;L(g)&&(l=T(a,d));g.a=null;g.value=l}b=b?a.f:a.g;0<c.length&&(50<b.length&&b.shift(),b.push(c));a.c=!0}
function ma(a){if(0!==a.g.length){var b=a.g.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,O(a,c.position,c.value);P(a,!0)}}function na(a){if(0!==a.f.length){var b=a.f.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,O(a,c.position,c.value);P(a)}};function V(a,b,c,f,e){e=void 0===e?"+":e;var d=new J(b,c),g=d.c,l=d.f,n=f?c.x:b.x;f=f?b.y:c.y;for(var w=d.a;w<g;w++){var q=new p(w,f),D=U(a,new p(w,f));" "===e&&2===D.f+D.c||R(a,q,e)}for(d=d.b;d<l;d++)g=new p(n,d),w=U(a,new p(n,d))," "===e&&2===w.a+w.b||R(a,g,e);O(a,b,e);O(a,c,e);R(a,new p(n,f),e)};function oa(a){this.a=a;this.b=null}h=oa.prototype;h.start=function(a){this.b=a};h.j=function(a){S(this.a);V(this.a,this.b,a,!0);V(this.a,this.b,a,!1)};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};h.l=function(){};function W(a){this.c=a;this.a=this.b=null}h=W.prototype;h.start=function(a){this.b=a;this.j(a)};h.j=function(a){S(this.c);this.a=a;a=Math.min(this.b.y,this.a.y);for(var b=Math.max(this.b.x,this.a.x),c=Math.max(this.b.y,this.a.y),f=Math.min(this.b.x,this.a.x);f<=b;f++)for(var e=a;e<=c;e++)O(this.c,new p(f,e),"\u2009")};h.m=function(){P(this.c)};h.o=function(){return"crosshair"};h.l=function(){};function pa(a){this.a=a;this.value="X";C&&(document.getElementById("freeform-tool-input").value="",document.getElementById("freeform-tool-input").style.display="none",setTimeout(function(){document.getElementById("freeform-tool-input").style.display="block";setTimeout(function(){document.getElementById("freeform-tool-input").focus()},0)},0))}h=pa.prototype;h.start=function(a){O(this.a,a,this.value)};h.j=function(a){O(this.a,a,this.value)};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};
h.l=function(a){C&&(this.value=document.getElementById("freeform-tool-input").value.charAt(0),document.getElementById("freeform-tool-input").blur(),document.getElementById("freeform-tool-input").style.display="none");1===a.length&&(this.value=a)};function qa(a,b){this.a=a;this.c=b;this.b=null}h=qa.prototype;h.start=function(a){this.b=a};h.j=function(a){S(this.a);var b=U(this.a,this.b),c=U(this.a,a);V(this.a,this.b,a,b.f&&b.c||c.a&&c.b);this.c&&O(this.a,a,"^")};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};h.l=function(){};function ra(a){this.a=a;this.b=null;this.c=[]}h=ra.prototype;
h.start=function(a){if(C)if(L(Q(this.a,a)))var b=a;else{var c=I.concat([E.add(G),E.add(H),F.add(G),F.add(H)]);b=null;var f=0;c=k(c);for(var e=c.next();!e.done;e=c.next()){e=e.value;var d=a.add(e),g=N(U(this.a,d));L(Q(this.a,d))&&g>f&&(b=e,f=g)}b=null===b?a:a.add(b)}else b=a;this.b=b;this.c=[];if(L(Q(this.a,this.b))){b=[];f=k(I);for(c=f.next();!c.done;c=f.next())for(c=c.value,e=sa(this,this.b,c),e=k(e),d=e.next();!d.done;d=e.next()){d=d.value;g=0!==c.x;var l=-1!==B.indexOf(K(Q(this.a,a))),n=-1!==B.indexOf(K(Q(this.a,
d)));if(1===N(U(this.a,d)))b.push({position:d,s:g,w:l,v:n});else for(var w=k(I),q=w.next();!q.done;q=w.next())q=q.value,0!==c.add(q).length()&&2!==c.add(q).length()&&(q=sa(this,d,q),0!==q.length&&(q=k(q).next().value,b.push({position:q,s:g,w:l,A:n,v:-1!==B.indexOf(K(Q(this.a,q)))})))}this.c=b;this.j(this.b)}};
function t(a,b){return null!==b&&void 0!==b&&a.x===b.x&&a.y===b.y}function u(a,b){return new p(a.x-b.x,a.y-b.y)}p.prototype.add=function(a){return new p(this.x+a.x,this.y+a.y)};p.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};p.prototype.scale=function(a){return new p(this.x*a,this.y*a)};function v(a){return new p(a.x,a.y-1)}function x(a){return new p(a.x,a.y+1)}function y(a){return new p(a.x-1,a.y)}function A(a){return new p(a.x+1,a.y)};var B=["+","\u2012","\u2013","-","|"],C=[">","<","^","v"],da=B.concat(C),D="ontouchstart"in window||"onmsgesturechange"in window,E=new p(-1,0),F=new p(1,0),G=new p(0,-1),H=new p(0,1),I=[E,F,G,H];function J(a,b){this.a=Math.min(a.x,b.x);this.b=Math.min(a.y,b.y);this.c=Math.max(a.x,b.x);this.f=Math.max(a.y,b.y)}function ea(a){return new p(a.a,a.b)}function fa(a,b){return b.x>=a.a&&b.x<=a.c&&b.y>=a.b&&b.y<=a.f}function ha(){this.a=this.value=null}function K(a){return null===a.a?a.value:a.a}function L(a){return da.includes(K(a))}function M(a){return null===a.value&&null===a.a}function ia(a,b,c,f){this.a=a;this.b=b;this.f=c;this.c=f;this.i=this.g=this.u=this.h=!1}
function N(a){return a.a+a.b+a.f+a.c}function ja(a,b){this.position=a;this.value=b}function ka(a,b){this.position=a;this.a=b};function la(){this.a=Array(2E3);this.b=[];this.c=!0;this.g=[];this.f=[];for(var a=0;a<this.a.length;a++){this.a[a]=Array(600);for(var b=0;b<this.a[a].length;b++)this.a[a][b]=new ha}}function ma(a){for(var b=0;b<a.a.length;b++)for(var c=0;c<a.a[b].length;c++)null!==K(a.a[b][c])&&O(a,new p(b,c),"\u2009");P(a)}function Q(a,b){a=a.a[b.x][b.y];if(void 0===a||null===a)throw Error("Cell not found");return a}function O(a,b,c){var f=Q(a,b);a.b.push(new ka(b,f));f.a=c;a.c=!0}
function R(a,b,c){K(Q(a,b))!==c&&O(a,b,c)}function S(a){for(var b=k(a.b),c=b.next();!c.done;c=b.next())c.value.a.a=null;a.b.length=0}
function T(a,b){var c=K(Q(a,b)),f=B.includes(c),e=C.includes(c);if(!f&&!e)return c;var d=U(a,b);if(f&&d.a&&d.b&&!d.f&&!d.c)return"-";if(f&&!d.a&&!d.b&&d.f&&d.c)return"|";if(4===N(d))return"-";if(e&&3===N(d)){if(!d.a)return"<";if(!d.f)return"^";if(!d.c)return"v";if(!d.b)return">"}if((f||e)&&3===N(d)){d.h=L(Q(a,v(y(b))));d.u=L(Q(a,v(A(b))));d.g=L(Q(a,x(y(b))));d.i=L(Q(a,x(A(b))));if(!d.b&&d.h&&d.g||!d.a&&d.u&&d.i)return"|";if(!d.c&&d.h&&d.u||!d.f&&d.i&&d.g)return"-";c=M(Q(a,v(y(b))));f=M(Q(a,v(A(b))));
if(d.f&&d.a&&d.b&&(!c||!f))return"-";c=M(Q(a,x(y(b))));a=M(Q(a,x(A(b))));return!(d.c&&d.a&&d.b)||c&&a?"+":"-"}if(e&&1===N(d)){if(d.a)return">";if(d.f)return"v";if(d.c)return"^";if(d.b)return"<"}return c}function U(a,b){var c=L(Q(a,y(b))),f=L(Q(a,A(b))),e=L(Q(a,v(b)));a=L(Q(a,x(b)));return new ia(c,f,e,a)}
function P(a,b){var c=[],f=a.b.map(function(a){return a.position.x.toString()+a.position.y.toString()}),e=a.b.filter(function(a,b){return f.indexOf(f[b])===b});a.b.length=0;e=k(e);for(var d=e.next();!d.done;d=e.next()){var g=d.value;d=g.position;g=g.a;c.push(new ja(d,null===g.value?" ":g.value));var l=K(g);if("\u2009"===l||" "===l)l=null;L(g)&&(l=T(a,d));g.a=null;g.value=l}b=b?a.f:a.g;0<c.length&&(50<b.length&&b.shift(),b.push(c));a.c=!0}
function na(a){if(0!==a.g.length){var b=a.g.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,O(a,c.position,c.value);P(a,!0)}}function oa(a){if(0!==a.f.length){var b=a.f.pop();b=k(b);for(var c=b.next();!c.done;c=b.next())c=c.value,O(a,c.position,c.value);P(a)}};function V(a,b,c,f,e){e=void 0===e?"+":e;var d=new J(b,c),g=d.c,l=d.f,n=f?c.x:b.x;f=f?b.y:c.y;for(var w=d.a;w<g;w++){var q=new p(w,f),z=U(a,new p(w,f));" "===e&&2===z.f+z.c||R(a,q,e)}for(d=d.b;d<l;d++)g=new p(n,d),w=U(a,new p(n,d))," "===e&&2===w.a+w.b||R(a,g,e);O(a,b,e);O(a,c,e);R(a,new p(n,f),e)};function pa(a){this.a=a;this.b=null}h=pa.prototype;h.start=function(a){this.b=a};h.j=function(a){S(this.a);V(this.a,this.b,a,!0);V(this.a,this.b,a,!1)};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};h.l=function(){};function W(a){this.c=a;this.a=this.b=null}h=W.prototype;h.start=function(a){this.b=a;this.j(a)};h.j=function(a){S(this.c);this.a=a;a=Math.min(this.b.y,this.a.y);for(var b=Math.max(this.b.x,this.a.x),c=Math.max(this.b.y,this.a.y),f=Math.min(this.b.x,this.a.x);f<=b;f++)for(var e=a;e<=c;e++)O(this.c,new p(f,e),"\u2009")};h.m=function(){P(this.c)};h.o=function(){return"crosshair"};h.l=function(){};function qa(a){this.a=a;this.value="X";D&&(document.getElementById("freeform-tool-input").value="",document.getElementById("freeform-tool-input").style.display="none",setTimeout(function(){document.getElementById("freeform-tool-input").style.display="block";setTimeout(function(){document.getElementById("freeform-tool-input").focus()},0)},0))}h=qa.prototype;h.start=function(a){O(this.a,a,this.value)};h.j=function(a){O(this.a,a,this.value)};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};
h.l=function(a){D&&(this.value=document.getElementById("freeform-tool-input").value.charAt(0),document.getElementById("freeform-tool-input").blur(),document.getElementById("freeform-tool-input").style.display="none");1===a.length&&(this.value=a)};function ra(a,b){this.a=a;this.c=b;this.b=null}h=ra.prototype;h.start=function(a){this.b=a};h.j=function(a){S(this.a);var b=U(this.a,this.b),c=U(this.a,a);V(this.a,this.b,a,b.f&&b.c||c.a&&c.b);this.c&&O(this.a,a,"^")};h.m=function(){P(this.a)};h.o=function(){return"crosshair"};h.l=function(){};function sa(a){this.a=a;this.b=null;this.c=[]}h=sa.prototype;
h.start=function(a){if(D)if(L(Q(this.a,a)))var b=a;else{var c=I.concat([E.add(G),E.add(H),F.add(G),F.add(H)]);b=null;var f=0;c=k(c);for(var e=c.next();!e.done;e=c.next()){e=e.value;var d=a.add(e),g=N(U(this.a,d));L(Q(this.a,d))&&g>f&&(b=e,f=g)}b=null===b?a:a.add(b)}else b=a;this.b=b;this.c=[];if(L(Q(this.a,this.b))){b=[];f=k(I);for(c=f.next();!c.done;c=f.next())for(c=c.value,e=ta(this,this.b,c),e=k(e),d=e.next();!d.done;d=e.next()){d=d.value;g=0!==c.x;var l=-1!==C.indexOf(K(Q(this.a,a))),n=-1!==C.indexOf(K(Q(this.a,
d)));if(1===N(U(this.a,d)))b.push({position:d,s:g,w:l,v:n});else for(var w=k(I),q=w.next();!q.done;q=w.next())if(q=q.value,0!==c.add(q).length()&&2!==c.add(q).length()&&(q=ta(this,d,q),0!==q.length)){q=k(q).next().value;var z=-1!==C.indexOf(K(Q(this.a,q)));b.push({position:q,s:g,w:l,A:n,v:z})}}this.c=b;this.j(this.b)}};
h.j=function(a){S(this.a);for(var b=k(this.c),c=b.next();!c.done;c=b.next())c=c.value,V(this.a,this.b,c.position,c.s," ");b=k(this.c);for(c=b.next();!c.done;c=b.next())c=c.value,V(this.a,a,c.position,c.s);b=k(this.c);for(c=b.next();!c.done;c=b.next())c=c.value,c.w&&O(this.a,a,"^"),c.v&&O(this.a,c.position,"^"),c.A&&O(this.a,new p(c.s?c.position.x:a.x,c.s?a.y:c.position.y),"^")};h.m=function(){P(this.a)};
function sa(a,b,c){for(var f=new p(b.x,b.y),e=[];;){var d=f.add(c);if(!L(Q(a.a,d)))return t(b,f)||e.push(f),e;f=d;3===N(U(a.a,f))&&e.push(f)}}h.o=function(a){return L(Q(this.a,a))?"pointer":"default"};h.l=function(){};function ta(a){this.c=a;this.g=this.f=this.b=this.a=null;this.h=!0;this.i=[]}h=ta.prototype;h.start=function(a){null!==this.a&&null!==this.b&&(new J(this.a,this.b)).contains(a)?(this.f=a,ua(this),va(this,a)):(this.a=a,this.b=null,this.h=!1,this.j(a))};function ua(a){var b=a.c.b.filter(function(a){a=K(a.a);return null!==a&&"\u2009"!==a}),c=ea(new J(a.a,a.b));a.i=b.map(function(a){return new ia(u(a.position,c),K(a.a))})}
h.j=function(a){if(null!==this.f)va(this,a);else if(!this.h){this.b=a;S(this.c);a=new J(this.a,a);for(var b=a.a;b<=a.c;b++)for(var c=a.b;c<=a.f;c++){var f=new p(b,c),e=K(Q(this.c,f));O(this.c,f,null===e?"\u2009":e)}}};function va(a,b){a.g=b;S(a.c);b=new W(a.c);b.start(a.a);b.j(a.b);b=u(a.g,a.f).add(ea(new J(a.a,a.b)));wa(a,b)}function wa(a,b){for(var c=k(a.i),f=c.next();!f.done;f=c.next()){f=f.value;var e=f.value;O(a.c,f.position.add(b),e)}}
h.m=function(){null!==this.f&&(P(this.c),this.b=this.a=null);this.g=this.f=null;this.h=!0};h.o=function(a){return null!==this.a&&null!==this.b&&(new J(this.a,this.b)).contains(a)?"pointer":"default"};h.l=function(a){if(null!==this.a&&null!==this.b&&("Copy"!==a&&"Cut"!==a||ua(this),"Cut"===a)){var b=new W(this.c);b.start(this.a);b.j(this.b);P(this.c)}"Paste"===a&&(wa(this,this.a),P(this.c))};function xa(a){this.b=a;this.c=this.a=null}h=xa.prototype;h.start=function(a){P(this.b);document.getElementById("text-tool-input").value="";this.a=a;a=K(Q(this.b,this.a));O(this.b,this.a,null===a?"\u2009":a)};h.j=function(){};
function ta(a,b,c){for(var f=new p(b.x,b.y),e=[];;){var d=f.add(c);if(!L(Q(a.a,d)))return t(b,f)||e.push(f),e;f=d;3===N(U(a.a,f))&&e.push(f)}}h.o=function(a){return L(Q(this.a,a))?"pointer":"default"};h.l=function(){};function ua(a){this.c=a;this.g=this.f=this.b=this.a=null;this.h=!0;this.i=[]}h=ua.prototype;h.start=function(a){null!==this.a&&null!==this.b&&fa(new J(this.a,this.b),a)?(this.f=a,va(this,this.a,this.b),wa(this,a,this.f)):(this.a=a,this.b=null,this.h=!1,this.j(a))};function va(a,b,c){var f=a.c.b.filter(function(a){a=K(a.a);return null!==a&&"\u2009"!==a}),e=ea(new J(b,c));a.i=f.map(function(a){return new ja(u(a.position,e),K(a.a))})}
h.j=function(a){if(null!==this.f)wa(this,a,this.f);else if(!this.h){this.b=a;S(this.c);a=new J(this.a,a);for(var b=a.a;b<=a.c;b++)for(var c=a.b;c<=a.f;c++){var f=new p(b,c),e=K(Q(this.c,f));O(this.c,f,null===e?"\u2009":e)}}};function wa(a,b,c){a.g=b;S(a.c);b=new W(a.c);b.start(a.a);b.j(a.b);c=u(a.g,c).add(ea(new J(a.a,a.b)));xa(a,c)}function xa(a,b){for(var c=k(a.i),f=c.next();!f.done;f=c.next()){f=f.value;var e=f.value;O(a.c,f.position.add(b),e)}}
h.m=function(){null!==this.f&&(P(this.c),this.b=this.a=null);this.g=this.f=null;this.h=!0};h.o=function(a){return null!==this.a&&null!==this.b&&fa(new J(this.a,this.b),a)?"pointer":"default"};h.l=function(a){if(null!==this.a&&null!==this.b&&("Copy"!==a&&"Cut"!==a||va(this,this.a,this.b),"Cut"===a)){var b=new W(this.c);b.start(this.a);b.j(this.b);P(this.c)}"Paste"===a&&(xa(this,this.a),P(this.c))};function ya(a){this.b=a;this.c=this.a=null}h=ya.prototype;h.start=function(a){P(this.b);document.getElementById("text-tool-input").value="";this.a=a;a=K(Q(this.b,this.a));O(this.b,this.a,null===a?"\u2009":a)};h.j=function(){};
h.m=function(){null!==this.a&&(this.c=this.a,this.a=null,document.getElementById("text-tool-widget").style.display="none",setTimeout(function(){document.getElementById("text-tool-widget").style.display="block";setTimeout(function(){document.getElementById("text-tool-input").focus()},0)},0))};h.o=function(){return"pointer"};
h.l=function(){var a=document.getElementById("text-tool-input").value;S(this.b);var b=this.b,c=this.c,f=0,e=0;a=k(a);for(var d=a.next();!d.done;d=a.next())d=d.value,"\n"===d?(e+=1,f=0):(O(b,c.add(new p(f,e)),d),f+=1)};function ya(a){this.g=a;this.b=document.getElementById("ascii-canvas");this.h=this.b.getContext("2d");this.c=1;this.a=new p(9E3,5100);this.f=!0;this.i=!1;za(this)}function za(a){a.b.width=document.documentElement.clientWidth;a.b.height=document.documentElement.clientHeight;a.f=!0}function Aa(a){if(a.f||a.g.c)a.f=!1,a.g.c=!1,Ba(a);window.requestAnimationFrame(function(){Aa(a)})}
function Ba(a){var b=a.h;b.setTransform(1,0,0,1,0,0);b.clearRect(0,0,a.b.width,a.b.height);b.scale(a.c,a.c);b.translate(a.b.width/2/a.c,a.b.height/2/a.c);var c=u(X(a,new p(0,0)),new p(3,3)),f=X(a,new p(a.b.width,a.b.height)).add(new p(3,3));c.x=Math.max(0,Math.min(c.x,2E3));f.x=Math.max(0,Math.min(f.x,2E3));c.y=Math.max(0,Math.min(c.y,600));f.y=Math.max(0,Math.min(f.y,600));b.lineWidth="1";b.strokeStyle="#EEEEEE";b.beginPath();for(var e=c.x;e<f.x;e++)b.moveTo(9*e-a.a.x,-a.a.y),b.lineTo(9*e-a.a.x,
17*a.g.a.length-a.a.y);for(e=c.y;e<f.y;e++)b.moveTo(-a.a.x,17*e-a.a.y),b.lineTo(9*a.g.a.length-a.a.x,17*e-a.a.y);a.h.stroke();e=!a.i;b.font="15px Courier New";for(var d=c.x;d<f.x;d++)for(var g=c.y;g<f.y;g++){var l=Q(a.g,new p(d,g));if(L(l)||null!==l.a&&" "!==K(l))a.h.fillStyle=null!==l.a?"#DEF":"#F5F5F5",b.fillRect(9*d-a.a.x,17*(g-1)-a.a.y,9,17);var n=T(a.g,new p(d,g));null===n||L(l)&&!e||(a.h.fillStyle="#000000",b.fillText(n,9*d-a.a.x,17*g-a.a.y-3))}if(a.i){b.lineWidth="1";b.strokeStyle="#000000";
h.l=function(){var a=document.getElementById("text-tool-input").value;S(this.b);var b=this.b,c=this.c,f=0,e=0;a=k(a);for(var d=a.next();!d.done;d=a.next())d=d.value,"\n"===d?(e+=1,f=0):(O(b,c.add(new p(f,e)),d),f+=1)};function za(a){this.g=a;a=document.getElementById("ascii-canvas");if(null===a)throw Error('Element with id="ascii-canvas" not found');this.b=a;this.h=this.b.getContext("2d");this.c=1;this.a=new p(9E3,5100);this.f=!0;this.i=!1;Aa(this)}function Aa(a){a.b.width=document.documentElement.clientWidth;a.b.height=document.documentElement.clientHeight;a.f=!0}function Ba(a){if(a.f||a.g.c)a.f=!1,a.g.c=!1,Ca(a);window.requestAnimationFrame(function(){Ba(a)})}
function Ca(a){var b=a.h;b.setTransform(1,0,0,1,0,0);b.clearRect(0,0,a.b.width,a.b.height);b.scale(a.c,a.c);b.translate(a.b.width/2/a.c,a.b.height/2/a.c);var c=u(X(a,new p(0,0)),new p(3,3)),f=X(a,new p(a.b.width,a.b.height)).add(new p(3,3));c.x=Math.max(0,Math.min(c.x,2E3));f.x=Math.max(0,Math.min(f.x,2E3));c.y=Math.max(0,Math.min(c.y,600));f.y=Math.max(0,Math.min(f.y,600));b.lineWidth="1";b.strokeStyle="#EEEEEE";b.beginPath();for(var e=c.x;e<f.x;e++)b.moveTo(9*e-a.a.x,-a.a.y),b.lineTo(9*e-a.a.x,
17*a.g.a.length-a.a.y);for(e=c.y;e<f.y;e++)b.moveTo(0-a.a.x,17*e-a.a.y),b.lineTo(9*a.g.a.length-a.a.x,17*e-a.a.y);a.h.stroke();e=!a.i;b.font="15px Courier New";for(var d=c.x;d<f.x;d++)for(var g=c.y;g<f.y;g++){var l=Q(a.g,new p(d,g));if(L(l)||null!==l.a&&" "!==K(l))a.h.fillStyle=null!==l.a?"#DEF":"#F5F5F5",b.fillRect(9*d-a.a.x,17*(g-1)-a.a.y,9,17);var n=T(a.g,new p(d,g));null===n||L(l)&&!e||(a.h.fillStyle="#000000",b.fillText(n,9*d-a.a.x,17*g-a.a.y-3))}if(a.i){b.lineWidth="1";b.strokeStyle="#000000";
b.beginPath();for(e=c.x;e<f.x;e++)for(d=!1,g=c.y;g<f.y;g++)l=Q(a.g,new p(e,g)),L(l)&&g!==f.y-1||!d||(b.moveTo(9*e-a.a.x+4.5,17*d-a.a.y-8.5),b.lineTo(9*e-a.a.x+4.5,17*(g-1)-a.a.y-8.5),d=!1),L(l)&&!d&&(d=g);for(e=c.y;e<f.y;e++)for(d=!1,g=c.x;g<f.x;g++)l=Q(a.g,new p(g,e)),L(l)&&g!==f.x-1||!d||(b.moveTo(9*d-a.a.x+4.5,17*e-a.a.y-8.5),b.lineTo(9*(g-1)-a.a.x+4.5,17*e-a.a.y-8.5),d=!1),L(l)&&!d&&(d=g);a.h.stroke()}}
function X(a,b){a=new p((b.x-a.b.width/2)/a.c+a.a.x,(b.y-a.b.height/2)/a.c+a.a.y);return new p(Math.min(Math.max(1,Math.round((a.x-4.5)/9)),1998),Math.min(Math.max(1,Math.round((a.y+8.5)/17)),598))};function Ca(a,b){this.view=a;this.a=b;this.b=new oa(b);this.mode=0;this.c=this.g=this.f=null;Da(this)}function Y(){Array.prototype.forEach.call(document.getElementsByClassName("dialog"),function(a){return a.classList.remove("visible")})}function Ea(a,b){var c=X(a.view,b);null===a.c&&(a.c=c);t(c,a.c)||(a.view.b.style.cursor=a.b.o(c));2!==a.mode||t(c,a.c)||a.b.j(c);if(1===a.mode){var f=a.view;b=a.g.add(u(a.f,b).scale(1/a.view.c));f.a=b;f.f=!0}a.c=c}
function X(a,b){a=new p((b.x-a.b.width/2)/a.c+a.a.x,(b.y-a.b.height/2)/a.c+a.a.y);return new p(Math.min(Math.max(1,Math.round((a.x-4.5)/9)),1998),Math.min(Math.max(1,Math.round((a.y+8.5)/17)),598))};function Da(a,b){this.view=a;this.a=b;this.b=new pa(b);this.mode=0;this.c=this.g=this.f=null;Ea(this)}function Y(){Array.prototype.forEach.call(document.getElementsByClassName("dialog"),function(a){return a.classList.remove("visible")})}function Fa(a,b){var c=X(a.view,b);null===a.c&&(a.c=c);t(c,a.c)||(a.view.b.style.cursor=a.b.o(c));2!==a.mode||t(c,a.c)||a.b.j(c);if(1===a.mode){var f=a.view;b=a.g.add(u(a.f,b).scale(1/a.view.c));f.a=b;f.f=!0}a.c=c}
function Z(a){2===a.mode&&a.b.m();a.mode=0;a.f=null;a.g=null;a.c=null}
function Da(a){window.addEventListener("resize",function(){za(a.view)});Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"),function(b){return b.addEventListener("click",function(b){document.getElementById("text-tool-widget").style.display="none";Fa(a,b.target.id)})});Array.prototype.forEach.call(document.querySelectorAll("#file-tools > button.tool"),function(b){return b.addEventListener("click",function(b){b=b.target.id;Y();var c=document.getElementById(b+"-dialog");
c&&c.classList.toggle("visible");"import-button"===b&&(document.getElementById("import-area").value="",document.getElementById("import-area").focus());if("export-button"===b){c=document.getElementById("export-area");var e=a.a;for(var d=new p(Number.MAX_VALUE,Number.MAX_VALUE),g=new p(-1,-1),l=0;l<e.a.length;l++)for(var n=0;n<e.a[l].length;n++)null!==K(e.a[l][n])&&(l<d.x&&(d.x=l),n<d.y&&(d.y=n),l>g.x&&(g.x=l),n>g.y&&(g.y=n));if(0>g.x)e="";else{l="";for(n=d.y;n<=g.y;n++){for(var w="",q=d.x;q<=g.x;q++){var D=
T(e,new p(q,n));w+=null===D||"\u2009"===D?" ":D}l+=w.replace(/\s+$/,"");l+="\n"}e=l}c.value=e;document.getElementById("export-area").select()}"clear-button"===b&&la(a.a);"undo-button"===b&&ma(a.a);"redo-button"===b&&na(a.a)})});Array.prototype.forEach.call(document.querySelectorAll("button.close-dialog-button"),function(a){return a.addEventListener("click",function(){Y()})});document.getElementById("import-submit-button").addEventListener("click",function(){la(a.a);for(var b=a.a,c=X(a.view,new p(a.view.b.width/
2,a.view.b.height/2)),f=document.getElementById("import-area").value.split("\n"),e=new p(0,Math.round(f.length/2)),d=0;d<f.length;d++)e.x=Math.max(e.x,Math.round(f[d].length/2));for(d=0;d<f.length;d++)for(var g=f[d],l=0;l<g.length;l++){var n=g.charAt(l);A.includes(n)&&(n="+");O(b,u((new p(l,d)).add(c),e),n)}P(a.a);document.getElementById("import-area").value="";Y()});document.getElementById("use-lines-button").addEventListener("click",function(){Y();var b=a.view;b.i=!0;b.f=!0});document.getElementById("use-ascii-button").addEventListener("click",
function(){Y();var b=a.view;b.i=!1;b.f=!0});window.addEventListener("keydown",function(b){a:{var c=null;if((b.ctrlKey||b.metaKey)&&!b.altKey&&!b.shiftKey){"c"===b.key&&(c="Copy");"v"===b.key&&(c="Paste");if("z"===b.key){ma(a.a);break a}if("y"===b.key){na(a.a);break a}"x"===b.key&&(c="Cut")}a.b.l(null===c?b.key:c)}});document.getElementById("text-tool-input").addEventListener("keyup",function(){a.b.l("")});document.getElementById("freeform-tool-input").addEventListener("keyup",function(){a.b.l("")});
function Ea(a){window.addEventListener("resize",function(){Aa(a.view)});Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"),function(b){return b.addEventListener("click",function(b){document.getElementById("text-tool-widget").style.display="none";Ga(a,b.target.id)})});Array.prototype.forEach.call(document.querySelectorAll("#file-tools > button.tool"),function(b){return b.addEventListener("click",function(b){b=b.target.id;Y();var c=document.getElementById(b+"-dialog");
c&&c.classList.toggle("visible");"import-button"===b&&(document.getElementById("import-area").value="",document.getElementById("import-area").focus());if("export-button"===b){c=document.getElementById("export-area");var e=a.a;for(var d=new p(Number.MAX_VALUE,Number.MAX_VALUE),g=new p(-1,-1),l=0;l<e.a.length;l++)for(var n=0;n<e.a[l].length;n++)null!==K(e.a[l][n])&&(l<d.x&&(d.x=l),n<d.y&&(d.y=n),l>g.x&&(g.x=l),n>g.y&&(g.y=n));if(0>g.x)e="";else{l="";for(n=d.y;n<=g.y;n++){for(var w="",q=d.x;q<=g.x;q++){var z=
T(e,new p(q,n));w+=null===z||"\u2009"===z?" ":z}l+=w.replace(/\s+$/,"");l+="\n"}e=l}c.value=e;document.getElementById("export-area").select()}"clear-button"===b&&ma(a.a);"undo-button"===b&&na(a.a);"redo-button"===b&&oa(a.a)})});Array.prototype.forEach.call(document.querySelectorAll("button.close-dialog-button"),function(a){return a.addEventListener("click",function(){Y()})});document.getElementById("import-submit-button").addEventListener("click",function(){ma(a.a);for(var b=a.a,c=X(a.view,new p(a.view.b.width/
2,a.view.b.height/2)),f=document.getElementById("import-area").value.split("\n"),e=new p(0,Math.round(f.length/2)),d=0;d<f.length;d++)e.x=Math.max(e.x,Math.round(f[d].length/2));for(d=0;d<f.length;d++)for(var g=f[d],l=0;l<g.length;l++){var n=g.charAt(l);B.includes(n)&&(n="+");O(b,u((new p(l,d)).add(c),e),n)}P(a.a);document.getElementById("import-area").value="";Y()});document.getElementById("use-lines-button").addEventListener("click",function(){Y();var b=a.view;b.i=!0;b.f=!0});document.getElementById("use-ascii-button").addEventListener("click",
function(){Y();var b=a.view;b.i=!1;b.f=!0});window.addEventListener("keydown",function(b){a:{var c=null;if((b.ctrlKey||b.metaKey)&&!b.altKey&&!b.shiftKey){"c"===b.key&&(c="Copy");"v"===b.key&&(c="Paste");if("z"===b.key){na(a.a);break a}if("y"===b.key){oa(a.a);break a}"x"===b.key&&(c="Cut")}a.b.l(null===c?b.key:c)}});document.getElementById("text-tool-input").addEventListener("keyup",function(){a.b.l("")});document.getElementById("freeform-tool-input").addEventListener("keyup",function(){a.b.l("")});
document.getElementById("text-tool-input").addEventListener("change",function(){a.b.l("")});document.getElementById("freeform-tool-input").addEventListener("change",function(){a.b.l("")});document.getElementById("text-tool-close").addEventListener("click",function(){document.getElementById("text-tool-widget").style.display="none";P(a.a)})}
function Fa(a,b){Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"),function(a){return a.classList.remove("active")});document.getElementById(b).classList.toggle("active");Y();"box-button"===b&&(a.b=new oa(a.a));"line-button"===b&&(a.b=new qa(a.a,!1));"arrow-button"===b&&(a.b=new qa(a.a,!0));"freeform-button"===b&&(a.b=new pa(a.a));"erase-button"===b&&(a.b=new W(a.a));"move-button"===b&&(a.b=new ra(a.a));"text-button"===b&&(a.b=new xa(a.a));"select-button"===b&&(a.b=
new ta(a.a));P(a.a);a.view.b.focus()};function Ga(a){this.a=a;Ha(this)}
function Ha(a){var b=a.a.view.b;b.addEventListener("wheel",function(b){b=a.a.view.c*Math.pow(.9,0===b.deltaMode?b.deltaY/120:Math.sign(b.deltaY));b=Math.max(Math.min(b,5.396595277354286),.18530201888518424);var c=a.a.view;c.c=b;c.f=!0});b.addEventListener("mousedown",function(b){if(b.ctrlKey||b.metaKey){var c=a.a;b=new p(b.clientX,b.clientY);c.mode=1;c.f=b;c.g=c.view.a}else c=a.a,b=new p(b.clientX,b.clientY),c.mode=2,c.b.start(X(c.view,b))});b.addEventListener("mouseup",function(){Z(a.a)});b.addEventListener("mouseleave",
function(){Z(a.a)});b.addEventListener("mousemove",function(b){Ea(a.a,new p(b.clientX,b.clientY))})}function Ia(a){this.a=a;this.c=null;this.i=this.g=NaN;this.h=0;this.f=this.b=!1;Ja(this)}function Ka(a,b){a.c=b;a.h=Date.now();a.b=!1;window.setTimeout(function(){if(!a.b&&!a.f&&null!==a.c){var c=a.a;c.mode=2;c.b.start(X(c.view,b))}},150)}
function Ja(a){var b=a.a.view.b;b.addEventListener("touchstart",function(b){b.preventDefault();if(1===b.touches.length)Ka(a,r(b));else if(1<b.touches.length){var c=r(b,0);b=r(b,1);Z(a.a);a.f=!0;a.b=!1;a.i=u(c,b).length();a.g=a.a.view.c}});b.addEventListener("touchmove",function(b){b.preventDefault();if(1===b.touches.length){b=r(b);if(!a.b&&150>Date.now()-a.h&&6<u(b,a.c).length()){a.b=!0;var c=a.a;c.mode=1;c.f=b;c.g=c.view.a}Ea(a.a,b)}else 1<b.touches.length&&a.f&&(b=a.g*u(r(b,0),r(b,1)).length()/
a.i,b=Math.max(Math.min(b,5),.5),c=a.a.view,c.c=b,c.f=!0)});b.addEventListener("touchend",function(b){b.preventDefault();a.b=!1;a.f=!1;a.c=null;Z(a.a)})};if(window.ASCIIFLOW2_LOADED)throw Error("Unexpected double initialization of JS.");else window.ASCIIFLOW2_LOADED=!0;(function(){var a=new ka,b=new ya(a);a=new Ca(b,a);new Ia(a);new Ga(a);Aa(b);window.setTimeout(function(){document.getElementById("logo-interstitial").style.display="none"},3E3)})();})();
function Ga(a,b){Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"),function(a){return a.classList.remove("active")});document.getElementById(b).classList.toggle("active");Y();"box-button"===b&&(a.b=new pa(a.a));"line-button"===b&&(a.b=new ra(a.a,!1));"arrow-button"===b&&(a.b=new ra(a.a,!0));"freeform-button"===b&&(a.b=new qa(a.a));"erase-button"===b&&(a.b=new W(a.a));"move-button"===b&&(a.b=new sa(a.a));"text-button"===b&&(a.b=new ya(a.a));"select-button"===b&&(a.b=
new ua(a.a));P(a.a);a.view.b.focus()};function Ha(a){this.a=a;Ia(this)}
function Ia(a){var b=a.a.view.b;b.addEventListener("wheel",function(b){b=a.a.view.c*Math.pow(.9,0===b.deltaMode?b.deltaY/120:Math.sign(b.deltaY));b=Math.max(Math.min(b,5.396595277354286),.18530201888518424);var c=a.a.view;c.c=b;c.f=!0});b.addEventListener("mousedown",function(b){if(b.ctrlKey||b.metaKey){var c=a.a;b=new p(b.clientX,b.clientY);c.mode=1;c.f=b;c.g=c.view.a}else c=a.a,b=new p(b.clientX,b.clientY),c.mode=2,c.b.start(X(c.view,b))});b.addEventListener("mouseup",function(){Z(a.a)});b.addEventListener("mouseleave",
function(){Z(a.a)});b.addEventListener("mousemove",function(b){Fa(a.a,new p(b.clientX,b.clientY))})}function Ja(a){this.a=a;this.c=null;this.i=this.g=NaN;this.h=0;this.f=this.b=!1;Ka(this)}function La(a,b){a.c=b;a.h=Date.now();a.b=!1;window.setTimeout(function(){if(!a.b&&!a.f&&null!==a.c){var c=a.a;c.mode=2;c.b.start(X(c.view,b))}},150)}
function Ka(a){var b=a.a.view.b;b.addEventListener("touchstart",function(b){b.preventDefault();if(1===b.touches.length)La(a,r(b));else if(1<b.touches.length){var c=r(b,0);b=r(b,1);Z(a.a);a.f=!0;a.b=!1;a.i=u(c,b).length();a.g=a.a.view.c}});b.addEventListener("touchmove",function(b){b.preventDefault();if(1===b.touches.length){b=r(b);if(!a.b&&150>Date.now()-a.h&&6<u(b,a.c||new p(0,0)).length()){a.b=!0;var c=a.a;c.mode=1;c.f=b;c.g=c.view.a}Fa(a.a,b)}else 1<b.touches.length&&a.f&&(b=a.g*u(r(b,0),r(b,1)).length()/
a.i,b=Math.max(Math.min(b,5),.5),c=a.a.view,c.c=b,c.f=!0)});b.addEventListener("touchend",function(b){b.preventDefault();a.b=!1;a.f=!1;a.c=null;Z(a.a)})};if(window.ASCIIFLOW2_LOADED)throw Error("Unexpected double initialization of JS.");else window.ASCIIFLOW2_LOADED=!0;(function(){var a=new la,b=new za(a);a=new Da(b,a);new Ja(a);new Ha(a);Ba(b);window.setTimeout(function(){document.getElementById("logo-interstitial").style.display="none"},3E3)})();})();
//# sourceMappingURL=js-compiled.js.map

+ 2
- 2
js-compiled.js.map
File diff suppressed because it is too large
View File


+ 14
- 11
js-lib/common.js View File

@ -3,21 +3,21 @@
*/
import {ERASE_CHAR, ALL_SPECIAL_VALUES} from "./constants.js";
import Vector from "./vector.js";
import {Vector} from "./vector.js";
/**
* Represents a box with normalized position vectors.
*/
export class Box {
/**
* @param {Vector} a
* @param {Vector} b
* @param {!Vector} a
* @param {!Vector} b
*/
constructor(a, b) {
/** type {number} */ this.startX = Math.min(a.x, b.x);
/** type {number} */ this.startY = Math.min(a.y, b.y);
/** type {number} */ this.endX = Math.max(a.x, b.x);
/** type {number} */ this.endY = Math.max(a.y, b.y);
/** type {!number} */ this.startX = Math.min(a.x, b.x);
/** type {!number} */ this.startY = Math.min(a.y, b.y);
/** type {!number} */ this.endX = Math.max(a.x, b.x);
/** type {!number} */ this.endY = Math.max(a.y, b.y);
}
/** @return {!Vector} */
@ -30,7 +30,10 @@ export class Box {
return new Vector(this.endX, this.endY);
}
/** @return {boolean} */
/**
* @param {!Vector} position
* @return {boolean}
*/
contains(position) {
return position.x >= this.startX && position.x <= this.endX &&
position.y >= this.startY && position.y <= this.endY;
@ -116,7 +119,7 @@ export class CellContext {
*/
export class MappedValue {
/**
* @param {Vector} position
* @param {!Vector} position
* @param {string|null} value
*/
constructor(position, value) {
@ -130,8 +133,8 @@ export class MappedValue {
*/
export class MappedCell {
/**
* @param {Vector} position
* @param {Cell} cell
* @param {!Vector} position
* @param {!Cell} cell
*/
constructor(position, cell) {
this.position = position;


+ 3
- 2
js-lib/constants.js View File

@ -1,4 +1,4 @@
import Vector from "./vector.js";
import {Vector} from "./vector.js";
export const MAX_GRID_WIDTH = 2000;
export const MAX_GRID_HEIGHT = 600;
@ -34,7 +34,8 @@ export const KEY_COPY = "Copy";
export const KEY_PASTE = "Paste";
export const KEY_CUT = "Cut";
// http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript
// What's the best way to detect a 'touch screen' device using JavaScript?
// https://stackoverflow.com/q/4817029
export const TOUCH_ENABLED =
"ontouchstart" in window ||
"onmsgesturechange" in window;


+ 29
- 28
js-lib/controller.js View File

@ -1,15 +1,15 @@
import * as c from "./constants.js";
import Vector from "./vector.js";
import View from "./view.js";
import State from "./state.js";
import DrawFunction from "./draw/function.js";
import DrawBox from "./draw/box.js";
import DrawErase from "./draw/erase.js";
import DrawLine from "./draw/line.js";
import DrawSelect from "./draw/select.js";
import DrawText from "./draw/text.js";
import DrawMove from "./draw/move.js";
import DrawFreeform from "./draw/freeform.js";
import {Vector} from "./vector.js";
import {View} from "./view.js";
import {State} from "./state.js";
import {DrawFunction} from "./draw/function.js";
import {DrawBox} from "./draw/box.js";
import {DrawErase} from "./draw/erase.js";
import {DrawLine} from "./draw/line.js";
import {DrawSelect} from "./draw/select.js";
import {DrawText} from "./draw/text.js";
import {DrawMove} from "./draw/move.js";
import {DrawFreeform} from "./draw/freeform.js";
/**
@ -24,28 +24,28 @@ const Mode = {
/**
* Handles user input events and modifies state.
*/
export default class Controller {
export class Controller {
/**
* @param {View} view
* @param {State} state
* @param {!View} view
* @param {!State} state
*/
constructor(view, state) {
/** @type {View} */ this.view = view;
/** @type {State} */ this.state = state;
/** @type {!View} */ this.view = view;
/** @type {!State} */ this.state = state;
/** @type {DrawFunction} */ this.drawFunction = new DrawBox(state);
/** @type {!DrawFunction} */ this.drawFunction = new DrawBox(state);
/** @type {number} */ this.mode = Mode.NONE;
/** @type {Vector} */ this.dragOrigin = null;
/** @type {Vector} */ this.dragOriginCell = null;
/** @type {?Vector} */ this.dragOrigin = null;
/** @type {?Vector} */ this.dragOriginCell = null;
/** @type {Vector} */ this.lastMoveCell = null;
/** @type {?Vector} */ this.lastMoveCell = null;
this.installBindings();
}
/**
* @param {Vector} position
* @param {!Vector} position
*/
startDraw(position) {
this.mode = Mode.DRAW;
@ -53,7 +53,7 @@ export default class Controller {
}
/**
* @param {Vector} position
* @param {!Vector} position
*/
startDrag(position) {
this.mode = Mode.DRAG;
@ -66,7 +66,7 @@ export default class Controller {
}
/**
* @param {Vector} position
* @param {!Vector} position
*/
handleMove(position) {
const moveCell = this.view.screenToCell(position);
@ -115,12 +115,12 @@ export default class Controller {
this.view.resizeCanvas();
});
Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"), el => el.addEventListener("click", e => {
Array.prototype.forEach.call(document.querySelectorAll("#draw-tools > button.tool"), el => el.addEventListener("click", (/** @type {!MouseEvent} */ e) => {
document.getElementById("text-tool-widget").style.display = "none";
this.handleDrawButton(e.target.id);
}));
Array.prototype.forEach.call(document.querySelectorAll("#file-tools > button.tool"), el => el.addEventListener("click", e => {
Array.prototype.forEach.call(document.querySelectorAll("#file-tools > button.tool"), el => el.addEventListener("click", (/** @type {!MouseEvent} */ e) => {
this.handleFileButton(e.target.id);
}));
@ -130,6 +130,7 @@ export default class Controller {
document.getElementById("import-submit-button").addEventListener("click", () => {
this.state.clear();
/** @type {string} */
const importText = document.getElementById("import-area").value;
this.state.fromText(
@ -151,7 +152,7 @@ export default class Controller {
this.view.setUseLines(false);
});
window.addEventListener("keydown", (/** @type {KeyboardEvent} */ e) => {
window.addEventListener("keydown", (/** @type {!KeyboardEvent} */ e) => {
this.handleKeyDown(e);
});
@ -203,7 +204,7 @@ export default class Controller {
this.drawFunction = new DrawMove(this.state);
}
if (id === "text-button") {
this.drawFunction = new DrawText(this.state, this.view);
this.drawFunction = new DrawText(this.state);
}
if (id === "select-button") {
this.drawFunction = new DrawSelect(this.state);
@ -245,7 +246,7 @@ export default class Controller {
/**
* Handles key down events.
* @param {KeyboardEvent} event
* @param {!KeyboardEvent} event
*/
handleKeyDown(event) {
// Override some special characters so that they can be handled in one place.


+ 7
- 7
js-lib/draw/box.js View File

@ -1,19 +1,19 @@
import State from "../state.js";
import Vector from "../vector.js";
import DrawFunction from "./function.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
import {DrawFunction} from "./function.js";
import {drawLine} from "./utils.js";
/**
* @implements {DrawFunction}
*/
export default class DrawBox {
export class DrawBox {
/**
* @param {State} state
* @param {!State} state
*/
constructor(state) {
this.state = state;
/** @type {Vector} */ this.startPosition = null;
/** @type {Vector} */ this.endPosition = null;
/** @type {?Vector} */ this.startPosition = null;
/** @type {?Vector} */ this.endPosition = null;
}
/** @inheritDoc */


+ 7
- 7
js-lib/draw/erase.js View File

@ -1,19 +1,19 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {ERASE_CHAR} from "../constants.js";
import State from "../state.js";
import Vector from "../vector.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
/**
* @implements {DrawFunction}
*/
export default class DrawErase {
export class DrawErase {
/**
* @param {State} state
* @param {!State} state
*/
constructor(state) {
this.state = state;
this.startPosition = null;
this.endPosition = null;
/** @type {?Vector} */ this.startPosition = null;
/** @type {?Vector} */ this.endPosition = null;
}
/** @inheritDoc */


+ 4
- 4
js-lib/draw/freeform.js View File

@ -1,13 +1,13 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {TOUCH_ENABLED} from "../constants.js";
import State from "../state.js";
import {State} from "../state.js";
/**
* @implements {DrawFunction}
*/
export default class DrawFreeform {
export class DrawFreeform {
/**
* @param {State} state
* @param {!State} state
* @param {?string} value
*/
constructor(state, value) {


+ 5
- 5
js-lib/draw/function.js View File

@ -1,17 +1,17 @@
import Vector from "../vector.js";
import {Vector} from "../vector.js";
/**
* Common interface for different drawing functions, e.g. box, line, etc.
* @interface
*/
export default class DrawFunction {
export class DrawFunction {
/** Start of drawing.
* @param {Vector} position
* @param {!Vector} position
*/
start(position) {}
/** Drawing move.
* @param {Vector} position
* @param {!Vector} position
*/
move(position) {}
@ -19,7 +19,7 @@ export default class DrawFunction {
end() {}
/** Cursor for given cell.
* @param {Vector} position
* @param {!Vector} position
* @return {string}
*/
getCursor(position) {}


+ 6
- 6
js-lib/draw/line.js View File

@ -1,21 +1,21 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {drawLine} from "./utils.js";
import {ALT_SPECIAL_VALUE} from "../constants.js";
import State from "../state.js";
import Vector from "../vector.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
/**
* @implements {DrawFunction}
*/
export default class DrawLine {
export class DrawLine {
/**
* @param {State} state
* @param {!State} state
* @param {boolean} isArrow
*/
constructor(state, isArrow) {
this.state = state;
this.isArrow = isArrow;
/** @type {Vector} */ this.startPosition = null;
/** @type {?Vector} */ this.startPosition = null;
}
/** @inheritDoc */


+ 12
- 11
js-lib/draw/move.js View File

@ -1,19 +1,20 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {drawLine} from "./utils.js";
import State from "../state.js";
import Vector from "../vector.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
import * as c from "../constants.js";
/**
* @implements {DrawFunction}
*/
export default class DrawMove {
export class DrawMove {
/**
* @param {State} state
* @param {!State} state
*/
constructor(state) {
this.state = state;
this.startPosition = null;
/** @type {?Vector} */ this.startPosition = null;
/** @type {!Array<{position, clockwise, startIsAlt, midPointIsAlt, endIsAlt}>} */
this.ends = [];
@ -104,9 +105,9 @@ export default class DrawMove {
* Follows a line in a given direction from the startPosition.
* Returns a list of positions that were line 'junctions'. This is a bit of a
* loose definition, but basically means a point around which we resize things.
* @param {Vector} startPosition
* @param {Vector} direction
* @return {!Array<Vector>}
* @param {!Vector} startPosition
* @param {!Vector} direction
* @return {!Array<!Vector>}
*/
followLine(startPosition, direction) {
let endPosition = startPosition.clone();
@ -134,8 +135,8 @@ export default class DrawMove {
* For a given position, finds the nearest cell that is of any interest to the
* move tool, e.g. a corner or a line. Will look up to 1 cell in each direction
* including diagonally.
* @param {Vector} position
* @return {Vector}
* @param {!Vector} position
* @return {!Vector}
*/
snapToNearest(position) {
if (this.state.getCell(position).isSpecial()) {


+ 22
- 24
js-lib/draw/select.js View File

@ -1,36 +1,36 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {ERASE_CHAR, KEY_COPY, KEY_CUT, KEY_PASTE} from "../constants.js";
import Vector from "../vector.js";
import State from "../state.js";
import {Vector} from "../vector.js";
import {State} from "../state.js";
import {MappedValue, Box} from "../common.js";
import DrawErase from "./erase.js";
import {DrawErase} from "./erase.js";
/**
* @implements {DrawFunction}
*/
export default class DrawSelect {
export class DrawSelect {
/**
* @param {State} state
* @param {!State} state
*/
constructor(state) {
this.state = state;
/** @type {Vector} */
/** @type {?Vector} */
this.startPosition = null;
/** @type {Vector} */
/** @type {?Vector} */
this.endPosition = null;
/** @type {Vector} */
/** @type {?Vector} */
this.dragStart = null;
/** @type {Vector} */
/** @type {?Vector} */
this.dragEnd = null;
/** @type {boolean} */
this.finished = true;
/** @type {!Array<MappedValue>} */
/** @type {!Array<!MappedValue>} */
this.selectedCells = [];
}
@ -39,11 +39,11 @@ export default class DrawSelect {
// Must be dragging.
if (this.startPosition !== null &&
this.endPosition !== null &&
this.getSelectedBox().contains(position)
new Box(this.startPosition, this.endPosition).contains(position)
) {
this.dragStart = position;
this.copyArea();
this.dragMove(position);
this.copyArea(this.startPosition, this.endPosition);
this.dragMove(position, this.dragStart);
} else {
this.startPosition = position;
this.endPosition = null;
@ -52,16 +52,12 @@ export default class DrawSelect {
}
}
getSelectedBox() {
return new Box(this.startPosition, this.endPosition);
}
copyArea() {
copyArea(startPosition, endPosition) {
const nonEmptyCells = this.state.scratchCells.filter(value => {
const rawValue = value.cell.getRawValue();
return rawValue !== null && rawValue !== ERASE_CHAR;
});
const topLeft = this.getSelectedBox().topLeft();
const topLeft = new Box(startPosition, endPosition).topLeft();
this.selectedCells = nonEmptyCells.map(
value => new MappedValue(value.position.subtract(topLeft), value.cell.getRawValue())
);
@ -70,7 +66,7 @@ export default class DrawSelect {
/** @inheritDoc */
move(position) {
if (this.dragStart !== null) {
this.dragMove(position);
this.dragMove(position, this.dragStart);
return;
}
@ -93,13 +89,15 @@ export default class DrawSelect {
}
}
dragMove(position) {
dragMove(position, dragStart) {
this.dragEnd = position;
this.state.clearDraw();
const eraser = new DrawErase(this.state);
eraser.start(this.startPosition);
eraser.move(this.endPosition);
const startPos = this.dragEnd.subtract(this.dragStart).add(this.getSelectedBox().topLeft());
const startPos = this.dragEnd.subtract(dragStart).add(
new Box(this.startPosition, this.endPosition).topLeft()
);
this.drawSelected(startPos);
}
@ -136,7 +134,7 @@ export default class DrawSelect {
handleKey(value) {
if (this.startPosition !== null && this.endPosition !== null) {
if (value === KEY_COPY || value === KEY_CUT) {
this.copyArea();
this.copyArea(this.startPosition, this.endPosition);
}
if (value === KEY_CUT) {
const eraser = new DrawErase(this.state);


+ 8
- 8
js-lib/draw/text.js View File

@ -1,20 +1,20 @@
import DrawFunction from "./function.js";
import {DrawFunction} from "./function.js";
import {ERASE_CHAR} from "../constants.js";
import State from "../state.js";
import Vector from "../vector.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
import {drawText} from "./utils.js";
/**
* @implements {DrawFunction}
*/
export default class DrawText {
export class DrawText {
/**
* @param {State} state
* @param {!State} state
*/
constructor(state, view) {
constructor(state) {
this.state = state;
this.startPosition = null;
this.endPosition = null;
/** @type {?Vector} */ this.startPosition = null;
/** @type {?Vector} */ this.endPosition = null;
}
/** @inheritDoc */


+ 7
- 7
js-lib/draw/utils.js View File

@ -1,14 +1,14 @@
import {SPECIAL_VALUE} from "../constants.js";
import {Box} from "../common.js";
import State from "../state.js";
import Vector from "../vector.js";
import {State} from "../state.js";
import {Vector} from "../vector.js";
/**
* Draws a line on the diagram state.
*
* @param {State} state
* @param {Vector} startPosition
* @param {Vector} endPosition
* @param {!State} state
* @param {!Vector} startPosition
* @param {!Vector} endPosition
* @param {boolean} clockwise
* @param {string=} value
*/
@ -46,8 +46,8 @@ export function drawLine(
/**
* Sets the cells scratch (uncommitted) values to the given text.
* Handles newlines appropriately.
* @param {State} state
* @param {Vector} position
* @param {!State} state
* @param {!Vector} position
* @param {string} text
*/
export function drawText(state, position, text) {


+ 20
- 20
js-lib/input-controller.js View File

@ -1,16 +1,16 @@
import * as c from "./constants.js";
import Controller from "./controller.js";
import Vector from "./vector.js";
import {Controller} from "./controller.js";
import {Vector} from "./vector.js";
/**
* Handles desktop inputs, and passes them onto the main controller.
*/
export class DesktopController {
/**
* @param {Controller} controller
* @param {!Controller} controller
*/
constructor(controller) {
/** @type {Controller} */ this.controller = controller;
/** @type {!Controller} */ this.controller = controller;
/** @type {boolean} */ this.isDragging = false;
this.installBindings();
@ -31,11 +31,11 @@ export class DesktopController {
*/
installBindings() {
const {canvas} = this.controller.view;
canvas.addEventListener("wheel", e => {
canvas.addEventListener("wheel", (/** @type {!WheelEvent} */ e) => {
this.handleZoom(e.deltaMode === 0 ? e.deltaY / 120 : Math.sign(e.deltaY));
});
canvas.addEventListener("mousedown", (/** @type {MouseEvent} */ e) => {
canvas.addEventListener("mousedown", (/** @type {!MouseEvent} */ e) => {
// Can drag by holding either the control or meta (Apple) key.
if (e.ctrlKey || e.metaKey) {
this.controller.startDrag(Vector.fromMouseEvent(e));
@ -53,7 +53,7 @@ export class DesktopController {
this.controller.endAll();
});
canvas.addEventListener("mousemove", (/** @type {MouseEvent} */ e) => {
canvas.addEventListener("mousemove", (/** @type {!MouseEvent} */ e) => {
this.controller.handleMove(Vector.fromMouseEvent(e));
});
}
@ -64,12 +64,12 @@ export class DesktopController {
*/
export class TouchController {
/**
* @param {Controller} controller
* @param {!Controller} controller
*/
constructor(controller) {
/** @type {Controller} */ this.controller = controller;
/** @type {!Controller} */ this.controller = controller;
/** @type {Vector} */ this.pressVector = null;
/** @type {?Vector} */ this.pressVector = null;
/** @type {number} */ this.originalZoom = NaN;
/** @type {number} */ this.zoomLength = NaN;
@ -82,7 +82,7 @@ export class TouchController {
}
/**
* @param {Vector} position
* @param {!Vector} position
*/
handlePress(position) {