New answers tagged

3

Your code is not too bad for one claiming to be a react newbie. I see only a few minor things I'd suggest cleaning or tightening up. Don't Repeat Yourself (DRY Principle) with regards to object property accesses Consistent use of === Using object destructing and object shorthand property definitions, and directly return the map result. const list = (...


6

UI First thing to look at would probably the ease of use of the webpage itself. You could start by using typed input controls, like time, ie: <input type="time" step="00:30" value="10:00" id="startTime" /> Those would still render as text inputs for any browser that might not be able to render it, but it would ...


4

I'm glad to see you incorporated much of the feedback from the answers to your previous post. I see you added the colors into CSS, but dynamically. I believe those styles for the colors could exist with the static CSS. Actually the whole addStyles() function could likely be eliminated using conditional classes (e.g. if checkbox1 is checked, then add an extra ...


2

The biggest problem in your code is keyCode. From MDN: Deprecated This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; ...


4

Mast mentioned that it is not possible to have html-tags in for example comments, without destroying the formatting. I've solved this problem by replacing & and <: text = text.replace(new RegExp("&", "g"), "&amp;"); text = text.replace(new RegExp("<", "g"), "&lt;"); You can ...


8

Interpreting any source code language entirely by regular expression — which is to say, without actually parsing the code and building an understanding of it on a syntactic level — is notoriously difficult to do. Your regular expressions do fall prey to some of the common issues with regexp-as-parser, since it will mis-highlight all of the following: public ...


1

I will focus on the CSS file. Keep the CSS file organized, whether it be class first, then ID, then element tags (p, a, nav etc), alphabetical or some other logical organization. One of the lines you have is background-color: darkorange;. Without the quotes, it looks odd to me (although allowed by the specification). Also, why is this the one of the few that ...


3

Your current approach of highlighting one token type after another will fail for more complicated examples. Imagine this: String s = "public data, private secrets"; The words in the string are not keywords. To fix this, you need to change your code to tokenize the input text in a single pass, like this pseudo code: function tokenize(text) { ...


11

For a beginner this looks like a great start! Below are some suggestions to clean things up and make things more consistent. It is a common convention for HTML to not contain spaces between attribute keys and values. So instead of <script language = "javascript" type = "text/javascript" src = "highlightSyntax.js"></...


13

There's a glaring problem with this: no user input validation. A basic test revealed this: Ah, but that's not Java you say? True, but what if some poor sod has a stray HTML tag in their docstring? All HTML that's already in the user input should probably be made harmless. Either escape it, wrap it in a container that will treat it as a string instead of ...


0

While Drew and Peter provide some useful techniques when dealing with complex components, this case cries out for the simplest solution possible. render () { if (showContainer) { return ( <Modal> <h3>Random Child JSX</h3> </Modal> ); } else { return ( &...


1

From a short review; There is no point in creating those functions as async, if anything it gives the reader the mistaken impression that anything async may happen in those functions (let columnIndex = 0; column = row.cells[columnIndex]; columnIndex++) creates a global variable column which is bad practice addTableCellClassInjector is so specific that it ...


0

Your Node side could be simplified by sending over the readings JSON as a singular list of objects. // assuming readings looks like this [ { 'fridge':'old sketchy fridge', 'temperature':-3, 'comment':'yup, still works' }, { 'fridge':'new fancy fridge', 'temperature':-4, 'comment':'this one better ...


3

Program looks well structured, so this is gonna be nitpicky function isDiagonalWinner(id) { posGradient = true; Since posGradient hasn't been declared anywhere, this will be treated as a global on window['posGradient']. let would suit you nicely here. var matches = document.querySelectorAll("#board .row .elem .clickable"); The value of ...


1

Somewhere in your code you should be setting the template engine and the base views path, in the likes of app.set('views', __dirname+'/views/'); app.set('view engine', 'hbs'); (I assume you have that figured out already) Having said that, you can either reference a view by its location relative to the views setting, therefore: res.render('Leagues/...


-1

To add to "Your Common Sense" answer: I would suggest that the next step would be to separate your HTML and PHP code. i.e. moving out the logic for account closure into its own class since you might want to use that logic elsewhere. (DRY Principle) It's best to let JS/HTML handle redirects too since that is something related to the front end ...


3

The code is overall good basic PHP and above the average. However, I would like it more structured. For example, why you are setting the error reporting manually in this file? Apparently you have sort of a bootstrap file as includes/header.php, why not to put these lines there? Besides, i don't see any point in the line assigning $post_id variable. What does ...


Top 50 recent answers are included