autofix eslint

This commit is contained in:
Thomas Grainger 2016-11-30 11:35:16 +00:00
parent c9cbc4ab81
commit 5f3226a8f7
No known key found for this signature in database
GPG key ID: 995EA0A029283160
10 changed files with 243 additions and 245 deletions

View file

@ -1,7 +1,6 @@
import Utils from '../core/Utils'; import Utils from '../core/Utils';
/** /**
* Bitwise operations. * Bitwise operations.
* *

View file

@ -1,7 +1,6 @@
import Utils from '../core/Utils'; import Utils from '../core/Utils';
/** /**
* Byte representation operations. * Byte representation operations.
* *

View file

@ -16,7 +16,7 @@ const Zlib = {
Gunzip: zlibAndGzip.Zlib.Gunzip, Gunzip: zlibAndGzip.Zlib.Gunzip,
Zip: zip.Zlib.Zip, Zip: zip.Zlib.Zip,
Unzip: zip.Zlib.Unzip, Unzip: zip.Zlib.Unzip,
} };
/** /**

View file

@ -160,7 +160,7 @@ const HTML = {
* @returns {html} * @returns {html}
*/ */
run_parse_colour_code(input, args) { run_parse_colour_code(input, args) {
var m = null, let m = null,
r = 0, r = 0,
g = 0, g = 0,
b = 0, b = 0,
@ -201,7 +201,7 @@ const HTML = {
b = Math.round(255 * (1 - y_) * (1 - k_)); b = Math.round(255 * (1 - y_) * (1 - k_));
} }
var hsl_ = HTML._rgb_to_hsl(r, g, b), let hsl_ = HTML._rgb_to_hsl(r, g, b),
h = Math.round(hsl_[0] * 360), h = Math.round(hsl_[0] * 360),
s = Math.round(hsl_[1] * 100), s = Math.round(hsl_[1] * 100),
l = Math.round(hsl_[2] * 100), l = Math.round(hsl_[2] * 100),
@ -226,7 +226,7 @@ const HTML = {
cmyk = `cmyk(${c}, ${m}, ${y}, ${k})`; cmyk = `cmyk(${c}, ${m}, ${y}, ${k})`;
// Generate output // Generate output
return `${"<div data-cyber-chef-func='colorpicker' data-rgba='" + rgba + "' id='colorpicker' style='display: inline-block'></div>" + return `${`<div data-cyber-chef-func='colorpicker' data-rgba='${rgba}' id='colorpicker' style='display: inline-block'></div>` +
'Hex: '}${hex}\n` + 'Hex: '}${hex}\n` +
`RGB: ${rgb}\n` + `RGB: ${rgb}\n` +
`RGBA: ${rgba}\n` + `RGBA: ${rgba}\n` +

View file

@ -1,7 +1,6 @@
import Utils from '../core/Utils'; import Utils from '../core/Utils';
/** /**
* Hexdump operations. * Hexdump operations.
* *

View file

@ -2,7 +2,6 @@ import Utils from '../core/Utils';
import JsDiff from '../lib/diff'; import JsDiff from '../lib/diff';
/** /**
* String utility operations. * String utility operations.
* *

View file

@ -3,7 +3,6 @@ import HTMLOperation from './HTMLOperation';
import Sortable from '../../lib/Sortable'; import Sortable from '../../lib/Sortable';
/** /**
* Waiter to handle events related to the operations. * Waiter to handle events related to the operations.
* *

View file

@ -9,8 +9,8 @@ const inlineFuncs = {
color: rgba, color: rgba,
container: true, container: true,
inline: true, inline: true,
}).on('changeColor', function(e) { }).on('changeColor', (e) => {
const { r, g, b, a} = e.color.toRGB(); const { r, g, b, a } = e.color.toRGB();
const css = `rgba(${r}, ${g}, ${b}, ${a})`; const css = `rgba(${r}, ${g}, ${b}, ${a})`;
document.getElementById('input-text').value = css; document.getElementById('input-text').value = css;
window.app.auto_bake(); window.app.auto_bake();
@ -26,12 +26,12 @@ const inlineFuncs = {
{ {
label: 'English text', label: 'English text',
min: 3.5, min: 3.5,
max: 5 max: 5,
},{ }, {
label: 'Encrypted/compressed', label: 'Encrypted/compressed',
min: 7.5, min: 7.5,
max: 8 max: 8,
} },
]); ]);
}, },
freq({ percentages }) { freq({ percentages }) {
@ -41,8 +41,8 @@ const inlineFuncs = {
canvas.width = parent_rect.width * 0.95; canvas.width = parent_rect.width * 0.95;
canvas.height = parent_rect.height * 0.9; canvas.height = parent_rect.height * 0.9;
CanvasComponents.draw_bar_chart(canvas, scores, 'Byte', 'Frequency %', 16, 6); CanvasComponents.draw_bar_chart(canvas, scores, 'Byte', 'Frequency %', 16, 6);
} },
} };
/** /**
* Waiter to handle events related to the output. * Waiter to handle events related to the output.

View file

@ -10,7 +10,7 @@
*/ */
const CanvasComponents = { const CanvasComponents = {
draw_line: function(ctx, start_x, start_y, end_x, end_y) { draw_line(ctx, start_x, start_y, end_x, end_y) {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(start_x, start_y); ctx.moveTo(start_x, start_y);
ctx.lineTo(end_x, end_y); ctx.lineTo(end_x, end_y);
@ -18,7 +18,7 @@ const CanvasComponents = {
ctx.stroke(); ctx.stroke();
}, },
draw_bar_chart: function(canvas, scores, x_axis_label, y_axis_label, num_x_labels, num_y_labels, font_size) { draw_bar_chart(canvas, scores, x_axis_label, y_axis_label, num_x_labels, num_y_labels, font_size) {
font_size = font_size || 15; font_size = font_size || 15;
if (!num_x_labels || num_x_labels > Math.round(canvas.width / 50)) { if (!num_x_labels || num_x_labels > Math.round(canvas.width / 50)) {
num_x_labels = Math.round(canvas.width / 50); num_x_labels = Math.round(canvas.width / 50);
@ -28,7 +28,7 @@ const CanvasComponents = {
} }
// Graph properties // Graph properties
var ctx = canvas.getContext("2d"), let ctx = canvas.getContext('2d'),
left_padding = canvas.width * 0.08, left_padding = canvas.width * 0.08,
right_padding = canvas.width * 0.03, right_padding = canvas.width * 0.03,
top_padding = canvas.height * 0.08, top_padding = canvas.height * 0.08,
@ -38,60 +38,60 @@ const CanvasComponents = {
base = top_padding + graph_height, base = top_padding + graph_height,
ceil = top_padding; ceil = top_padding;
ctx.font = font_size + "px Arial"; ctx.font = `${font_size}px Arial`;
// Draw axis // Draw axis
ctx.lineWidth = "1.0"; ctx.lineWidth = '1.0';
ctx.strokeStyle = "#444"; ctx.strokeStyle = '#444';
CanvasComponents.draw_line(ctx, left_padding, base, graph_width + left_padding, base); // x CanvasComponents.draw_line(ctx, left_padding, base, graph_width + left_padding, base); // x
CanvasComponents.draw_line(ctx, left_padding, base, left_padding, ceil); // y CanvasComponents.draw_line(ctx, left_padding, base, left_padding, ceil); // y
// Bar properties // Bar properties
var bar_padding = graph_width * 0.003, let bar_padding = graph_width * 0.003,
bar_width = (graph_width - (bar_padding * scores.length)) / scores.length, bar_width = (graph_width - (bar_padding * scores.length)) / scores.length,
curr_x = left_padding + bar_padding, curr_x = left_padding + bar_padding,
max = Math.max.apply(Math, scores); max = Math.max(...scores);
// Draw bars // Draw bars
ctx.fillStyle = "green"; ctx.fillStyle = 'green';
for (var i = 0; i < scores.length; i++) { for (var i = 0; i < scores.length; i++) {
var h = scores[i] / max * graph_height; const h = scores[i] / max * graph_height;
ctx.fillRect(curr_x, base - h, bar_width, h); ctx.fillRect(curr_x, base - h, bar_width, h);
curr_x += bar_width + bar_padding; curr_x += bar_width + bar_padding;
} }
// Mark x axis // Mark x axis
ctx.fillStyle = "black"; ctx.fillStyle = 'black';
ctx.textAlign = "center"; ctx.textAlign = 'center';
curr_x = left_padding + bar_padding; curr_x = left_padding + bar_padding;
if (num_x_labels >= scores.length) { if (num_x_labels >= scores.length) {
// Mark every score // Mark every score
for (var j = 0; j <= scores.length; j++) { for (let j = 0; j <= scores.length; j++) {
ctx.fillText(j, curr_x, base + (bottom_padding * 0.3)); ctx.fillText(j, curr_x, base + (bottom_padding * 0.3));
curr_x += bar_width + bar_padding; curr_x += bar_width + bar_padding;
} }
} else { } else {
// Mark some scores // Mark some scores
for (var k = 0; k <= num_x_labels; k++) { for (let k = 0; k <= num_x_labels; k++) {
var val = Math.ceil((scores.length / num_x_labels) * k); const val = Math.ceil((scores.length / num_x_labels) * k);
curr_x = (graph_width / num_x_labels) * k + left_padding; curr_x = (graph_width / num_x_labels) * k + left_padding;
ctx.fillText(val, curr_x, base + (bottom_padding * 0.3)); ctx.fillText(val, curr_x, base + (bottom_padding * 0.3));
} }
} }
// Mark y axis // Mark y axis
ctx.textAlign = "right"; ctx.textAlign = 'right';
var curr_y; let curr_y;
if (num_y_labels >= max) { if (num_y_labels >= max) {
// Mark every increment // Mark every increment
for (var l = 0; l <= max; l++) { for (let l = 0; l <= max; l++) {
curr_y = base - (l / max * graph_height) + font_size / 3; curr_y = base - (l / max * graph_height) + font_size / 3;
ctx.fillText(i, left_padding * 0.8, curr_y); ctx.fillText(i, left_padding * 0.8, curr_y);
} }
} else { } else {
// Mark some increments // Mark some increments
for (var m = 0; m <= num_y_labels; m++) { for (let m = 0; m <= num_y_labels; m++) {
var val2 = Math.ceil((max / num_y_labels) * m); const val2 = Math.ceil((max / num_y_labels) * m);
curr_y = base - (val2 / max * graph_height) + font_size / 3; curr_y = base - (val2 / max * graph_height) + font_size / 3;
ctx.fillText(val2, left_padding * 0.8, curr_y); ctx.fillText(val2, left_padding * 0.8, curr_y);
} }
@ -99,26 +99,26 @@ const CanvasComponents = {
// Label x axis // Label x axis
if (x_axis_label) { if (x_axis_label) {
ctx.textAlign = "center"; ctx.textAlign = 'center';
ctx.fillText(x_axis_label, graph_width / 2 + left_padding, base + bottom_padding * 0.8); ctx.fillText(x_axis_label, graph_width / 2 + left_padding, base + bottom_padding * 0.8);
} }
// Label y axis // Label y axis
if (y_axis_label) { if (y_axis_label) {
ctx.save(); ctx.save();
var x = left_padding * 0.3, let x = left_padding * 0.3,
y = graph_height / 2 + top_padding; y = graph_height / 2 + top_padding;
ctx.translate(x, y); ctx.translate(x, y);
ctx.rotate(-Math.PI / 2); ctx.rotate(-Math.PI / 2);
ctx.textAlign = "center"; ctx.textAlign = 'center';
ctx.fillText(y_axis_label, 0, 0); ctx.fillText(y_axis_label, 0, 0);
ctx.restore(); ctx.restore();
} }
}, },
draw_scale_bar: function(canvas, score, max, markings) { draw_scale_bar(canvas, score, max, markings) {
// Bar properties // Bar properties
var ctx = canvas.getContext("2d"), let ctx = canvas.getContext('2d'),
left_padding = canvas.width * 0.01, left_padding = canvas.width * 0.01,
right_padding = canvas.width * 0.01, right_padding = canvas.width * 0.01,
top_padding = canvas.height * 0.1, top_padding = canvas.height * 0.1,
@ -127,25 +127,28 @@ const CanvasComponents = {
bar_width = canvas.width - left_padding - right_padding; bar_width = canvas.width - left_padding - right_padding;
// Scale properties // Scale properties
var proportion = score / max; const proportion = score / max;
// Draw bar outline // Draw bar outline
ctx.strokeRect(left_padding, top_padding, bar_width, bar_height); ctx.strokeRect(left_padding, top_padding, bar_width, bar_height);
// Shade in up to proportion // Shade in up to proportion
var grad = ctx.createLinearGradient(left_padding, 0, bar_width + left_padding, 0); const grad = ctx.createLinearGradient(left_padding, 0, bar_width + left_padding, 0);
grad.addColorStop(0, "green"); grad.addColorStop(0, 'green');
grad.addColorStop(0.5, "gold"); grad.addColorStop(0.5, 'gold');
grad.addColorStop(1, "red"); grad.addColorStop(1, 'red');
ctx.fillStyle = grad; ctx.fillStyle = grad;
ctx.fillRect(left_padding, top_padding, bar_width * proportion, bar_height); ctx.fillRect(left_padding, top_padding, bar_width * proportion, bar_height);
// Add markings // Add markings
var x0, y0, x1, y1; let x0,
ctx.fillStyle = "black"; y0,
ctx.textAlign = "center"; x1,
ctx.font = "13px Arial"; y1;
for (var i = 0; i < markings.length; i++) { ctx.fillStyle = 'black';
ctx.textAlign = 'center';
ctx.font = '13px Arial';
for (let i = 0; i < markings.length; i++) {
// Draw min line down // Draw min line down
x0 = bar_width / max * markings[i].min + left_padding; x0 = bar_width / max * markings[i].min + left_padding;
y0 = top_padding + bar_height + (bottom_padding * 0.1); y0 = top_padding + bar_height + (bottom_padding * 0.1);
@ -167,12 +170,12 @@ const CanvasComponents = {
// Add label // Add label
if (markings[i].max >= max * 0.9) { if (markings[i].max >= max * 0.9) {
ctx.textAlign = "right"; ctx.textAlign = 'right';
x0 = x1; x0 = x1;
} else if (markings[i].max <= max * 0.1) { } else if (markings[i].max <= max * 0.1) {
ctx.textAlign = "left"; ctx.textAlign = 'left';
} else { } else {
x0 = x0 + (x1 - x0) / 2; x0 += (x1 - x0) / 2;
} }
y0 = top_padding + bar_height + (bottom_padding * 0.8); y0 = top_padding + bar_height + (bottom_padding * 0.8);
ctx.fillText(markings[i].label, x0, y0); ctx.fillText(markings[i].label, x0, y0);