extends ../layout
block content
    include ../partials/flyer
    .app-content.app-centered
    script.
        var challengeName = 'Profile View';
    if (user && user.username === username)
      .row
        if (!user.isGithubCool)
          a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/link/github')
              i.fa.fa-github
              | Link my GitHub to enable my public profile
        .col-xs-12
            a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='/settings')
                | Update my settings
        .col-xs-12
            a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='/signout')
                | Sign me out of freeCodeCamp
        .col-xs-12
            a.btn.btn-lg.btn-block.btn-primary.btn-link-social(href='mailto:team@freecodecamp.org')
                | Email us at team@freecodecamp.org
        .spacer
    h1.text-center #{username}'s code portfolio
    hr
    .row
        .col-xs-12.col-sm-10.col-sm-offset-1.col-md-8.col-md-offset-2.text-center
            if picture
                img.img-center.img-responsive.public-profile-img.border-radius-5(src=picture)
            else
                img.img-center.img-responsive.public-profile-img.border-radius-5(src='https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png')
            h1.text-center.negative-5.profile-social-icons
                if (twitter)
                    a.fa.fa-twitter-square.text-primary(title="@#{username}'s Twitter Profile", href='https://twitter.com/' + twitter, target='_blank')
                if (github)
                    a.fa.fa-github-square.text-primary(title="@#{username}'s GitHub Profile", href=github, target='_blank')
                if (linkedin)
                    a.fa.fa-linkedin-square.text-primary(title="@#{username}'s LinkedIn Profile", href=linkedin, target='_blank')
            h1.flat-top.wrappable= name
            h1.flat-top.wrappable= location
            p.flat-top.bio= bio
            h1.flat-top.text-primary= "[ " + (progressTimestamps.length) + " ]"
            if pledge
                .spacer
                  h4
                    | This camper has committed to giving $#{pledge.amount} to
                    a(href='#{pledge.donateUrl}?ref=freecodecamp.org' target='_blank')  #{pledge.displayName}
                    |  each month until they have completed their #{pledge.goal}.
                .spacer
            .row
                .col-xs-12.col-sm-10.col-sm-offset-1.col-md-8.col-md-offset-2
                    if isFrontEndCert
                        a.btn.btn-primary.btn-block(href='/' + username + '/front-end-certification') View My Front End Development Certification
                    if isDataVisCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/data-visualization-certification') View My Data Visualization Certification
                    if isBackEndCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/back-end-certification') View My Back End Development Certification
                    if isRespWebDesignCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/responsive-web-design-certification') View My Responsive Web Design Certification
                    if isFrontEndLibsCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/front-end-libraries-certification') View My Front End Libraries Certification
                    if isJsAlgoDataStructCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/javascript-algorithms-data-structures-certification') View My JavaScript Algorithms Data Structures Certification
                    if isApisMicroservicesCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/apis-microservices-certification') View My APIs Microservices Certification
                    if isInfosecQaCert
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/information-security-quality-assurance-certification') View My Information Sequrity Quality Assurance Certification
                    if (user && user.username != username)
                        .button-spacer
                        a.btn.btn-primary.btn-block(href='/' + username + '/report-user/') Report this user's profile for abuse
    .row
      .col-xs-12.text-center
        if (badges.coreTeam && badges.coreTeam.length)
            h4 Core Team #{badges.coreTeam.reverse().join(', ')}

    .spacer
    .col-md-12
        #cal-heatmap.hidden-xs.hidden-sm.d3-centered
            script.
                $(document).ready(function () {
                    var cal = new CalHeatMap();
                    var calendar = !{JSON.stringify(calender)};
                    var rectSelector = "#cal-heatmap > svg > svg.graph-legend > g > rect.r";
                    var calLegendTitles = ["0 items", "1 item", "2 items", "3 or more items"]
                    cal.init({
                        itemSelector: "#cal-heatmap",
                        domain: "month",
                        subDomain: "x_day",
                        domainGutter: 10,
                        data: calendar,
                        cellSize: 15,
                        align: 'center',
                        cellRadius: 3,
                        cellPadding: 2,
                        tooltip: true,
                        range: 6,
                        start: new Date().setDate(new Date().getDate() - 150),
                        legendColors: ["#cccccc", "#215f1e"],
                        legend: [1, 2, 3],
                        label: {
                            position: "top"
                        }
                    });
                    calLegendTitles.forEach(function(title, i) {
                        document.querySelector(rectSelector + (i + 1).toString() + '> title').innerHTML = title;
                    });
                });
        .row
            .hidden-xs.col-sm-12.text-center
                .row.text-primary
                    h4.col-sm-6.text-right Longest Streak: #{longestStreak} #{longestStreak === 1 ? ' day' : ' days'}
                    h4.col-sm-6.text-left Current Streak: #{currentStreak} #{currentStreak === 1 ? ' day' : ' days'}


          if (user && user.username == username || !isLocked)
              if (projects .length > 0)
                  .col-sm-12
                      table.table.table-striped
                          thead
                              tr
                                  th.col-xs-5 Projects
                                  th.col-xs-2.hidden-xs Completed
                                  th.col-xs-2.hidden-xs Last Updated
                                  th.col-xs-2.hidden-xs Link
                          for challenge in projects
                              tr
                                  td.col-xs-5.hidden-xs
                                    a(href='/challenges/#{challenge.block}/#{challenge.dashedName}', target='_blank')= challenge.name
                                  td.col-xs-2.hidden-xs= challenge.completedDate ? challenge.completedDate : 'Not Available'
                                  td.col-xs-2.hidden-xs= challenge.lastUpdated ? challenge.lastUpdated : ''
                                  td.col-xs-2.hidden-xs
                                      a(href=challenge.solution, target='_blank') View project
                                  td.col-xs-12.visible-xs
                                      a(href=challenge.solution, target='_blank')= challenge.name
              if (algorithms.length > 0)
                  .col-sm-12
                      table.table.table-striped
                          thead
                              tr
                                  th.col-xs-5 Algorithms
                                  th.col-xs-2.hidden-xs Completed
                                  th.col-xs-2.hidden-xs Last Updated
                                  th.col-xs-2.hidden-xs Solution
                          for challenge in algorithms
                              tr
                                  td.col-xs-5.hidden-xs= challenge.name
                                  td.col-xs-2.hidden-xs= challenge.completedDate ? challenge.completedDate : 'Not Available'
                                  td.col-xs-2.hidden-xs= challenge.lastUpdated ? challenge.lastUpdated : ''
                                  td.col-xs-2.hidden-xs
                                    if (challenge.solution)
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}?solution=#{encodeURIComponent(encodeFcc(challenge.solution))}', target='_blank') View solution
                                    else
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}') View this challenge
                                  td.col-xs-12.visible-xs
                                    if (challenge.solution)
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}?solution=#{encodeURIComponent(encodeFcc(challenge.solution))}', target='_blank')= challenge.name
                                    else
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}')= challenge.name
              if (challenges.length > 0)
                  .col-sm-12
                      table.table.table-striped
                          thead
                              tr
                                  th.col-xs-5 Challenges
                                  th.col-xs-2.hidden-xs Completed
                                  th.col-xs-2.hidden-xs Last Updated
                                  th.col-xs-2.hidden-xs Solution
                          for challenge in challenges
                              tr
                                  td.col-xs-5.hidden-xs= challenge.name
                                  td.col-xs-2.hidden-xs= challenge.completedDate ? challenge.completedDate : 'Not Available'
                                  td.col-xs-2.hidden-xs= challenge.lastUpdated ? challenge.lastUpdated : ''
                                  td.col-xs-2.hidden-xs
                                    if (challenge.solution && challenge.name)
                                      a(href='/challenges/#{challenge.block}/#{challenge.dashedName}?solution=#{encodeURIComponent(encodeFcc(challenge.solution))}', target='_blank') View solution
                                    else if (challenge.name)
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}') View this challenge
                                    else
                                        span N/A
                                  td.col-xs-12.visible-xs
                                    if (challenge.solution && challenge.name)
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}?solution=#{encodeURIComponent(encodeFcc(challenge.solution))}', target='_blank')= challenge.name
                                    else if (challenge.name)
                                        a(href='/challenges/#{challenge.block}/#{challenge.dashedName}')= challenge.name
                                    else
                                        span N/A
