From 82dc0919c83256224f23f26aa9149bcd804dd571 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 9 Jan 2019 16:53:28 +1200 Subject: [PATCH] cleanup --- desktop/main.js | 8 ++++---- desktop/sources/scripts/generator.js | 8 ++++---- desktop/sources/scripts/interface.js | 14 +++++++------- desktop/sources/scripts/lib/controller.js | 14 +++++++------- desktop/sources/scripts/picker.js | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/desktop/main.js b/desktop/main.js index 20058d3..a00c438 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -3,7 +3,7 @@ const path = require('path') const url = require('url') const shell = require('electron').shell -let is_shown = true +let isShown = true app.on('ready', () => { app.win = new BrowserWindow({ @@ -27,11 +27,11 @@ app.on('ready', () => { }) app.win.on('hide', function () { - is_shown = false + isShown = false }) app.win.on('show', function () { - is_shown = true + isShown = true }) app.on('window-all-closed', () => { @@ -59,7 +59,7 @@ app.toggle_visible = function () { if (process.platform == 'win32') { if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() } } else { - if (is_shown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() } + if (isShown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() } } } diff --git a/desktop/sources/scripts/generator.js b/desktop/sources/scripts/generator.js index 9ed7e05..410abe2 100644 --- a/desktop/sources/scripts/generator.js +++ b/desktop/sources/scripts/generator.js @@ -19,7 +19,7 @@ function Generator (layer, style) { // Rotate const 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) + seg.vertices[k2] = rotatePoint(seg.vertices[k2], center, angle) // Scale seg.vertices[k2].x *= scale @@ -40,7 +40,7 @@ function Generator (layer, style) { let vertex = vertices[id] let next = vertices[parseInt(id) + 1] - let after_next = vertices[parseInt(id) + 2] + let afterNext = 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} ` @@ -61,7 +61,7 @@ function Generator (layer, style) { let clock = mirror > 0 ? '1,1' : '1,0' html += this._arc(vertex, next, clock) } else if (type == 'bezier') { - html += this._bezier(next, after_next) + html += this._bezier(next, afterNext) skip = 1 } } @@ -113,5 +113,5 @@ function Generator (layer, style) { } function copy (data) { return data ? JSON.parse(JSON.stringify(data)) : [] } - function rotate_point (point, origin, angle) { angle = angle * Math.PI / 180.0; return { x: (Math.cos(angle) * (point.x - origin.x) - Math.sin(angle) * (point.y - origin.y) + origin.x).toFixed(1), y: (Math.sin(angle) * (point.x - origin.x) + Math.cos(angle) * (point.y - origin.y) + origin.y).toFixed(1) } } + function rotatePoint (point, origin, angle) { angle = angle * Math.PI / 180.0; return { x: (Math.cos(angle) * (point.x - origin.x) - Math.sin(angle) * (point.y - origin.y) + origin.x).toFixed(1), y: (Math.sin(angle) * (point.x - origin.x) + Math.cos(angle) * (point.y - origin.y) + origin.y).toFixed(1) } } } diff --git a/desktop/sources/scripts/interface.js b/desktop/sources/scripts/interface.js index ec2ab07..51bdfff 100644 --- a/desktop/sources/scripts/interface.js +++ b/desktop/sources/scripts/interface.js @@ -100,12 +100,12 @@ function Interface (dotgrid) { this.update = function (force = false, id) { if (this.prev_operation == dotgrid.cursor.operation && force == false) { return } - let multi_vertices = null + let multiVertices = null let segments = dotgrid.tool.layer() - const sum_segments = dotgrid.tool.length() + const sumSegments = dotgrid.tool.length() for (const i in segments) { - if (segments[i].vertices.length > 2) { multi_vertices = true; break } + if (segments[i].vertices.length > 2) { multiVertices = true; break } } document.getElementById('option_line').className.baseVal = !dotgrid.tool.canCast('line') ? 'icon inactive' : 'icon' @@ -116,7 +116,7 @@ function Interface (dotgrid) { document.getElementById('option_thickness').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_linecap').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' - document.getElementById('option_linejoin').className.baseVal = dotgrid.tool.layer().length < 1 || !multi_vertices ? 'icon inactive' : 'icon' + document.getElementById('option_linejoin').className.baseVal = dotgrid.tool.layer().length < 1 || !multiVertices ? 'icon inactive' : 'icon' document.getElementById('option_mirror').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' document.getElementById('option_fill').className.baseVal = dotgrid.tool.layer().length < 1 ? 'icon inactive' : 'icon' @@ -126,9 +126,9 @@ function Interface (dotgrid) { // Source - document.getElementById('option_save').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' - document.getElementById('option_export').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' - document.getElementById('option_render').className.baseVal = sum_segments < 1 ? 'icon inactive source' : 'icon source' + document.getElementById('option_save').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source' + document.getElementById('option_export').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source' + document.getElementById('option_render').className.baseVal = sumSegments < 1 ? 'icon inactive source' : 'icon source' document.getElementById('option_grid').className.baseVal = dotgrid.renderer.showExtras ? 'icon inactive source' : 'icon source' diff --git a/desktop/sources/scripts/lib/controller.js b/desktop/sources/scripts/lib/controller.js index 1448b26..546e29d 100644 --- a/desktop/sources/scripts/lib/controller.js +++ b/desktop/sources/scripts/lib/controller.js @@ -62,18 +62,18 @@ function Controller () { } this.generate_svg = function (m) { - let svg_html = '' + let html = '' for (const id in this.layout) { let key = this.layout[id] let acc = this.accelerator_for_key(key.name, m) - svg_html += `` - svg_html += `` - svg_html += `${key.name.toUpperCase()}` - svg_html += acc && acc.basic ? `${acc.basic}` : '' - svg_html += acc && acc.ctrl ? `${acc.ctrl}` : '' + html += `` + html += `` + html += `${key.name.toUpperCase()}` + html += acc && acc.basic ? `${acc.basic}` : '' + html += acc && acc.ctrl ? `${acc.ctrl}` : '' } - return `${svg_html}` + return `${html}` } this.documentation = function () { diff --git a/desktop/sources/scripts/picker.js b/desktop/sources/scripts/picker.js index 2a157e9..1647597 100644 --- a/desktop/sources/scripts/picker.js +++ b/desktop/sources/scripts/picker.js @@ -61,7 +61,7 @@ function Picker (dotgrid) { } this.listen = function (e, is_down = false) { - if (is_down && !is_color_char(e.key)) { + if (is_down && !isColorChar(e.key)) { e.preventDefault() return } @@ -90,7 +90,7 @@ function Picker (dotgrid) { return re.test(val) } - function is_color_char (val) { + function isColorChar (val) { const re = /[0-9A-Fa-f]/g return re.test(val) }