use
String(event.clientY - this.__contextMenu.clientHeight + 20)
instead103 this.__contextMenu.style.left = "" + (event.clientX + 30) + "px";
104 }
105 if (event.clientY - 20 + this.__contextMenu.clientHeight > window.innerHeight) {
106 this.__contextMenu.style.top = "" + (event.clientY - this.__contextMenu.clientHeight + 20) + "px";107 }
108 else {
109 this.__contextMenu.style.top = "" + (event.clientY - 20) + "px";
use
String(event.clientY - 20)
instead106 this.__contextMenu.style.top = "" + (event.clientY - this.__contextMenu.clientHeight + 20) + "px";
107 }
108 else {
109 this.__contextMenu.style.top = "" + (event.clientY - 20) + "px";110 }
111
112 //Delete any table in the context menu
use
String(event.clientX + 30)
instead100 this.__contextMenu.style.left = "" + (event.clientX - this.__contextMenu.clientWidth - 30) + "px";
101 }
102 else {
103 this.__contextMenu.style.left = "" + (event.clientX + 30) + "px";104 }
105 if (event.clientY - 20 + this.__contextMenu.clientHeight > window.innerHeight) {
106 this.__contextMenu.style.top = "" + (event.clientY - this.__contextMenu.clientHeight + 20) + "px";
use
String(event.clientX - this.__contextMenu.clientWidth - 30)
instead 97 console.log("HEIGHT: "+this.__contextMenu.clientHeight);
98
99 if (event.clientX + 30 + this.__contextMenu.clientWidth > window.innerWidth) {
100 this.__contextMenu.style.left = "" + (event.clientX - this.__contextMenu.clientWidth - 30) + "px";101 }
102 else {
103 this.__contextMenu.style.left = "" + (event.clientX + 30) + "px";
use
String(event.clientX + 30)
instead355 table.style.opacity = 0.7;
356 }
357 table.style.position = "absolute";
358 table.style.left = "" + (event.clientX + 30) + "px";359 table.style.top = "" + (event.clientY - 20) + "px";
360 HTMLUtils.removeClass(table, "hidden-block");
361 HTMLUtils.addClass(table, "shown-block");
use
String(event.clientY - 20)
instead356 }
357 table.style.position = "absolute";
358 table.style.left = "" + (event.clientX + 30) + "px";
359 table.style.top = "" + (event.clientY - 20) + "px";360 HTMLUtils.removeClass(table, "hidden-block");
361 HTMLUtils.addClass(table, "shown-block");
362 document.body.appendChild(table);
use
Boolean(window.CanvasRenderingContext2D)
instead 4 */
5
6export const Detector = {
7 canvas: !!window.CanvasRenderingContext2D, 8 webgl: (function() {
9 try {
10 var canvas = document.createElement("canvas");
use
Boolean(window.Worker)
instead13 return false;
14 }
15 })(),
16 workers: !!window.Worker,17 fileapi: window.File && window.FileReader && window.FileList && window.Blob,
18
19 getWebGLErrorMessage: function() {
use
Boolean(window.WebGLRenderingContext && (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")))
instead 8 webgl: (function() {
9 try {
10 var canvas = document.createElement("canvas");
11 return !!(window.WebGLRenderingContext && (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")));12 } catch (e) {
13 return false;
14 }
use
Number(n)
instead 1export function isFloat(n) {
2 return n === +n && n !== (n | 0); 3}
4
5export function isInteger(n) {
use
Number(n)
instead 3}
4
5export function isInteger(n) {
6 return n === +n && n === (n | 0); 7}
8
9export function isFloatOrInt(n) {
Description
Prefer using explicit casts by calling Number
, Boolean
, or String
over using operators like +
, !!
or "" +
.
This is considered best practice as it improves readability.
Bad Practice
const b = !!foo;
// The `+` operator does not change the value of its operand
// unless it's already a number.
let n = +foo;
n = 1 * foo;
const s = "" + foo;
Recommended
const b = Boolean(foo);
const n = Number(foo);
const s = String(foo);