Quantcast
Channel: RSS Feed Calendar Plugin - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by konijn for RSS Feed Calendar Plugin

$
0
0

This code looks good, I only have 2 minor items from a once over;

  • I would have a constant for -1 meaning an all day event

    var ALL_DAY_EVENT = -1; // <-- Declared somewhere on top
    if (position === ALL_DAY_EVENT) {
        ...
    
  • This:

    if (secondHalf.indexOf("AM") !== -1) {
        var title = secondHalf.substring(secondHalf.indexOf("AM") + 3); //Title if has AM
    } else {
        var title = secondHalf.substring(secondHalf.indexOf("PM") + 3); //Title if has PM
    }
    

    Declares title with var twice, you should declare title only once, ideally on top before your loop. Also, there is some serious code repetition there. I would suggest something like:

    //Declare meridiem and title somewhere higher prior to the loop
    meridiem = ~secondHalf.indexOf("AM") ? "AM" : "PM"; 
    title = secondHalf.substring(secondHalf.indexOf(meridiem) + 3);
    

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>