HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavascriptMinor

Cleaning up a dining hall...website

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
hallwebsitecleaningdining

Problem

I am making a website that takes a bunch of dining hall information and puts it all together in a neater (and hopefully more mobile friendly) form.

Here is the link:
https://googledrive.com/host/0By7Z_HHj2VhnWmlhbWl4aF8xdFU/nuEats.html

It's a little incomplete at the moment, but what it does is the bar up top shows you how much a "meal" is worth at a university convenience store (there is an arrow that is usually there, but it is current gone because it is 2:21 AM, which is after closing time).

Also, there are links to dining halls and their menus. My first question is: I don't know a lot about HTML and CSS best practices.

I have tried to keep everything nice and neat, but I was wondering if someone could just browse through my code and see

  • Is the code efficient



  • Is the code clear and concise?



The second point is especially important to me because I don't want anything to be ambiguous or hard to understand in my code, since I inevitably will have to pass it down.

HTML

```






nuEats

















nuEats











Equivalency Meal Exchange Rate:












1835 Hinman

Menu














Allison

Menu

Solution

From a once over,

DRY (Dont' Repeat Yourself)

-
You have a number of these blocks that seem all copy pasted:


    
        
             Sargent
            
                Menu
            
        
    


You could consider having a JavaScript array holding just the restaurant names and links and then building the HTML with templating. Furthermore I am not sure why you need an h4 in a div in a div, you should be able to style the top div in such a manner that the HTML would look like


    
        Sargent
        
            Menu
        
    


Style

  • Don't skip the newlines in returnDay and returnMonth



-
formatTime could use a ternary, return (i

-
createEqRateBars is mixing logic/calculation and creation of UI elements, you should split that out in 2 functions. It looks messy and too tightly coupled now.

Functionality

  • It seems like your code in formatDate will return 11st and 13rd, that seems wrong



All in all

Time/date handling is a pain in any language, and I think you pulled it off pretty well. I probably would have encapsulated
EqRates` into an object with helper functions to make the code a little more readable, but other than that I would not maintaining code like this.

Code Snippets

<!-- Sargent -->
<div class="panel panel-default">
    <div class="panel-heading">
        <h4 class="panel-title">
             Sargent
            <a href="https://m-nucuisine.sodexomyway.com/images/Sargent3_tcm238-12910.htm">
                <div class="menu">Menu</div>
            </a>
        </h4>
    </div>
</div>
<!-- Sargent -->
    <div class="panel panel-default awesomerestaurantclass">
        Sargent
        <a href="https://m-nucuisine.sodexomyway.com/images/Sargent3_tcm238-12910.htm">
            <div class="menu">Menu</div>
        </a>
    </div>

Context

StackExchange Code Review Q#45067, answer score: 3

Revisions (0)

No revisions yet.