diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js
index 57759c1..47d1b4f 100644
--- a/desktop/sources/scripts/cursor.js
+++ b/desktop/sources/scripts/cursor.js
@@ -99,7 +99,7 @@ function Cursor()
this.pos_snap = function(pos)
{
- var grid = dotgrid.tool.settings.size.width/dotgrid.grid_x;
+ let grid = dotgrid.tool.settings.size.width/dotgrid.grid_x;
return {
x:clamp(step(pos.x,grid),grid,dotgrid.tool.settings.size.width),
y:clamp(step(pos.y,grid),grid,dotgrid.tool.settings.size.height+grid)
diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js
index f56278d..a901fe6 100644
--- a/desktop/sources/scripts/dotgrid.js
+++ b/desktop/sources/scripts/dotgrid.js
@@ -48,7 +48,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.open = function()
{
- var paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]});
+ if(!dialog){ return; }
+
+ let paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]});
if(!paths){ console.log("Nothing to load"); return; }
@@ -76,7 +78,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.save_web = function(content)
{
console.info("Web Save");
- var win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`);
+ let win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`);
win.document.body.innerHTML = `
To save: Copy this into a .grid file.
To load: Drag the .grid onto the browser window.
${content}
`;
}
@@ -118,7 +120,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.export_web = function(content)
{
console.info("Web Export");
- var win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`);
+ let win = window.open("", "Save", `toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=${screen.height-200},left=${screen.width-640}`);
win.document.body.innerHTML = `${dotgrid.renderer.to_svg()}`;
}
@@ -132,7 +134,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.tool.settings.size.height = size.height
try{
- var win = require('electron').remote.getCurrentWindow();
+ let win = require('electron').remote.getCurrentWindow();
win.setSize((size.width+100)*scale,(size.height+100+(interface ? 10 : 0))*scale,true);
}
catch(err){
@@ -182,7 +184,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.refresh = function()
{
- var size = {width:step(window.innerWidth-90,15),height:step(window.innerHeight-120,15)}
+ let size = {width:step(window.innerWidth-90,15),height:step(window.innerHeight-120,15)}
dotgrid.tool.settings.size.width = size.width
dotgrid.tool.settings.size.height = size.height
@@ -205,11 +207,11 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
e.preventDefault();
e.stopPropagation();
- var file = e.dataTransfer.files[0];
+ let file = e.dataTransfer.files[0];
if(!file.path || file.path.indexOf(".dot") < 0 && file.path.indexOf(".grid") < 0){ console.log("Dotgrid","Not a dot file"); return; }
- var reader = new FileReader();
+ let reader = new FileReader();
reader.onload = function(e){
dotgrid.tool.replace(JSON.parse(e.target.result.toString().trim()));
dotgrid.guide.refresh();
@@ -250,7 +252,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
this.paste = function(e)
{
if(e.target !== this.picker.el){
- var data = e.clipboardData.getData("text/source");
+ let data = e.clipboardData.getData("text/source");
if (is_json(data)) {
data = JSON.parse(data.trim());
dotgrid.tool.import(data);
diff --git a/desktop/sources/scripts/generator.js b/desktop/sources/scripts/generator.js
index fdcf064..71c8f52 100644
--- a/desktop/sources/scripts/generator.js
+++ b/desktop/sources/scripts/generator.js
@@ -5,11 +5,11 @@ function Generator(layer,style)
function operate(layer,offset,scale,mirror = 0,angle = 0)
{
- var l = copy(layer)
+ let l = copy(layer)
- for(k1 in l){
- var seg = l[k1];
- for(k2 in seg.vertices){
+ for(let k1 in l){
+ let seg = l[k1];
+ for(let k2 in seg.vertices){
if(mirror == 1){ seg.vertices[k2].x = (dotgrid.tool.settings.size.width) - seg.vertices[k2].x + 15 }
if(mirror == 2){ seg.vertices[k2].y = (dotgrid.tool.settings.size.height) - seg.vertices[k2].y + 30 }
@@ -18,7 +18,7 @@ function Generator(layer,style)
seg.vertices[k2].y += offset.y
// Rotate
- var center = {x:(dotgrid.tool.settings.size.width/2)+offset.x+(7.5),y:(dotgrid.tool.settings.size.height/2)+offset.y+30}
+ let center = {x:(dotgrid.tool.settings.size.width/2)+offset.x+(7.5),y:(dotgrid.tool.settings.size.height/2)+offset.y+30}
seg.vertices[k2] = rotate_point(seg.vertices[k2],center,angle)
// Scale
@@ -31,17 +31,17 @@ function Generator(layer,style)
this.render = function(prev,segment,mirror = 0)
{
- var type = segment.type;
- var vertices = segment.vertices;
- var html = '';
- var skip = 0;
+ let type = segment.type;
+ let vertices = segment.vertices;
+ let html = '';
+ let skip = 0;
- for(id in vertices){
+ for(let id in vertices){
if(skip > 0){ skip -= 1; continue; }
- var vertex = vertices[id]
- var next = vertices[parseInt(id)+1]
- var after_next = vertices[parseInt(id)+2]
+ let vertex = vertices[id]
+ let next = vertices[parseInt(id)+1]
+ let after_next = vertices[parseInt(id)+2]
if(id == 0 && !prev || id == 0 && prev && (prev.x != vertex.x || prev.y != vertex.y)){
html += `M${vertex.x},${vertex.y} `
@@ -51,11 +51,11 @@ function Generator(layer,style)
html += `L${vertex.x},${vertex.y} `;
}
else if(type == "arc_c"){
- var clock = mirror > 0 ? '0,0' : '0,1'
+ let clock = mirror > 0 ? '0,0' : '0,1'
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : '';
}
else if(type == "arc_r"){
- var clock = mirror > 0 ? '0,1' : '0,0'
+ let clock = mirror > 0 ? '0,1' : '0,0'
html += next ? `A${Math.abs(next.x - vertex.x)},${Math.abs(next.y - vertex.y)} 0 ${clock} ${next.x},${next.y} ` : '';
}
else if(type == "bezier"){
@@ -76,10 +76,10 @@ function Generator(layer,style)
this.convert = function(layer,mirror,angle)
{
- var s = ""
- var prev = null
- for(id in layer){
- var seg = layer[id];
+ let s = ""
+ let prev = null
+ for(let id in layer){
+ let seg = layer[id];
s += `${this.render(prev,seg,mirror)}`
prev = seg.vertices ? seg.vertices[seg.vertices.length-1] : null
}
@@ -89,7 +89,7 @@ function Generator(layer,style)
this.toString = function(offset = {x:0,y:0}, scale = 1, mirror = this.style && this.style.mirror_style ? this.style.mirror_style : 0)
{
- var s = this.convert(operate(this.layer,offset,scale))
+ let s = this.convert(operate(this.layer,offset,scale))
if(mirror == 1 || mirror == 2){
s += this.convert(operate(this.layer,offset,scale,mirror),mirror)
diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js
index ea88690..d0a12be 100644
--- a/desktop/sources/scripts/guide.js
+++ b/desktop/sources/scripts/guide.js
@@ -48,7 +48,7 @@ function Guide()
this.resize = function(size)
{
- var offset = 15
+ let offset = 15
this.el.width = (size.width+offset)*this.scale;
this.el.height = (size.height+(offset*2))*this.scale;
this.el.style.width = (size.width+offset)+"px";
@@ -61,10 +61,10 @@ function Guide()
{
if(!this.show_extras){ return; }
- for(segment_id in dotgrid.tool.layer()){
- var segment = dotgrid.tool.layer()[segment_id];
- for(vertex_id in segment.vertices){
- var vertex = segment.vertices[vertex_id];
+ for(let segment_id in dotgrid.tool.layer()){
+ let segment = dotgrid.tool.layer()[segment_id];
+ for(let vertex_id in segment.vertices){
+ let vertex = segment.vertices[vertex_id];
this.draw_handle(vertex);
}
}
@@ -72,7 +72,7 @@ function Guide()
this.draw_vertices = function()
{
- for(id in dotgrid.tool.vertices){
+ for(let id in dotgrid.tool.vertices){
this.draw_vertex(dotgrid.tool.vertices[id]);
}
}
@@ -81,14 +81,14 @@ function Guide()
{
if(!this.show_extras){ return; }
- var cursor = {x:parseInt(dotgrid.cursor.pos.x/dotgrid.grid_width),y:parseInt(dotgrid.cursor.pos.y/dotgrid.grid_width)}
+ let cursor = {x:parseInt(dotgrid.cursor.pos.x/dotgrid.grid_width),y:parseInt(dotgrid.cursor.pos.y/dotgrid.grid_width)}
- for (var x = dotgrid.grid_x-1; x >= 0; x--) {
- for (var y = dotgrid.grid_y; y >= 0; y--) {
- var is_step = x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0;
+ for (let x = dotgrid.grid_x-1; x >= 0; x--) {
+ for (let y = dotgrid.grid_y; y >= 0; y--) {
+ let is_step = x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0;
// Color
- var color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low;
+ let color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low;
if((y == 0 || y == dotgrid.grid_y) && cursor.x == x+1){ color = dotgrid.theme.active.f_high; }
else if((x == 0 || x == dotgrid.grid_x-1) && cursor.y == y+1){ color = dotgrid.theme.active.f_high; }
else if(cursor.x == x+1 && cursor.y == y+1){ color = dotgrid.theme.active.f_high; }
@@ -103,7 +103,7 @@ function Guide()
this.draw_marker = function(pos,radius = 1,color)
{
- var ctx = this.el.getContext('2d');
+ let ctx = this.el.getContext('2d');
ctx.beginPath();
ctx.lineWidth = 2;
ctx.arc(pos.x * this.scale, pos.y * this.scale, radius, 0, 2 * Math.PI, false);
@@ -114,7 +114,7 @@ function Guide()
this.draw_vertex = function(pos, radius = 5)
{
- var ctx = this.el.getContext('2d');
+ let ctx = this.el.getContext('2d');
ctx.beginPath();
ctx.lineWidth = 2;
ctx.arc((pos.x * this.scale), (pos.y * this.scale), radius, 0, 2 * Math.PI, false);
@@ -125,7 +125,7 @@ function Guide()
this.draw_handle = function(pos, radius = 6)
{
- var ctx = this.el.getContext('2d');
+ let ctx = this.el.getContext('2d');
ctx.beginPath();
ctx.lineWidth = 3;
@@ -152,8 +152,8 @@ function Guide()
this.draw_path = function(path,style)
{
- var ctx = this.el.getContext('2d');
- var p = new Path2D(path);
+ let ctx = this.el.getContext('2d');
+ let p = new Path2D(path);
ctx.strokeStyle = style.color;
ctx.lineWidth = style.thickness * this.scale;
@@ -175,7 +175,7 @@ function Guide()
{
if(!dotgrid.cursor.translation){ return; }
- var ctx = this.el.getContext('2d');
+ let ctx = this.el.getContext('2d');
ctx.beginPath();
ctx.moveTo((dotgrid.cursor.translation.from.x * this.scale),(dotgrid.cursor.translation.from.y * this.scale));
@@ -193,7 +193,7 @@ function Guide()
this.draw_cursor = function(pos = dotgrid.cursor.pos,radius = dotgrid.tool.style().thickness-1)
{
- var ctx = this.el.getContext('2d');
+ let ctx = this.el.getContext('2d');
ctx.beginPath();
ctx.lineWidth = 3;
@@ -214,14 +214,14 @@ function Guide()
this.draw_preview = function()
{
- var ctx = this.el.getContext('2d');
- var operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null
+ let ctx = this.el.getContext('2d');
+ let operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null
if(!dotgrid.tool.can_cast(operation)){ return; }
if(operation == "close"){ return; }
- var path = new Generator([{vertices:dotgrid.tool.vertices,type:operation}]).toString({x:0,y:0},2)
- var style = {
+ let path = new Generator([{vertices:dotgrid.tool.vertices,type:operation}]).toString({x:0,y:0},2)
+ let style = {
color:dotgrid.theme.active.f_med,
thickness:2,
strokeLinecap:"round",
diff --git a/desktop/sources/scripts/interface.js b/desktop/sources/scripts/interface.js
index 7ab91b1..8884049 100644
--- a/desktop/sources/scripts/interface.js
+++ b/desktop/sources/scripts/interface.js
@@ -14,8 +14,8 @@ function Interface()
document.getElementById("app").appendChild(this.el);
this.el.appendChild(dotgrid.picker.el);
- var html = ""
- var options = {
+ let html = ""
+ let options = {
cast:{
line: { key:"A",icon:"M60,60 L240,240" },
arc_c: { key:"S",icon:"M60,60 A180,180 0 0,1 240,240" },
@@ -42,10 +42,10 @@ function Interface()
}
}
- for(type in options){
- var tools = options[type];
- for(name in tools){
- var tool = tools[name];
+ for(let type in options){
+ let tools = options[type];
+ for(let name in tools){
+ let tool = tools[name];
html += `