- Linting (ESLint): As per latest ash-nazg

This commit is contained in:
Brett Zamir
2020-03-27 20:39:51 +08:00
parent 1f1452f4fa
commit 7914f26e02
20 changed files with 113 additions and 101 deletions

View File

@@ -61,7 +61,10 @@ module.exports = {
polyfills: [ polyfills: [
'document.querySelector', 'document.querySelector',
'history.pushState', 'history.pushState',
'history.replaceState' 'history.replaceState',
'Number.parseFloat',
'Number.parseInt',
'Number.isNaN'
] ]
}, },
rules: { rules: {
@@ -136,6 +139,9 @@ module.exports = {
'JSON', 'JSON',
'location.href', 'location.href',
'MutationObserver', 'MutationObserver',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'Object.assign', 'Object.assign',
'Object.defineProperty', 'Object.defineProperty',
'Object.defineProperties', 'Object.defineProperties',
@@ -170,6 +176,9 @@ module.exports = {
'console', 'console',
'fetch', 'fetch',
'location.origin', 'location.origin',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'window.postMessage' 'window.postMessage'
] ]
}, },
@@ -231,6 +240,8 @@ module.exports = {
files: ['canvg/rgbcolor.js'], files: ['canvg/rgbcolor.js'],
settings: { settings: {
polyfills: [ polyfills: [
'Number.isNaN',
'Number.parseInt',
'Object.assign', 'Object.assign',
'Object.keys' 'Object.keys'
] ]
@@ -266,6 +277,7 @@ module.exports = {
'document.body', 'document.body',
'document.head', 'document.head',
'DOMParser', 'DOMParser',
'Number.isNaN',
'Object.keys', 'Object.keys',
'Object.entries', 'Object.entries',
'Promise' 'Promise'

View File

@@ -224,7 +224,7 @@ function build (opts) {
numValue () { numValue () {
if (!this.hasValue()) return 0; if (!this.hasValue()) return 0;
let n = parseFloat(this.value); let n = Number.parseFloat(this.value);
if (String(this.value).endsWith('%')) { if (String(this.value).endsWith('%')) {
n /= 100.0; n /= 100.0;
} }
@@ -414,7 +414,7 @@ function build (opts) {
// points and paths // points and paths
svg.ToNumberArray = function (s) { svg.ToNumberArray = function (s) {
const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' '); const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
return a.map((_a) => parseFloat(_a)); return a.map((_a) => Number.parseFloat(_a));
}; };
svg.Point = class { svg.Point = class {
constructor (x, y) { constructor (x, y) {
@@ -1308,7 +1308,7 @@ function build (opts) {
}, },
getScalar () { getScalar () {
return parseFloat(this.getToken()); return Number.parseFloat(this.getToken());
}, },
nextCommand () { nextCommand () {
@@ -1908,8 +1908,8 @@ function build (opts) {
if (this.values.hasValue()) { if (this.values.hasValue()) {
const p = ret.progress * (this.values.value.length - 1); const p = ret.progress * (this.values.value.length - 1);
const lb = Math.floor(p), ub = Math.ceil(p); const lb = Math.floor(p), ub = Math.ceil(p);
ret.from = new svg.Property('from', parseFloat(this.values.value[lb])); ret.from = new svg.Property('from', Number.parseFloat(this.values.value[lb]));
ret.to = new svg.Property('to', parseFloat(this.values.value[ub])); ret.to = new svg.Property('to', Number.parseFloat(this.values.value[ub]));
ret.progress = (p - lb) / (ub - lb); ret.progress = (p - lb) / (ub - lb);
} else { } else {
ret.from = this.from; ret.from = this.from;
@@ -1942,7 +1942,7 @@ function build (opts) {
const r = from.r + (to.r - from.r) * p.progress; const r = from.r + (to.r - from.r) * p.progress;
const g = from.g + (to.g - from.g) * p.progress; const g = from.g + (to.g - from.g) * p.progress;
const b = from.b + (to.b - from.b) * p.progress; const b = from.b + (to.b - from.b) * p.progress;
return 'rgb(' + parseInt(r) + ',' + parseInt(g) + ',' + parseInt(b) + ')'; return 'rgb(' + Number.parseInt(r) + ',' + Number.parseInt(g) + ',' + Number.parseInt(b) + ')';
} }
return this.attribute('from').value; return this.attribute('from').value;
} }

View File

@@ -158,7 +158,7 @@ const colorDefs = [
// re: /^rgb\((?<r>\d{1,3}),\s*(?<g>\d{1,3}),\s*(?<b>\d{1,3})\)$/, // re: /^rgb\((?<r>\d{1,3}),\s*(?<g>\d{1,3}),\s*(?<b>\d{1,3})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'], example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process (_, ...bits) { process (_, ...bits) {
return bits.map((b) => parseInt(b)); return bits.map((b) => Number.parseInt(b));
} }
}, },
{ {
@@ -166,7 +166,7 @@ const colorDefs = [
// re: /^(?<r>\w{2})(?<g>\w{2})(?<b>\w{2})$/, // re: /^(?<r>\w{2})(?<g>\w{2})(?<b>\w{2})$/,
example: ['#00ff00', '336699'], example: ['#00ff00', '336699'],
process (_, ...bits) { process (_, ...bits) {
return bits.map((b) => parseInt(b, 16)); return bits.map((b) => Number.parseInt(b, 16));
} }
}, },
{ {
@@ -174,7 +174,7 @@ const colorDefs = [
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/, // re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'], example: ['#fb0', 'f0f'],
process (_, ...bits) { process (_, ...bits) {
return bits.map((b) => parseInt(b + b, 16)); return bits.map((b) => Number.parseInt(b + b, 16));
} }
} }
]; ];

View File

@@ -111,8 +111,8 @@ export const remapElement = function (selected, changes, m) {
// therefore [T'] = [M_inv][T][M] // therefore [T'] = [M_inv][T][M]
const existing = transformListToTransform(selected).matrix, const existing = transformListToTransform(selected).matrix,
tNew = matrixMultiply(existing.inverse(), m, existing); tNew = matrixMultiply(existing.inverse(), m, existing);
changes.x = parseFloat(changes.x) + tNew.e; changes.x = Number.parseFloat(changes.x) + tNew.e;
changes.y = parseFloat(changes.y) + tNew.f; changes.y = Number.parseFloat(changes.y) + tNew.f;
} else { } else {
// we just absorb all matrices into the element and don't do any remapping // we just absorb all matrices into the element and don't do any remapping
const chlist = getTransformList(selected); const chlist = getTransformList(selected);

View File

@@ -253,7 +253,7 @@ export class Drawing {
return false; return false;
} }
// extract the obj_num of this id // extract the obj_num of this id
const num = parseInt(id.substr(front.length)); const num = Number.parseInt(id.substr(front.length));
// if we didn't get a positive number or we already released this number // if we didn't get a positive number or we already released this number
// then return false. // then return false.

View File

@@ -14,7 +14,7 @@ export default {
// https://code.google.com/p/chromium/issues/detail?id=565120. // https://code.google.com/p/chromium/issues/detail?id=565120.
if (isChrome()) { if (isChrome()) {
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7; const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
const chromeVersion = parseInt(navigator.userAgent.substring(verIndex)); const chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) { if (chromeVersion < 49) {
return undefined; return undefined;
} }
@@ -37,12 +37,12 @@ export default {
// Define dynamic animation of the view box. // Define dynamic animation of the view box.
const updateViewBox = function () { const updateViewBox = function () {
const portHeight = parseFloat($('#workarea').css('height')); const portHeight = Number.parseFloat($('#workarea').css('height'));
const portWidth = parseFloat($('#workarea').css('width')); const portWidth = Number.parseFloat($('#workarea').css('width'));
const portX = $('#workarea').scrollLeft(); const portX = $('#workarea').scrollLeft();
const portY = $('#workarea').scrollTop(); const portY = $('#workarea').scrollTop();
const windowWidth = parseFloat($('#svgcanvas').css('width')); const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = parseFloat($('#svgcanvas').css('height')); const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width'); const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); const overviewHeight = $('#overviewMiniView').attr('height');
@@ -93,12 +93,12 @@ export default {
// Set up the overview window as a controller for the view port. // Set up the overview window as a controller for the view port.
overviewWindowGlobals.viewBoxDragging = false; overviewWindowGlobals.viewBoxDragging = false;
const updateViewPortFromViewBox = function () { const updateViewPortFromViewBox = function () {
const windowWidth = parseFloat($('#svgcanvas').css('width')); const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = parseFloat($('#svgcanvas').css('height')); const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width'); const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = parseFloat($('#overview_window_view_box').css('left')); const viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left'));
const viewBoxY = parseFloat($('#overview_window_view_box').css('top')); const viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top'));
const portX = viewBoxX / overviewWidth * windowWidth; const portX = viewBoxX / overviewWidth * windowWidth;
const portY = viewBoxY / overviewHeight * windowHeight; const portY = viewBoxY / overviewHeight * windowHeight;
@@ -118,8 +118,8 @@ export default {
const mouseY = (evt.offsetY || evt.originalEvent.layerY); const mouseY = (evt.offsetY || evt.originalEvent.layerY);
const overviewWidth = $('#overviewMiniView').attr('width'); const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height'); const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxWidth = parseFloat($('#overview_window_view_box').css('min-width')); const viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width'));
const viewBoxHeight = parseFloat($('#overview_window_view_box').css('min-height')); const viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height'));
let viewBoxX = mouseX - 0.5 * viewBoxWidth; let viewBoxX = mouseX - 0.5 * viewBoxWidth;
let viewBoxY = mouseY - 0.5 * viewBoxHeight; let viewBoxY = mouseY - 0.5 * viewBoxHeight;

View File

@@ -106,7 +106,7 @@ export default {
*/ */
function updateFont (font) { function updateFont (font) {
font = font.split(' '); font = font.split(' ');
const fontSize = parseInt(font.pop()); const fontSize = Number.parseInt(font.pop());
font = font.join(' '); font = font.join(' ');
selElems.forEach((elem) => { selElems.forEach((elem) => {
if (elem && elem.getAttribute('class').includes('placemark')) { if (elem && elem.getAttribute('class').includes('placemark')) {
@@ -356,7 +356,7 @@ export default {
const id = svgCanvas.getNextId(); const id = svgCanvas.getNextId();
const items = $('#placemarkText').val().split(';'); const items = $('#placemarkText').val().split(';');
let font = $('#placemarkFont').val().split(' '); let font = $('#placemarkFont').val().split(' ');
const fontSize = parseInt(font.pop()); const fontSize = Number.parseInt(font.pop());
font = font.join(' '); font = font.join(' ');
const x0 = opts.start_x + 10, y0 = opts.start_y + 10; const x0 = opts.start_x + 10, y0 = opts.start_y + 10;
let maxlen = 0; let maxlen = 0;

View File

@@ -515,7 +515,7 @@ export default function jQueryPluginJGraduate ($) {
let inverted = ''; let inverted = '';
for (let i = 0; i < 6; i += 2) { for (let i = 0; i < 6; i += 2) {
// const ch = color.substr(i, 2); // const ch = color.substr(i, 2);
let inv = (255 - parseInt(color.substr(i, 2), 16)).toString(16); let inv = (255 - Number.parseInt(color.substr(i, 2), 16)).toString(16);
if (inv.length < 2) inv = 0 + inv; if (inv.length < 2) inv = 0 + inv;
inverted += inv; inverted += inv;
} }
@@ -535,15 +535,15 @@ export default function jQueryPluginJGraduate ($) {
} }
} }
const x1 = parseFloat(grad.getAttribute('x1') || 0.0), const x1 = Number.parseFloat(grad.getAttribute('x1') || 0.0),
y1 = parseFloat(grad.getAttribute('y1') || 0.0), y1 = Number.parseFloat(grad.getAttribute('y1') || 0.0),
x2 = parseFloat(grad.getAttribute('x2') || 1.0), x2 = Number.parseFloat(grad.getAttribute('x2') || 1.0),
y2 = parseFloat(grad.getAttribute('y2') || 0.0); y2 = Number.parseFloat(grad.getAttribute('y2') || 0.0);
const cx = parseFloat(grad.getAttribute('cx') || 0.5), const cx = Number.parseFloat(grad.getAttribute('cx') || 0.5),
cy = parseFloat(grad.getAttribute('cy') || 0.5), cy = Number.parseFloat(grad.getAttribute('cy') || 0.5),
fx = parseFloat(grad.getAttribute('fx') || cx), fx = Number.parseFloat(grad.getAttribute('fx') || cx),
fy = parseFloat(grad.getAttribute('fy') || cy); fy = Number.parseFloat(grad.getAttribute('fy') || cy);
const previewRect = mkElem('rect', { const previewRect = mkElem('rect', {
id: id + '_jgraduate_rect', id: id + '_jgraduate_rect',
@@ -617,7 +617,7 @@ export default function jQueryPluginJGraduate ($) {
.val(attrval) .val(attrval)
.change(function () { .change(function () {
// TODO: Support values < 0 and > 1 (zoomable preview?) // TODO: Support values < 0 and > 1 (zoomable preview?)
if (isNaN(parseFloat(this.value)) || this.value < 0) { if (isNaN(Number.parseFloat(this.value)) || this.value < 0) {
this.value = 0.0; this.value = 0.0;
} else if (this.value > 1) { } else if (this.value > 1) {
this.value = 1.0; this.value = 1.0;
@@ -692,7 +692,7 @@ export default function jQueryPluginJGraduate ($) {
const colorhandle = this; // eslint-disable-line consistent-this const colorhandle = this; // eslint-disable-line consistent-this
let stopOpacity = Number(stop.getAttribute('stop-opacity')) || 1; let stopOpacity = Number(stop.getAttribute('stop-opacity')) || 1;
let stopColor = stop.getAttribute('stop-color') || 1; let stopColor = stop.getAttribute('stop-color') || 1;
let thisAlpha = (parseFloat(stopOpacity) * 255).toString(16); let thisAlpha = (Number.parseFloat(stopOpacity) * 255).toString(16);
while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; } while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }
colr = stopColor.substr(1) + thisAlpha; colr = stopColor.substr(1) + thisAlpha;
$('#' + id + '_jGraduate_stopPicker').css({left: 100, bottom: 15}).jPicker({ $('#' + id + '_jGraduate_stopPicker').css({left: 100, bottom: 15}).jPicker({
@@ -1052,7 +1052,7 @@ export default function jQueryPluginJGraduate ($) {
const setSlider = function (e) { const setSlider = function (e) {
const {offset: {left}} = slider; const {offset: {left}} = slider;
const div = slider.parent; const div = slider.parent;
let x = (e.pageX - left - parseInt(div.css('border-left-width'))); let x = (e.pageX - left - Number.parseInt(div.css('border-left-width')));
if (x > SLIDERW) x = SLIDERW; if (x > SLIDERW) x = SLIDERW;
if (x <= 0) x = 0; if (x <= 0) x = 0;
const posx = x - 5; const posx = x - 5;
@@ -1066,7 +1066,7 @@ export default function jQueryPluginJGraduate ($) {
curGradient.setAttribute('r', x); curGradient.setAttribute('r', x);
break; break;
case 'opacity': case 'opacity':
$this.paint.alpha = parseInt(x * 100); $this.paint.alpha = Number.parseInt(x * 100);
previewRect.setAttribute('fill-opacity', x); previewRect.setAttribute('fill-opacity', x);
break; break;
case 'ellip': case 'ellip':

View File

@@ -463,11 +463,11 @@ const jPicker = function ($) {
case alpha && alpha.get(0): case alpha && alpha.get(0):
switch (e.keyCode) { switch (e.keyCode) {
case 38: case 38:
alpha.val(setValueInRange.call(that, parseFloat(alpha.val()) + 1, 0, 100)); alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) + 1, 0, 100));
color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target); color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);
return false; return false;
case 40: case 40:
alpha.val(setValueInRange.call(that, parseFloat(alpha.val()) - 1, 0, 100)); alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) - 1, 0, 100));
color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target); color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);
return false; return false;
} }
@@ -563,7 +563,7 @@ const jPicker = function ($) {
break; break;
case ahex && ahex.get(0): case ahex && ahex.get(0):
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2)); ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
color.val('a', !isNullish(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target); color.val('a', !isNullish(ahex.val()) ? Number.parseInt(ahex.val(), 16) : null, e.target);
break; break;
} }
return undefined; return undefined;
@@ -1086,7 +1086,7 @@ const jPicker = function ($) {
* @returns {Integer} * @returns {Integer}
*/ */
hexToInt (hex) { hexToInt (hex) {
return parseInt(hex, 16); return Number.parseInt(hex, 16);
}, },
/** /**
* @typedef {PlainObject} module:jPicker.HSV * @typedef {PlainObject} module:jPicker.HSV
@@ -1120,7 +1120,7 @@ const jPicker = function ($) {
if (r === max) hsv.h = (g - b) / delta; if (r === max) hsv.h = (g - b) / delta;
else if (g === max) hsv.h = 2 + (b - r) / delta; else if (g === max) hsv.h = 2 + (b - r) / delta;
else hsv.h = 4 + (r - g) / delta; else hsv.h = 4 + (r - g) / delta;
hsv.h = parseInt(hsv.h * 60); hsv.h = Number.parseInt(hsv.h * 60);
if (hsv.h < 0) hsv.h += 360; if (hsv.h < 0) hsv.h += 360;
} }
hsv.s = (hsv.s * 100) | 0; hsv.s = (hsv.s * 100) | 0;
@@ -1251,7 +1251,7 @@ const jPicker = function ($) {
} else { } else {
settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results
} }
const isLessThanIE7 = parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters; // needed to run the AlphaImageLoader function for IE6 const isLessThanIE7 = Number.parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters; // needed to run the AlphaImageLoader function for IE6
// set color mode and update visuals for the new color mode // set color mode and update visuals for the new color mode
/** /**
* *
@@ -1802,8 +1802,8 @@ const jPicker = function ($) {
function moveBarMouseDown (e) { function moveBarMouseDown (e) {
// const {element} = settings.window, // local copies for YUI compressor // const {element} = settings.window, // local copies for YUI compressor
// {page} = settings.window; // {page} = settings.window;
elementStartX = parseInt(container.css('left')); elementStartX = Number.parseInt(container.css('left'));
elementStartY = parseInt(container.css('top')); elementStartY = Number.parseInt(container.css('top'));
pageStartX = e.pageX; pageStartX = e.pageX;
pageStartY = e.pageY; pageStartY = e.pageY;
// bind events to document to move window - we will unbind these on mouseup // bind events to document to move window - we will unbind these on mouseup
@@ -2000,7 +2000,7 @@ const jPicker = function ($) {
? (popup.offset().left - 10 + (win.position.y === 'center' ? 25 : 0)) + 'px' ? (popup.offset().left - 10 + (win.position.y === 'center' ? 25 : 0)) + 'px'
: win.position.x === 'screenCenter' : win.position.x === 'screenCenter'
? (($(document).width() >> 1) - 260) + 'px' ? (($(document).width() >> 1) - 260) + 'px'
: (popup.offset().left + parseInt(win.position.x)) + 'px', : (popup.offset().left + Number.parseInt(win.position.x)) + 'px',
position: 'absolute', position: 'absolute',
top: win.position.y === 'top' top: win.position.y === 'top'
? (popup.offset().top - 312) + 'px' ? (popup.offset().top - 312) + 'px'
@@ -2008,7 +2008,7 @@ const jPicker = function ($) {
? (popup.offset().top - 156) + 'px' ? (popup.offset().top - 156) + 'px'
: win.position.y === 'bottom' : win.position.y === 'bottom'
? (popup.offset().top + 25) + 'px' ? (popup.offset().top + 25) + 'px'
: (popup.offset().top + parseInt(win.position.y)) + 'px' : (popup.offset().top + Number.parseInt(win.position.y)) + 'px'
} }
); );
} else { } else {

View File

@@ -263,7 +263,7 @@ const svgElementToPdf = function (element, pdf, options) {
pdf.setFillColor(fillRGB.r, fillRGB.g, fillRGB.b); pdf.setFillColor(fillRGB.r, fillRGB.g, fillRGB.b);
} }
if (attributeIsNotEmpty(node, 'stroke-width')) { if (attributeIsNotEmpty(node, 'stroke-width')) {
pdf.setLineWidth(k * parseInt(node.getAttribute('stroke-width'))); pdf.setLineWidth(k * Number.parseInt(node.getAttribute('stroke-width')));
} }
const strokeColor = node.getAttribute('stroke'); const strokeColor = node.getAttribute('stroke');
if (attributeIsNotEmpty(strokeColor) && node.getAttribute('stroke-width') !== '0' && node.getAttribute('stroke-opacity') !== '0') { if (attributeIsNotEmpty(strokeColor) && node.getAttribute('stroke-width') !== '0' && node.getAttribute('stroke-opacity') !== '0') {
@@ -291,38 +291,38 @@ const svgElementToPdf = function (element, pdf, options) {
break; break;
case 'line': case 'line':
pdf.line( pdf.line(
k * parseInt(node.getAttribute('x1')), k * Number.parseInt(node.getAttribute('x1')),
k * parseInt(node.getAttribute('y1')), k * Number.parseInt(node.getAttribute('y1')),
k * parseInt(node.getAttribute('x2')), k * Number.parseInt(node.getAttribute('x2')),
k * parseInt(node.getAttribute('y2')) k * Number.parseInt(node.getAttribute('y2'))
); );
removeAttributes(node, pdfSvgAttr.line); removeAttributes(node, pdfSvgAttr.line);
break; break;
case 'rect': case 'rect':
pdf.rect( pdf.rect(
k * parseInt(node.getAttribute('x')), k * Number.parseInt(node.getAttribute('x')),
k * parseInt(node.getAttribute('y')), k * Number.parseInt(node.getAttribute('y')),
k * parseInt(node.getAttribute('width')), k * Number.parseInt(node.getAttribute('width')),
k * parseInt(node.getAttribute('height')), k * Number.parseInt(node.getAttribute('height')),
colorMode colorMode
); );
removeAttributes(node, pdfSvgAttr.rect); removeAttributes(node, pdfSvgAttr.rect);
break; break;
case 'ellipse': case 'ellipse':
pdf.ellipse( pdf.ellipse(
k * parseInt(node.getAttribute('cx')), k * Number.parseInt(node.getAttribute('cx')),
k * parseInt(node.getAttribute('cy')), k * Number.parseInt(node.getAttribute('cy')),
k * parseInt(node.getAttribute('rx')), k * Number.parseInt(node.getAttribute('rx')),
k * parseInt(node.getAttribute('ry')), k * Number.parseInt(node.getAttribute('ry')),
colorMode colorMode
); );
removeAttributes(node, pdfSvgAttr.ellipse); removeAttributes(node, pdfSvgAttr.ellipse);
break; break;
case 'circle': case 'circle':
pdf.circle( pdf.circle(
k * parseInt(node.getAttribute('cx')), k * Number.parseInt(node.getAttribute('cx')),
k * parseInt(node.getAttribute('cy')), k * Number.parseInt(node.getAttribute('cy')),
k * parseInt(node.getAttribute('r')), k * Number.parseInt(node.getAttribute('r')),
colorMode colorMode
); );
removeAttributes(node, pdfSvgAttr.circle); removeAttributes(node, pdfSvgAttr.circle);
@@ -405,7 +405,7 @@ const svgElementToPdf = function (element, pdf, options) {
} }
pdf.setFontType(fontType); pdf.setFontType(fontType);
const pdfFontSize = node.hasAttribute('font-size') const pdfFontSize = node.hasAttribute('font-size')
? parseInt(node.getAttribute('font-size')) ? Number.parseInt(node.getAttribute('font-size'))
: 16; : 16;
/** /**
@@ -441,8 +441,8 @@ const svgElementToPdf = function (element, pdf, options) {
case 'start': break; case 'start': break;
case 'default': node.setAttribute('text-anchor', 'start'); break; case 'default': node.setAttribute('text-anchor', 'start'); break;
} }
x = parseInt(node.getAttribute('x')) - xOffset; x = Number.parseInt(node.getAttribute('x')) - xOffset;
y = parseInt(node.getAttribute('y')); y = Number.parseInt(node.getAttribute('y'));
} }
// console.log('fontSize:', pdfFontSize, 'text:', node.textContent); // console.log('fontSize:', pdfFontSize, 'text:', node.textContent);
pdf.setFontSize(pdfFontSize).text( pdf.setFontSize(pdfFontSize).text(

View File

@@ -120,7 +120,7 @@ class Layer {
if (isNullish(opacity)) { if (isNullish(opacity)) {
return 1; return 1;
} }
return parseFloat(opacity); return Number.parseFloat(opacity);
} }
/** /**

View File

@@ -158,8 +158,8 @@ export const transformListToTransform = function (tlist, min, max) {
} }
min = min || 0; min = min || 0;
max = max || (tlist.numberOfItems - 1); max = max || (tlist.numberOfItems - 1);
min = parseInt(min); min = Number.parseInt(min);
max = parseInt(max); max = Number.parseInt(max);
if (min > max) { const temp = max; max = min; min = temp; } if (min > max) { const temp = max; max = min; min = temp; }
let m = svg.createSVGMatrix(); let m = svg.createSVGMatrix();
for (let i = min; i <= max; ++i) { for (let i = min; i <= max; ++i) {

View File

@@ -2003,7 +2003,7 @@ export const pathActions = (function () {
let curPt; let curPt;
if (id.substr(0, 14) === 'pathpointgrip_') { if (id.substr(0, 14) === 'pathpointgrip_') {
// Select this point // Select this point
curPt = path.cur_pt = parseInt(id.substr(14)); curPt = path.cur_pt = Number.parseInt(id.substr(14));
path.dragging = [startX, startY]; path.dragging = [startX, startY];
const seg = path.segs[curPt]; const seg = path.segs[curPt];

View File

@@ -146,8 +146,8 @@ export default function jQueryPluginSpinButton ($) {
this.spinCfg = { this.spinCfg = {
// min: cfg.min ? Number(cfg.min) : null, // min: cfg.min ? Number(cfg.min) : null,
// max: cfg.max ? Number(cfg.max) : null, // max: cfg.max ? Number(cfg.max) : null,
min: !isNaN(parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0 min: !isNaN(Number.parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0
max: !isNaN(parseFloat(cfg.max)) ? Number(cfg.max) : null, max: !isNaN(Number.parseFloat(cfg.max)) ? Number(cfg.max) : null,
step: cfg.step ? Number(cfg.step) : 1, step: cfg.step ? Number(cfg.step) : 1,
stepfunc: cfg.stepfunc || false, stepfunc: cfg.stepfunc || false,
page: cfg.page ? Number(cfg.page) : 10, page: cfg.page ? Number(cfg.page) : 10,

View File

@@ -969,7 +969,7 @@ editor.init = function () {
const s = sides[i]; const s = sides[i];
let cur = el.data('orig_margin-' + s); let cur = el.data('orig_margin-' + s);
if (Utils.isNullish(cur)) { if (Utils.isNullish(cur)) {
cur = parseInt(el.css('margin-' + s)); cur = Number.parseInt(el.css('margin-' + s));
// Cache the original margin // Cache the original margin
el.data('orig_margin-' + s, cur); el.data('orig_margin-' + s, cur);
} }
@@ -1986,7 +1986,7 @@ editor.init = function () {
// Create multiple canvases when necessary (due to browser limits) // Create multiple canvases when necessary (due to browser limits)
if (rulerLen >= limit) { if (rulerLen >= limit) {
ctxArrNum = parseInt(rulerLen / limit) + 1; ctxArrNum = Number.parseInt(rulerLen / limit) + 1;
ctxArr = []; ctxArr = [];
ctxArr[0] = ctx; ctxArr[0] = ctx;
let copy; let copy;
@@ -2903,7 +2903,7 @@ editor.init = function () {
options = tool; options = tool;
} else { } else {
// If flyout is selected, allow shift key to iterate through subitems // If flyout is selected, allow shift key to iterate through subitems
j = parseInt(j); j = Number.parseInt(j);
// Use `allHolders` to include both extension `includeWith` and toolbarButtons // Use `allHolders` to include both extension `includeWith` and toolbarButtons
options = allHolders[opts.parent][j + 1] || options = allHolders[opts.parent][j + 1] ||
holders[opts.parent][0]; holders[opts.parent][0];
@@ -3639,7 +3639,7 @@ editor.init = function () {
*/ */
const changeRotationAngle = function (ctl) { const changeRotationAngle = function (ctl) {
svgCanvas.setRotationAngle(ctl.value); svgCanvas.setRotationAngle(ctl.value);
$('#tool_reorient').toggleClass('disabled', parseInt(ctl.value) === 0); $('#tool_reorient').toggleClass('disabled', Number.parseInt(ctl.value) === 0);
}; };
/** /**
@@ -4019,7 +4019,7 @@ editor.init = function () {
editor.addDropDown('#opacity_dropdown', function () { editor.addDropDown('#opacity_dropdown', function () {
if ($(this).find('div').length) { return; } if ($(this).find('div').length) { return; }
const perc = parseInt($(this).text().split('%')[0]); const perc = Number.parseInt($(this).text().split('%')[0]);
changeOpacity(false, perc); changeOpacity(false, perc);
}, true); }, true);
@@ -4063,7 +4063,7 @@ editor.init = function () {
if (val) { if (val) {
zoomChanged(window, val); zoomChanged(window, val);
} else { } else {
changeZoom({value: parseFloat(item.text())}); changeZoom({value: Number.parseFloat(item.text())});
} }
}, true); }, true);
@@ -4462,7 +4462,7 @@ editor.init = function () {
const rotateSelected = function (cw, step) { const rotateSelected = function (cw, step) {
if (Utils.isNullish(selectedElement) || multiselected) { return; } if (Utils.isNullish(selectedElement) || multiselected) { return; }
if (!cw) { step *= -1; } if (!cw) { step *= -1; }
const angle = parseFloat($('#angle').val()) + step; const angle = Number.parseFloat($('#angle').val()) + step;
svgCanvas.setRotationAngle(angle); svgCanvas.setRotationAngle(angle);
updateContextPanel(); updateContextPanel();
}; };
@@ -4592,7 +4592,7 @@ editor.init = function () {
if (!customExportImage) { if (!customExportImage) {
openExportWindow(); openExportWindow();
} }
const quality = parseInt($('#image-slider').val()) / 100; const quality = Number.parseInt($('#image-slider').val()) / 100;
/* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName); /* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);
} }
}; };
@@ -5184,7 +5184,7 @@ editor.init = function () {
this._paintOpacity = 1; this._paintOpacity = 1;
break; break;
} default: { } default: {
this._paintOpacity = parseFloat(selectedElement.getAttribute(type + '-opacity')); this._paintOpacity = Number.parseFloat(selectedElement.getAttribute(type + '-opacity'));
if (isNaN(this._paintOpacity)) { if (isNaN(this._paintOpacity)) {
this._paintOpacity = 1.0; this._paintOpacity = 1.0;
} }
@@ -5432,8 +5432,8 @@ editor.init = function () {
const rulerX = $('#ruler_x'); const rulerX = $('#ruler_x');
$('#sidepanels').width('+=' + delta); $('#sidepanels').width('+=' + delta);
$('#layerpanel').width('+=' + delta); $('#layerpanel').width('+=' + delta);
rulerX.css('right', parseInt(rulerX.css('right')) + delta); rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);
workarea.css('right', parseInt(workarea.css('right')) + delta); workarea.css('right', Number.parseInt(workarea.css('right')) + delta);
svgCanvas.runExtensions('workareaResized'); svgCanvas.runExtensions('workareaResized');
}; };

View File

@@ -572,7 +572,7 @@ const getCurrentZoom = this.getZoom = function () { return currentZoom; };
* @type {module:path.EditorContext#round} * @type {module:path.EditorContext#round}
*/ */
const round = this.round = function (val) { const round = this.round = function (val) {
return parseInt(val * currentZoom) / currentZoom; return Number.parseInt(val * currentZoom) / currentZoom;
}; };
selectInit( selectInit(
@@ -1231,8 +1231,8 @@ const getIntersectionList = this.getIntersectionList = function (rect) {
if (!isIE()) { if (!isIE()) {
if (typeof svgroot.getIntersectionList === 'function') { if (typeof svgroot.getIntersectionList === 'function') {
// Offset the bbox of the rubber box by the offset of the svgcontent element. // Offset the bbox of the rubber box by the offset of the svgcontent element.
rubberBBox.x += parseInt(svgcontent.getAttribute('x')); rubberBBox.x += Number.parseInt(svgcontent.getAttribute('x'));
rubberBBox.y += parseInt(svgcontent.getAttribute('y')); rubberBBox.y += Number.parseInt(svgcontent.getAttribute('y'));
resultList = svgroot.getIntersectionList(rubberBBox, parent); resultList = svgroot.getIntersectionList(rubberBBox, parent);
} }
@@ -1498,7 +1498,7 @@ const ffClone = function (elem) {
*/ */
this.setRotationAngle = function (val, preventUndo) { this.setRotationAngle = function (val, preventUndo) {
// ensure val is the proper type // ensure val is the proper type
val = parseFloat(val); val = Number.parseFloat(val);
const elem = selectedElements[0]; const elem = selectedElements[0];
const oldTransform = elem.getAttribute('transform'); const oldTransform = elem.getAttribute('transform');
const bbox = utilsGetBBox(elem); const bbox = utilsGetBBox(elem);
@@ -2849,7 +2849,7 @@ const mouseUp = function (evt) {
let aniDur = 0.2; let aniDur = 0.2;
let cAni; let cAni;
if (opacAni.beginElement && parseFloat(element.getAttribute('opacity')) !== curShape.opacity) { if (opacAni.beginElement && Number.parseFloat(element.getAttribute('opacity')) !== curShape.opacity) {
cAni = $(opacAni).clone().attr({ cAni = $(opacAni).clone().attr({
to: curShape.opacity, to: curShape.opacity,
dur: aniDur dur: aniDur

View File

@@ -172,7 +172,7 @@ export class SVGTransformList { // eslint-disable-line no-shadow
*/ */
const mtx = svgroot.createSVGMatrix(); const mtx = svgroot.createSVGMatrix();
Object.values(valArr).forEach(function (item, i) { Object.values(valArr).forEach(function (item, i) {
valArr[i] = parseFloat(item); valArr[i] = Number.parseFloat(item);
if (name === 'matrix') { if (name === 'matrix') {
mtx[letters[i]] = valArr[i]; mtx[letters[i]] = valArr[i];
} }

View File

@@ -140,7 +140,7 @@ export const shortFloat = function (val) {
if (Array.isArray(val)) { if (Array.isArray(val)) {
return shortFloat(val[0]) + ',' + shortFloat(val[1]); return shortFloat(val[0]) + ',' + shortFloat(val[1]);
} }
return parseFloat(val).toFixed(digits) - 0; return Number.parseFloat(val).toFixed(digits) - 0;
}; };
/** /**

View File

@@ -661,8 +661,8 @@ export const getBBox = function (elem) {
const bb = { const bb = {
width, width,
height, height,
x: x + parseFloat(selected.getAttribute('x') || 0), x: x + Number.parseFloat(selected.getAttribute('x') || 0),
y: y + parseFloat(selected.getAttribute('y') || 0) y: y + Number.parseFloat(selected.getAttribute('y') || 0)
}; };
ret = bb; ret = bb;
} }

View File

@@ -33,12 +33,12 @@ const query = function (qry, root) {
}; };
const ua = navigator.userAgent; const ua = navigator.userAgent;
const isFF = parseFloat(ua.split('Firefox/')[1]) || undefined; const isFF = Number.parseFloat(ua.split('Firefox/')[1]) || undefined;
const isWK = parseFloat(ua.split('WebKit/')[1]) || undefined; const isWK = Number.parseFloat(ua.split('WebKit/')[1]) || undefined;
const isOpera = parseFloat(ua.split('Opera/')[1]) || undefined; const isOpera = Number.parseFloat(ua.split('Opera/')[1]) || undefined;
const canTransition = (function () { const canTransition = (function () {
const ver = parseFloat(ua.split('Version/')[1]) || undefined; const ver = Number.parseFloat(ua.split('Version/')[1]) || undefined;
// test to determine if this browser can handle CSS transitions. // test to determine if this browser can handle CSS transitions.
const cachedCanTransition = const cachedCanTransition =
(isWK || (isFF && isFF > 3.6) || (isOpera && ver >= 10.5)); (isWK || (isFF && isFF > 3.6) || (isOpera && ver >= 10.5));
@@ -158,9 +158,9 @@ const SlideShow = function (slides) {
const h = window.location.hash; const h = window.location.hash;
try { try {
this.current = parseInt(h.split('#slide')[1]); this.current = Number.parseInt(h.split('#slide')[1]);
} catch (e) { /* squeltch */ } } catch (e) { /* squelch */ }
this.current = isNaN(this.current) ? 1 : this.current; this.current = Number.isNaN(this.current) ? 1 : this.current;
const that = this; const that = this;
doc.addEventListener('keydown', doc.addEventListener('keydown',
function (e) { that.handleKeys(e); }); function (e) { that.handleKeys(e); });