
/*
 * GET favs page.
 */
var data = require('../favorites.json');
exports.view = function(req, res){
  res.render('favs',data);
};

exports.addFavorite = function(req, res){
    var t_id = req.params.trail_id;
    var t_name = req.params.trail_name;
    var t_desc = req.params.trail_desc;
    var t_diff = req.params.trail_diff;

    var newjson = {
        "id"            : t_id,
        "name"          : t_name,
        "description"   : t_desc,
        "difficulty"    : t_diff
    }
    console.log("In the javascript file.")
    console.log(newjson);
    var unique=true;
    for(var i in data.favorites)
    {
         var id = data.favorites[i].id;
         var name = data.favorites[i].name;
         var description = data.favorites[i].description;
         var difficulty = data.favorites[i].difficulty;
         if(id==t_id && name==t_name && description==t_desc && difficulty==t_diff)
         {
            unique=false;
         }
    }
    if (unique==true) {data.favorites.push(newjson);};
    //data.favorites.push(newjson);
}
@@ -578,16 +578,27 @@
 ue;%0A    
+%3C!--%0A    //
 for(var 
@@ -618,30 +618,34 @@
 orites)%0A    
+//
 %7B%0A    
+//
      var id 
@@ -668,24 +668,26 @@
 %5Bi%5D.id;%0A    
+//
      var nam
@@ -714,24 +714,26 @@
 %5D.name;%0A    
+//
      var des
@@ -774,24 +774,26 @@
 iption;%0A    
+//
      var dif
@@ -833,24 +833,26 @@
 culty;%0A     
+//
     if(id==t
@@ -923,16 +923,18 @@
 )%0A      
+//
    %7B%0A   
@@ -933,24 +933,26 @@
    %7B%0A       
+//
      unique=
@@ -958,24 +958,26 @@
 =false;%0A    
+//
      %7D%0A    %7D
@@ -979,71 +979,24 @@
     
+//
 %7D%0A    
-if (unique==true) %7Bdata.favorites.push(newjson);%7D;
+--%3E
 %0A    
-//
 data

change to the original one