{{/*
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
   http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License. See accompanying LICENSE file.
*/}}
{{ $cap_view := .Get "cap-view" }}
{{ $index := .Get "cap-index" }}
{{ $cap_data := index $.Site.Data.capability_matrix (.Get "cap-data") }}
{{ if eq (.Get "cap-data") "capability-matrix-snapshot" }}
    {{ $cap_data = index $.Site.Data.capability_matrix_snapshot (.Get "cap-data") }}
{{ end }}

{{ range $i, $category := $cap_data.categories }}
    {{ if eq $i $index}}
        <a class="back-button" href="/documentation/runners/capability-matrix">
            <i class="fas fa-arrow-left"></i>
            {{ T "capability-back" }}
        </a>
        <h4>{{ $category.description }}</h4>
        <div class="table-container">
            <div class="table-left big-left">
                <table>
                    <tr>
                        <th></th>
                    </tr>
                    {{ range $row := $category.rows }}
                        <tr>
                            <th>{{ $row.name }}</th>
                        </tr>
                    {{ end }}
                </table>
            </div>
            <div class="table-right big-right">
                <div id="{{ $category.description | urlize }}" class="table-headers big-headers">
                    <table>
                        <tr>
                            {{ range $column := $cap_data.columns }}
                                <th>{{ $column.name }}</th>
                            {{ end }}
                        </tr>
                    </table>
                </div>
                <div id="{{ $category.description | urlize }}" class="table-center big-center">
                    <table>
                        {{ range $row := $category.rows }}
                            <tr>
                                {{ range $val := $row.values }}
                                    <td style='background-color:#{{ if eq $val.l1 "Yes" }}{{ index $category "color-y" }}{{ else if eq $val.l1 "Partially" }}{{ index $category "color-p" }}{{ else }}{{ index $category "color-n" }}{{ end }};border-color:#{{ if eq $val.l1 "Yes" }}{{ index $category "color-yb" }}{{ else if eq $val.l1 "Partially" }}{{ index $category "color-pb" }}{{ else }}{{ index $category "color-nb" }}{{ end }}'>
                                        {{ partial "documentation/capability-matrix-row" (dict "type" $cap_view "val" $val) }}
                                    </td>
                                {{ end }}
                            </tr>
                        {{ end }}
                    </table>
                </div>
            </div>
        </div>
    {{ end }}
{{ end }}

<script>
    $('.table-headers').bind('wheel',function(e){
        $('#'+this.id+'.table-center').scrollLeft($(this).scrollLeft());
    });
    $('.table-center').bind('wheel',function(e){
        $('#'+this.id+'.table-headers').scrollLeft($(this).scrollLeft());
    });
</script>
