gothick /
omm
| 1 | /* |
||
| 2 | * Welcome to your app's main JavaScript file! |
||
| 3 | * |
||
| 4 | * We recommend including the built version of this JavaScript file |
||
| 5 | * (and its CSS file) in your base layout (base.html.twig). |
||
| 6 | */ |
||
| 7 | |||
| 8 | // any CSS you import will output into a single css file (app.css in this case) |
||
| 9 | import './styles/app.scss'; |
||
| 10 | |||
| 11 | import "./fontawesome"; |
||
| 12 | |||
| 13 | import "@fontsource/archivo"; |
||
| 14 | |||
| 15 | // start the Stimulus application |
||
| 16 | import './bootstrap'; |
||
| 17 | |||
| 18 | const $ = require('jquery'); |
||
| 19 | require('bootstrap'); |
||
| 20 | |||
| 21 | $(function() { |
||
| 22 | if ($('#navigatePrev').length || $('#navigateNext').length) |
||
| 23 | window.addEventListener("keydown", function (event) { |
||
|
0 ignored issues
–
show
|
|||
| 24 | if (event.defaultPrevented) { |
||
| 25 | return; // Do nothing if the event was already processed |
||
| 26 | } |
||
| 27 | var url; |
||
| 28 | switch (event.key) { |
||
| 29 | case "Left": // IE/Edge specific value |
||
| 30 | case "ArrowLeft": |
||
| 31 | url = $("#navigatePrev").attr('href'); |
||
| 32 | break; |
||
| 33 | case "Right": // IE/Edge specific value |
||
| 34 | case "ArrowRight": |
||
| 35 | url = $("#navigateNext").attr('href'); |
||
| 36 | break; |
||
| 37 | default: |
||
| 38 | return; // Quit when this doesn't handle the key event. |
||
| 39 | } |
||
| 40 | if (url) { |
||
| 41 | window.location.href = url; |
||
| 42 | } |
||
| 43 | // Cancel the default action to avoid it being handled twice |
||
| 44 | event.preventDefault(); |
||
| 45 | }, true); |
||
| 46 | }); |
||
| 47 |
Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.
Consider:
If you or someone else later decides to put another statement in, only the first statement will be executed.
In this case the statement
b = 42will always be executed, while the logging statement will be executed conditionally.ensures that the proper code will be executed conditionally no matter how many statements are added or removed.