
/*
 * 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;
    //     }
    //}
    -->
    data.favorites.push(newjson);
}
@@ -582,19 +582,13 @@
     
-%3C!--
 %0A    
-//
 for(
@@ -620,18 +620,14 @@
     
-//
 %7B%0A    
-//
     
@@ -658,26 +658,24 @@
 %5Bi%5D.id;%0A    
-//
      var nam
@@ -702,26 +702,24 @@
 %5D.name;%0A    
-//
      var des
@@ -760,26 +760,24 @@
 iption;%0A    
-//
      var dif
@@ -817,26 +817,24 @@
 culty;%0A     
-//
     if(id==t
@@ -905,18 +905,16 @@
 )%0A      
-//
    %7B%0A   
@@ -913,26 +913,24 @@
    %7B%0A       
-//
      unique=
@@ -940,18 +940,16 @@
 se;%0A    
-//
      %7D%0A 
@@ -955,19 +955,36 @@
     
-//
 %7D%0A    
---%3E
+if(unique==true)%0A    %7B
 %0A   
@@ -1014,9 +1014,15 @@
 wjson);%0A
+    %7D%0A
 %7D

test fav