New answers tagged

2

Overall the code looks fine. I just have a couple suggestions about the JavaScript and CSS. JS querySelectorAll vs getElementsByClassName Generally document.getElementsByClassName will be quicker than document.querySelectorAll (see this post for more information) and the former also returns a live HTMLCollection so it wouldn't need to be queried each time....


3

Besides small points like the use of &nbsp; to indent, <code> unsemantically, everything looks well organized with a lot of effort in styling. And that leads me to the main point: It would be better to separate text content and styling. And that would mean an XML format with a custom XML-to-HTML XSL transformation. There are some XML formats ...


0

Instead of adding the event listener to the document element you could add it to every element that has a class of dropdown-trigger. Then you could make use of javascripts classList toggle function. That way you don't need the if else statement in handleDropdownClicks. Example: const dropdownTriggers = document.querySelectorAll(".dropdown-trigger") ...


1

Some ideas to improvement. If I need List of Str I prefer comb to match. my @initial = $initial_color.comb(/<xdigit> ** 2/)».parse-base(16); #or my @final = $final_color.substr(1).comb(2)».parse-base(16); You can use the sequence operator ... to make sequence of colors. my @color = @initial, { @^p Z+ @increment } ... * ~~ @final; Method ...


5

I'm going to limit my initial answer to not include modules, but I'll also cover a module that can help out some here too later. my $initial_color = '#FF0000'; my $final_color = '#00FF00'; While there's nothing wrong with using underscores, the tendency in Perl 6 has been to move towards hyphens, which would give us $initial-color and $final-color. my ...


1

You're closing tags only when a row or table is full. Is data always going to fit the table size? if (i % labelsPerRow == (labelsPerRow - 1)) { @Html.Raw("</tr>") } if (i % labelsPerPage == (labelsPerPage - 1)) { @Html.Raw("</table>") } You could make a functional helper and use that instead. Notice that after the loop, the row and ...


2

There's really not much you can improve. My follow up question would be where and how did you decide on your breakpoints? I suggest using a bit more standardized sizes; the ones I pasted below are directly from the Bootstrap 4 Template https://getbootstrap.com/docs/4.3/layout/overview/ You do not need all 4 sizes, but these are a bit more standard (even ...


4

I would make the following recommendations to clean it up for future maintainability and readability: Clean up and remove the anonymous functions. They aren't really needed here and just create extra clutter, decreasing readability. Remove the additional setTimeout call and just call to show when you're done loading. Use more meaningful names. It was ...


2

It looks ok to me. What you could improve is the order of your CSS statements. For example This: header { /* background-color: var(--focus-alt); */ background: linear-gradient(45deg, #4394d6, #43c5d6); padding: 2rem 1rem 1rem 1rem; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.05); margin-bottom: 0.5rem; color: #fff; } Would look a ...


1

Define your variables at the top of your script outside of the setTimeout. That way, you only need to define every variable once. Also, you can make them const, since they won't change. The same goes for the run() function. Declare it outside of the setTimeout. You just want to call it inside the setTimeout. I hope this is helpful for you. const wrp = ...


1

To add onto KIKO's answer, you are on the right track. Ultimately there is quite a bit you can change and there's a ton I would fix myself. But I'm not going to re-write the whole thing for you. Hopefully these pointers will help you move in the right direction. First things first lets answer your question: Your Question How do you put the message ...


2

I hate to break it to you, but no this is not very secure. While you are using some techniques to help secure it, there are still a few flaws with how you are managing the input and SQL checks. mySQL vs. mySQLi USE MYSQLI... you need the "i", mySQL is old and deprecated and should not be used if you are using a new enough version of PHP. 7+ Supports the ...


3

Are there any security concerns with the current approach? No. You never interact with a server or a database. There is no way you could have any security concerns. Focusing on the use of innerHTML here as I believe it could be potentially dangerous. Should I be creating elements instead of using text based HTML insertion? No it does not matter. ...


1

Whenever possible put the styling in the CSS. Avoid doing it in the JavaScript like this. For example, you could add it to your .dice style. (Note: same goes for other parts of your code) diceDOM.style.display = 'block'; Use shorthand +=. (Note: same goes for other parts of your code) roundScore =roundScore + dice + diceTwo; 'array' is a bad name for a ...


3

The main part of code I would focus on is this part with high branch complexity: if (e.keyCode == 38) { if(i >= slidesCount) { i = 0; } else( i++ ) } else if (e.keyCode == 40) { if(i <= 0) { i = slidesCount; } else ( i-- ) } When you realise a carousel has circular navigation, you could take ...


2

You probably are familiar with <input type="date"> but maybe you aren't satisfied by the browser compatibility or wanted to try your hand at reinventing-the-wheel. Instead of creating numerous HTML elements with the Javascript Logic, have you considered using a <template> with <slot> tags and replacing values as needed. Also, I see many ...


3

width="1068px" height="132px" The width and height attributes can’t contain "px". width="1068" height="132" The alt value for the logo should not contain "logo", just the company name. <i class="fab fa-facebook-f"></i> Don’t use the i element if you just want to display an icon via CSS. The i element has a meaning which isn’t appropriate for ...


3

Evaluation For somebody learning Javascript this code isn't bad, however it does have some inefficiencies and practices that are frowned upon (e.g. Global variables). See the suggestions below for advice about improving it. Suggestions Semicolon terminators Unless you are intimately familiar with the statements that need to be terminated by a semicolon ...


1

I wouldn't use strings at all. I would write to a stream. If wished, I would convert the stream to a string. (defun d20 () (+ 1 (random 19))) initlist can be written more compact: (defun initlist (specs) (sort (loop for (a b) in specs collect (list a (+ b (d20)))) #'> :key #'second)) Now we pass a stream to htmlinitlist and write the ...


2

You can replace the for loop with cardinalOut = cardinal[Math.floor((value / degrees) + 0.5)].


Top 50 recent answers are included