18F/continua11y

View on GitHub
views/repo.jade

Summary

Maintainability
Test Coverage
extends ./layout.jade

block title
    title Accessibility report for #{repo}

block content
    h1!= repo
        each branch in branches
            img(src="/#{repo}.svg?branch=#{branch}" class="#{branch} badge-img" alt="accessibility for #{branch} branch")
    div.dropdown
        button(class="btn btn-default btn-sm dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true")
            | Branches 
            span.caret
        ul(class="dropdown-menu" aria-labelledby="dropdownMenu1")
            each branch in branches
                li(class="branch-selector" id="#{branch}")
                    a(href="#") #{branch}
        |  current branch: 
        span.current_branch
    div
        input(type="checkbox" title="show pull requests" class="show-pr" autocomplete="off")
        |  show pull requests
    table.table
        thead
            tr
                th commit
                th errors
                th warnings
                th notices
                th total
        tbody
            each result in results
                tr(class="#{result.branch} pr-#{result.pullRequest}")
                    if result.pullRequest
                        td #[span(class="glyphicon glyphicon-share-alt" aria-hidden="true")] #[a(href="/#{repo}/#{result.commit}") #{result.commitMessage}] #[a(href="https://github.com/#{repo}/commit/#{result.commit}") #[code #{result.shortCommit}]] 
                    else
                        td #[a(href="/#{repo}/#{result.commit}") #{result.commitMessage}] #[a(href="https://github.com/#{repo}/commit/#{result.commit}") #[code #{result.shortCommit}]] 
                    td #{result.error}
                    td #{result.warning}
                    td #{result.notice}
                    td #{result.total}

block script
    script.
        var active;
        $(document).ready(function (){
            $("tbody>tr").hide();
            $("img.badge-img").hide();
            $(".pr-true").hide();
            var branches = "#{branches}".split(",");
            if ($.inArray("#{default_branch}", branches) > -1) {
                $("tr.#{default_branch}.pr-false").show();
                $("img.#{default_branch}").show();
                $("span.current_branch").text("#{default_branch}");
                active = "#{default_branch}"
            } else {
                $("tr.#{branches[0]}.pr-false").show();
                $("img.#{branches[0]}").show();
                $("span.current_branch").text("#{branches[0]}");
                active = "#{branches[0]}"
            }
        });
        $(".branch-selector").click(function(){
            $("tbody>tr").hide();
            $("img.badge-img").hide();
            if ($(".show-pr").is(":checked")) {
                $("tr."+$(this).attr("id")).show();
            } else {
                $("tr.pr-false."+$(this).attr("id")).show();
            }
            $("img."+$(this).attr("id")).show();
            $("span.current_branch").text($(this).attr("id"));
            active = $(this).attr("id")
        });
        $(".show-pr").click(function(){
            if ($(".show-pr").is(":checked")) {
                $("tbody>tr").hide();
                $("tr."+active).show();
            } else {
                // could also do $("tr.pr-true."+active).hide();
                $("tbody>tr").hide();
                $("tr.pr-false."+active).show();
            }
        });