jaymascarenas
2/26/2018 - 6:12 PM

SC Dynamic Content Master

/**
 * checks to see if s1 qs param exists, if so update DOM with dynamic content static non-api version
 */

function dynamicContent(headerRemoval) {

    var dc = getParameterByName('dc1');


    // if the param exists then determine what values to set from switch case
    if (dc === 'teacher' || dc === 'doctor' || dc === 'military') {

        var header, benefitsList, benefitsContent;
        switch (dc) {
            case "teacher":
                header = '<h1>Government Housing Programs for Teachers!</h1><h2>Take this 2 minute survey to see if you may qualify.</h2>';
                benefitsList = '<ul>\t<li>Local grant programs</li>\n' +
                    '              \t<li>Down Payment Assistance (DPA) for educators</li>\n' +
                    '              \t<li>Discounted lender fees</li>\n' +
                    '              \t<li>Discounted Title and Realtor fees</li>\n' +
                    '              \t<li>Discounted home prices in revitalization areas</li>\n' +
                    '              \t<li>More ...</li>' +
                    '</ul>';
                benefitsContent = '<p><strong>Most teachers are unaware of these special programs.</strong></p><p>What benefits can I qualify for as a teacher?</p>' + benefitsList + '<strong>Not a Teacher?</strong><p>That\'s alright. Simply take this survey to find out if there is a special program for you.</p>';
                break;

            case "doctor":
                header = '<h1>Government Housing Programs for Doctors and Physicians!</h1><h2>Take this 2 minute survey to see if you may qualify.</h2>';
                benefitsList = '<ul><li>No employment history needed</li>\n' +
                    '              \t<li>No or low down payment</li>\n' +
                    '              \t<li>No private mortgage insurance</li>\n' +
                    '              \t<li>Discounted lender fees</li>\n' +
                    '              \t<li>Discounted Title and Realtor Fees</li>\n' +
                    '              \t<li>Breaks on student loan debt</li>\n' +
                    '              \t<li>Higher loan amounts</li>\n' +
                    '              \t<li>More ...</li></ul>';
                benefitsContent = '<p><strong>Most Physicians are unaware of these special programs.</strong></p><p>What benefits can I qualify for as a Doctor or Physician?</p>' + benefitsList + '<p><em>Physician loan benefits will depend on the various investor programs specific to your area.</em></p><strong>Not a Doctor or Physician?</strong><p>That\'s alright. Simply take this survey to find out if there is a special program for you.</p>';
                break;

            case "military":
                header = '<h1>Government Housing Programs for Active Military, Reservist and Military Veterans!</h1><h2>Take this 2 minute survey to see if you may qualify.</h2>';
                benefitsList = '<ul><li>No down payment</li>\n' +
                    '              \t<li>No mortgage insurance</li>\n' +
                    '              \t<li>Discounted lender fees</li>\n' +
                    '              \t<li>Discounted Title and Realtor fees</li>\n' +
                    '              \t<li>Eased mortgage qualifying</li>\n' +
                    '              \t<li>More ...</li></ul>';
                benefitsContent = '<p><strong>Most military members are unaware of these special programs.</strong></p><p>What benefits can I qualify for as an active military member, a reservist or a military veteran?</p>' + benefitsList + '<strong>Not a Military Member?</strong><p>That\'s alright. Simply take this survey to find out if there is a special program for you.</p>';
                break;

            default:
                break;
        }

        // hide header we are removing in favor of this content
        if (headerRemoval) {
            $(headerRemoval).hide();
        }

        // update DOM with dynamic content
        $('#dc-header').html(header).show();
        $('#dc-benefits').html(benefitsContent).show();

    }

};

/**
 * checks to see if s1 qs param exists, if so run api call, parse response and update DOM
 */

/*$(function () {

    var dc = getParameterByName('s1');
    var benefitsContent;
    // if the param exists then determine what values to set from switch case
    if (dc) {
        $.ajax({
            url: "js/test.json",
            method: "GET"
        }).done(function (data) {

            // header dynamic content
            var header = '<div class="special_program"><h2>' + data[dc].header1 + '<br>' + data[dc].header2 + '</h2>';

            // most unaware content
            var mostUnawareContent = '<p class="unaware_programs">' + data[dc].header3 + '</p>';

            // benefits content

            var benefitsLi = data[dc].benefitsList;
            benefitsContent += '<div class="benefits_content"><p>' + data[dc].header4 + '</p>';
            benefitsContent += '<ul>';
            for (var i = 0; i < benefitsLi.length; i++) {
                benefitsContent += '<li>' + benefitsLi[i] + '</li>';
            }
            benefitsContent += '</ul>';
            benefitsContent += '<strong>' + data[dc].header5 + '</strong>';
            benefitsContent += '<p>' + data[dc].header6 + '</p>';

            $('#intro-frame .inner-container').prepend(header);

            // loads most content under question
            $('.inner-container:first label:last-child').after(benefitsContent);
            $('.inner-container:first label:first').after(mostUnawareContent);


        }).fail(function (jqXHR, textStatus, error) {
            console.log("Post error: " + error);
        });
    }

});*/
/* START dyanamic content css */

.special_program h2 {
    margin: 30px 10px;
    font-size: 20px;
}
.unaware_programs {
    margin: 40px 0 10px;
    font-weight: bold;
    text-align: left;
}

.benefits_content {
    margin: 40px 0;
    text-align: left;
}
.benefits_content ul {
    margin-left: 35px;
}

/* END dyanamic content css */