var tinderPeople = [
    {image: "https://tse1.mm.bing.net/th?id=A1005a18fcdfb31abd1df72b79dd474ff&w=137&h=183&c=8&rs=1&qlt=90&dpr=1.3&pid=3.1&rm=2",
     caption: "tree"},
     {image: "img/kindling/chris_rock.jpg",
     caption: "Chris Rock"},
     {image: "img/kindling/moana.jpg",
     caption: "Moana"},
     {image: "img/kindling/stockphoto_girl.jpg",
     caption: "Tonya Bae"},
]

function generateTinderObj(imgsrc, text, url){
    var wrapFront = "url(\"";
    var wrapBack = "\") no-repeat scroll center center";
    return {image: {background: wrapFront + imgsrc + wrapBack}, caption: text, link: url};
}

function genDefault(){
    return generateTinderObj("https://tse1.mm.bing.net/th?id=A1005a18fcdfb31abd1df72b79dd474ff&w=137&h=183&c=8&rs=1&qlt=90&dpr=1.3&pid=3.1&rm=2", "tree");
}

function TinderModel(){
    var self = this;
    self.matches = ko.observableArray();
    for (let i = 0; i < tinderPeople.length-4; i++){
        self.matches.push(generateTinderObj(tinderPeople[i].image, tinderPeople[i].caption));
    }
    $.ajax({url: "/currentAdNoRefresh", 
        success: function (currentAd) {
            console.log("getting current ad");
            if (currentAd){
                console.log(currentAd);
                stories.update(currentAd.storyObject);
                if (currentAd.tinderObject){
                    self.matches.push(generateTinderObj(currentAd.tinderObject.photo, currentAd.tinderObject.caption, currentAd.tinderObject.link));
                }
            }
        },
        async: false});
    for (let = tinderPeople.length - 4; i < tinderPeople; i++){
        self.matches.push(generateTinderObj(tinderPeople[i].image, tinderPeople[i].caption));
    }

}
var pageModel = new TinderModel();
ko.applyBindings(pageModel);

/**
 * jTinder initialization
 */
function activateSliders(){
    console.log("Activating sliders");
    $("#tinderslide").jTinder({
        // dislike callback
        onDislike: function (item) {
            // set the status text
            $('#status').html('Liked!');
        },
        // like callback
        onLike: function (item) {
            // set the status text
            $('#status').html('Disliked!');
        },
        animationRevertSpeed: 200,
        animationSpeed: 400,
        threshold: 1,
        likeSelector: '.like',
        dislikeSelector: '.dislike'
    });

    /**
     * Set button action to trigger jTinder like & dislike.
     */
    $('.actions .like, .actions .dislike').click(function(e){
        e.preventDefault();
        $("#tinderslide").jTinder($(this).attr('class'));
    });
}

activateSliders();

@@ -18,160 +18,8 @@
 = %5B%0A
-    %7Bimage: %22https://tse1.mm.bing.net/th?id=A1005a18fcdfb31abd1df72b79dd474ff&w=137&h=183&c=8&rs=1&qlt=90&dpr=1.3&pid=3.1&rm=2%22,%0A     caption: %22tree%22%7D,%0A
     
@@ -54,24 +54,24 @@
 _rock.jpg%22,%0A
+
      caption
@@ -734,19 +734,19 @@
    for (
-let
+var
  i = 0; 
@@ -772,10 +772,8 @@
 ngth
--4
 ; i+
@@ -1356,32 +1356,32 @@
    %7D%0A        %7D,%0A
+
         async: f
@@ -1391,172 +1391,8 @@
 e%7D);
-%0A    for (let = tinderPeople.length - 4; i %3C tinderPeople; i++)%7B%0A        self.matches.push(generateTinderObj(tinderPeople%5Bi%5D.image, tinderPeople%5Bi%5D.caption));%0A    %7D
 %0A%0A%7D%0A

update main