Total Complexity | 12 |
Complexity/F | 1.33 |
Lines of Code | 39 |
Function Count | 9 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | export var isShiftPressed = false; |
||
2 | export var isCtrlPressed = false; |
||
3 | |||
4 | export function isHtmlElement(object) { |
||
5 | return object instanceof HTMLElement; |
||
|
|||
6 | } |
||
7 | |||
8 | export function initHelpers() { |
||
9 | document.addEventListener('keydown', event => handleKeyDown(event)); |
||
10 | document.addEventListener('keyup', event => handleKeyUp(event)); |
||
11 | } |
||
12 | |||
13 | export function onReady(fn) { |
||
14 | if (document.readyState != 'loading') { |
||
15 | fn(); |
||
16 | } else { |
||
17 | document.addEventListener('DOMContentLoaded', fn); |
||
18 | } |
||
19 | } |
||
20 | |||
21 | export function assigned(obj) { |
||
22 | return !(typeof obj === 'undefined' || obj === null); |
||
23 | } |
||
24 | |||
25 | function handleKeyDown(event) { |
||
26 | handleKeyToggle(event, true); |
||
27 | } |
||
28 | |||
29 | function handleKeyUp(event) { |
||
30 | handleKeyToggle(event, false); |
||
31 | } |
||
32 | |||
33 | function handleKeyToggle(event, isPressed) { |
||
34 | if (event.key === 'Shift') { |
||
35 | isShiftPressed = isPressed; |
||
36 | } else if (event.key === 'Control') { |
||
37 | isCtrlPressed = isPressed; |
||
38 | } |
||
39 | } |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.