<commit_before>/*
      Version: 0.0.1
         Date: 11/03/2015
       Author: <NAME>
      Website: http://www.searchlaboratory.com/
  Description: json quiz score calculator
 Dependencies: JQuery 2.1.0 (cdn here: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js)
 */

;(function ($, undefined) {

    'use strict';

    // GLOBAL:
    var $placeHolder = $('#quiz'),
        loadingGif = './img/loading.gif',
        dataSource = './data/data.json',
        currentQuestion = 0,
        questionCount = 0,
        answerArray = [],
        infoMode = false,
        gotData = false,
        inMemoryData = [{"questions":[{"question":"Are you?","includeInfo":true,"info":"Men take less time to settle into a new house, taking a year and a half on average, compared to the 14.2 months it takes women.","answers":[{"answer":"Female","score":1},{"answer":"Male","score":2}]},{"question":"Are you?","includeInfo":false,"info":"Almost a third of 18-24 year-olds say they do not feel their house is a home. Less than a tenth of people over 55 agree.","answers":[{"answer":"18-24","score":4},{"answer":"25-44","score":3},{"answer":"45-54","score":2},{"answer":"55+","score":1}]},{"question":"You drop a slice of toast on the floor. You...","includeInfo":true,"info":"Men are twice as likely as women to feel that being able to eat food off the floor shows that their house is a home.","answers":[{"answer":"Pick it up straight away and chuck it in the bin ","score":4},{"answer":"Think that anything under 10 seconds is ok, so you still eat it ","score":3},{"answer":"Follow the five-second rule, it’s fair game!","score":2},{"answer":"Blow off the dust and eat it no matter how long it has been there. It’s not going to kill me, is it?! ","score":1}]},{"question":"Your favourite TV show is about to start. You...","includeInfo":true,"info":"Having a set spot on the sofa matters the most to those between 35 and 44, and the least to people over 55.","answers":[{"answer":"See that your friends have taken all the seats. No worries, you’d rather sit on the floor than ask someone to move ","score":4},{"answer":"Sit in the nearest free space, you’re not picky ","score":3},{"answer":"Run to your spot. Everybody knows that’s where you sit and that’s how it will stay. How would watching TV ever be the same sat somewhere different? ","score":1},{"answer":"See that someone is in the spot you like. You try to convince them to move, but give in and sit elsewhere ","score":2}]},{"question":"You are in the house alone at night and hear a weird noise from downstairs. You...","includeInfo":true,"info":"Not being scared of weird noises is a woman’s top indicator that her house is a home","answers":[{"answer":"Freak out and grab the baseball bat at the side of your bed ","score":4},{"answer":"Roll over and go back to sleep. You know it is just the pipes ","score":1},{"answer":"Don’t think there’s anything to worry about, but you sleep with the lamp on just in case ","score":2},{"answer":"Sit up straight away and get your partner or housemate to investigate ","score":3}]},{"question":"You see your neighbour on your way to the front door. You...","includeInfo":true,"info":"this is some content for question 6","answers":[{"answer":"Say hello, you are on first-name terms","score":1},{"answer":"Nod in acknowledgement, as you only know them by the nickname you have assigned them ","score":2},{"answer":"Smile politely, as you have seen them a couple of times before","score":3},{"answer":"Ignore them and go straight in the door without a moment of eye contact","score":4}]},{"question":"You need to find the tape measure for a spot of DIY. You...","includeInfo":true,"info":"People in Cambridge say that knowing their way around the cupboards is the true sign that their house has become a home. Across the country, only 10% of people agreed with this.","answers":[{"answer":"Know exactly where it is straight away ","score":4},{"answer":"Think of a few places it could be and check them all ","score":3},{"answer":"Vaguely remember seeing it, but to find it you need to overturn the house ","score":2},{"answer":"Have absolutely no idea and decide it would be easier to buy a new one ","score":1}]},{"question":"The bins are getting full. You...","includeInfo":true,"info":"Only 6% of people placed any importance on knowing the bin schedule.","answers":[{"answer":"Know when your waste and recycling bins go out. You’ve never missed a collection ","score":1},{"answer":"Know when they are collected, but you always miss them ","score":3},{"answer":"Know your waste bin collection day, but the recycling day is a mystery ","score":2},{"answer":"Just leave them out all the time, in the hope someone will take them one day ","score":4}]},{"question":"Your house smell is...","includeInfo":true,"info":"??","answers":[{"answer":"Warm and comforting like home cooking ","score":1},{"answer":"Sterile like bleach and cleaning products ","score":2},{"answer":"Stale like bin juice","score":4},{"answer":"Non-existent, I don’t know what it smells like ","score":3}]},{"question":"At Christmas you","includeInfo":true,"info":"One in ten think that the best sign that your house has become a home, is when you have spent a Christmas there.","answers":[{"answer":"Spend it elsewhere, from start to finish  ","score":4},{"answer":"Wake up at your house but leave shortly after  ","score":3},{"answer":"Alternate between your house and others each year","score":2},{"answer":"Always spend it at your own house  ","score":1}]}]},{"results":[{"title":"The Exhibitionist","description":"You are the king in your castle, and nothing will make you feel awkward in those four walls! You’re happy to walk around in the buff, go to the toilet with the door open, and you wouldn’t think twice about eating a slice of toast that you dropped on the floor. We congratulate you in your achievement, but advise you keep the curtains closed for your neighbour’s sake!","image":"./img/the-end.jpg","minScore":0},{"title":"The Occasional Strutter","description":"You don’t mind doing the occasional strut in your underwear to retrieve your jeans from the dryer, but you’d rather avoid it. You follow the ten-second rule when food drops on the floor, and you aren’t scared of the weird noises coming from the pipes, but you are still to master going to the toilet with the door open. You are so close to being completely comfortable in your surroundings but there is still as little way to go. To help bridge the gap, take a look at our simple guide to making your house a home.","image":"./img/the-end.jpg","minScore":11},{"title":"The Mad Dasher","description":"You will only ever show flesh in the mad dash between your bathroom and bedroom, when you’re sure nobody is around. You’re likely to have a place reserved on the sofa, but there isn’t a chance you know which draw the Sellotape is in, or what your neighbour’s name is. There is still a lot of work to be done before you’re truly settled. To help you along the way, take a look at our guide to making your house a home.","image":"./img/the-end.jpg","minScore":21},{"title":"The Sock Lover","description":"You really don’t feel at home and you’re likely to feel risky just having your socks off! You don’t have a set spot on the sofa and you certainly don’t leave the door open when you go to the toilet. You have a long way to go before you will be hanging plants outside. Aside from cranking up the underfloor heating, start to feel comfy by checking out our guide to making your house a home.","image":"./img/the-end.jpg","minScore":31}]}];

    // QUIZ LOGIC:
    var quiz = function () {

        // private methods:
        var getQuizData = function (url) {

            var promise = $.getJSON(url);
            return promise;
        };

        var getScore = function () {

            var score = 0;

            $(answerArray).each(function (index, object) {
                score += parseInt(object[0].value, 10);
            });
            return score;
        };

        var updateScore = function (userAnswer) {
            console.log(userAnswer);
            answerArray.push(userAnswer);
        };

        var getHTML = function (data, currentQuestion) {

            var content, complete = true;

            $(data).each(function (index, object) {

                $(object.questions).each(function (index, object) {
                    if (infoMode) {
                        if (currentQuestion === index) {
                            infoMode = false;
                            complete = false;
                            content = infoHTML(object.info);
                        }
                    } else {
                        if (currentQuestion === index) {
                            complete = false;
                            content = questionHTML(object.question, object.answers);
                            if (object.includeInfo) infoMode = true;
                        }
                    }
                });
            });
            if (complete) { 
            	content = resultHTML();
            }
            return content;
        };

        // BIND EVENT:

        var bindSubmit = function () {<commit_msg>Added { to if statement.<commit_after>/*
      Version: 0.0.1
         Date: 11/03/2015
       Author: <NAME>
      Website: http://www.searchlaboratory.com/
  Description: json quiz score calculator
 Dependencies: JQuery 2.1.0 (cdn here: https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js)
 */

;(function ($, undefined) {

    'use strict';

    // GLOBAL:
    var $placeHolder = $('#quiz'),
        loadingGif = './img/loading.gif',
        dataSource = './data/data.json',
        currentQuestion = 0,
        questionCount = 0,
        answerArray = [],
        infoMode = false,
        gotData = false,
        inMemoryData = [{"questions":[{"question":"Are you?","includeInfo":true,"info":"Men take less time to settle into a new house, taking a year and a half on average, compared to the 14.2 months it takes women.","answers":[{"answer":"Female","score":1},{"answer":"Male","score":2}]},{"question":"Are you?","includeInfo":false,"info":"Almost a third of 18-24 year-olds say they do not feel their house is a home. Less than a tenth of people over 55 agree.","answers":[{"answer":"18-24","score":4},{"answer":"25-44","score":3},{"answer":"45-54","score":2},{"answer":"55+","score":1}]},{"question":"You drop a slice of toast on the floor. You...","includeInfo":true,"info":"Men are twice as likely as women to feel that being able to eat food off the floor shows that their house is a home.","answers":[{"answer":"Pick it up straight away and chuck it in the bin ","score":4},{"answer":"Think that anything under 10 seconds is ok, so you still eat it ","score":3},{"answer":"Follow the five-second rule, it’s fair game!","score":2},{"answer":"Blow off the dust and eat it no matter how long it has been there. It’s not going to kill me, is it?! ","score":1}]},{"question":"Your favourite TV show is about to start. You...","includeInfo":true,"info":"Having a set spot on the sofa matters the most to those between 35 and 44, and the least to people over 55.","answers":[{"answer":"See that your friends have taken all the seats. No worries, you’d rather sit on the floor than ask someone to move ","score":4},{"answer":"Sit in the nearest free space, you’re not picky ","score":3},{"answer":"Run to your spot. Everybody knows that’s where you sit and that’s how it will stay. How would watching TV ever be the same sat somewhere different? ","score":1},{"answer":"See that someone is in the spot you like. You try to convince them to move, but give in and sit elsewhere ","score":2}]},{"question":"You are in the house alone at night and hear a weird noise from downstairs. You...","includeInfo":true,"info":"Not being scared of weird noises is a woman’s top indicator that her house is a home","answers":[{"answer":"Freak out and grab the baseball bat at the side of your bed ","score":4},{"answer":"Roll over and go back to sleep. You know it is just the pipes ","score":1},{"answer":"Don’t think there’s anything to worry about, but you sleep with the lamp on just in case ","score":2},{"answer":"Sit up straight away and get your partner or housemate to investigate ","score":3}]},{"question":"You see your neighbour on your way to the front door. You...","includeInfo":true,"info":"this is some content for question 6","answers":[{"answer":"Say hello, you are on first-name terms","score":1},{"answer":"Nod in acknowledgement, as you only know them by the nickname you have assigned them ","score":2},{"answer":"Smile politely, as you have seen them a couple of times before","score":3},{"answer":"Ignore them and go straight in the door without a moment of eye contact","score":4}]},{"question":"You need to find the tape measure for a spot of DIY. You...","includeInfo":true,"info":"People in Cambridge say that knowing their way around the cupboards is the true sign that their house has become a home. Across the country, only 10% of people agreed with this.","answers":[{"answer":"Know exactly where it is straight away ","score":4},{"answer":"Think of a few places it could be and check them all ","score":3},{"answer":"Vaguely remember seeing it, but to find it you need to overturn the house ","score":2},{"answer":"Have absolutely no idea and decide it would be easier to buy a new one ","score":1}]},{"question":"The bins are getting full. You...","includeInfo":true,"info":"Only 6% of people placed any importance on knowing the bin schedule.","answers":[{"answer":"Know when your waste and recycling bins go out. You’ve never missed a collection ","score":1},{"answer":"Know when they are collected, but you always miss them ","score":3},{"answer":"Know your waste bin collection day, but the recycling day is a mystery ","score":2},{"answer":"Just leave them out all the time, in the hope someone will take them one day ","score":4}]},{"question":"Your house smell is...","includeInfo":true,"info":"??","answers":[{"answer":"Warm and comforting like home cooking ","score":1},{"answer":"Sterile like bleach and cleaning products ","score":2},{"answer":"Stale like bin juice","score":4},{"answer":"Non-existent, I don’t know what it smells like ","score":3}]},{"question":"At Christmas you","includeInfo":true,"info":"One in ten think that the best sign that your house has become a home, is when you have spent a Christmas there.","answers":[{"answer":"Spend it elsewhere, from start to finish  ","score":4},{"answer":"Wake up at your house but leave shortly after  ","score":3},{"answer":"Alternate between your house and others each year","score":2},{"answer":"Always spend it at your own house  ","score":1}]}]},{"results":[{"title":"The Exhibitionist","description":"You are the king in your castle, and nothing will make you feel awkward in those four walls! You’re happy to walk around in the buff, go to the toilet with the door open, and you wouldn’t think twice about eating a slice of toast that you dropped on the floor. We congratulate you in your achievement, but advise you keep the curtains closed for your neighbour’s sake!","image":"./img/the-end.jpg","minScore":0},{"title":"The Occasional Strutter","description":"You don’t mind doing the occasional strut in your underwear to retrieve your jeans from the dryer, but you’d rather avoid it. You follow the ten-second rule when food drops on the floor, and you aren’t scared of the weird noises coming from the pipes, but you are still to master going to the toilet with the door open. You are so close to being completely comfortable in your surroundings but there is still as little way to go. To help bridge the gap, take a look at our simple guide to making your house a home.","image":"./img/the-end.jpg","minScore":11},{"title":"The Mad Dasher","description":"You will only ever show flesh in the mad dash between your bathroom and bedroom, when you’re sure nobody is around. You’re likely to have a place reserved on the sofa, but there isn’t a chance you know which draw the Sellotape is in, or what your neighbour’s name is. There is still a lot of work to be done before you’re truly settled. To help you along the way, take a look at our guide to making your house a home.","image":"./img/the-end.jpg","minScore":21},{"title":"The Sock Lover","description":"You really don’t feel at home and you’re likely to feel risky just having your socks off! You don’t have a set spot on the sofa and you certainly don’t leave the door open when you go to the toilet. You have a long way to go before you will be hanging plants outside. Aside from cranking up the underfloor heating, start to feel comfy by checking out our guide to making your house a home.","image":"./img/the-end.jpg","minScore":31}]}];

    // QUIZ LOGIC:
    var quiz = function () {

        // private methods:
        var getQuizData = function (url) {

            var promise = $.getJSON(url);
            return promise;
        };

        var getScore = function () {

            var score = 0;

            $(answerArray).each(function (index, object) {
                score += parseInt(object[0].value, 10);
            });
            return score;
        };

        var updateScore = function (userAnswer) {
            console.log(userAnswer);
            answerArray.push(userAnswer);
        };

        var getHTML = function (data, currentQuestion) {

            var content, complete = true;

            $(data).each(function (index, object) {

                $(object.questions).each(function (index, object) {
                    if (infoMode) {
                        if (currentQuestion === index) {
                            infoMode = false;
                            complete = false;
                            content = infoHTML(object.info);
                        }
                    } else {
                        if (currentQuestion === index) {
                            complete = false;
                            content = questionHTML(object.question, object.answers);
                            if (object.includeInfo) {
                            	infoMode = true;
                        }
                    }
                });
            });
            if (complete) { 
            	content = resultHTML();
            }
            return content;
        };

        // BIND EVENT:

        var bindSubmit = function () {
{'fraction_non_alphanumeric': 0.13124054462934948, 'fraction_numerical': 0.011130322022909013, 'mean_word_length': 3.430110100526568, 'pattern_counts': {'":': 268, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1967096', 'n_tokens_mistral': 4944, 'n_tokens_neox': 4635, 'n_words': 2185}