overview.jsp 27 KB
Newer Older
1 2
<!DOCTYPE html>

3
<%@ include file="/WEB-INF/jsp/init.jsp" %>
4 5 6

<html>
<head>
Maxim's avatar
Maxim committed
7
    <title><spring:message code="data-overview"/></title>
8
    <script type="text/javascript" src="<c:url value="${cdnServers.next}/html/1/js/browse.js" />"></script>
Maxim's avatar
Maxim committed
9
    <script type="text/javascript" src="<c:url value="/explore/i18n.js"/>"></script>
10
</head>
Maxim's avatar
Maxim committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<body class="overview-page explore-page">
<%--<body class="explore-page">--%>
<cms:informative-h1 title="data-overview" fancy="true" info="data-overview.intro"/>

<div class="container-fluid">

    <div id="loading-popup-id" class="loading-popup">
        <div class="loading-popup-content">
            <p><spring:message code="prompt.loading-data"/></p>
        </div>
    </div>

    <div id="error-loading-popup-id" class="error-loading-popup">
        <div class="error-loading-popup-content">
            <span class="close"><span class="glyphicon glyphicon-remove"></span></span>
            <p><spring:message code="prompt.loading-data-failed"/></p>
        </div>
    </div>

    <div class="">
        <%-- filter list --%>
32 33 34
            <filters:filter-list availableFilters="${availableFilters}" filters="${filters}"
                                 additionalFilters="${additionalFilters}" appliedFilters="${appliedFilters}"
                                 crops="${crops}" crop="${crop}" geoRegions="${geoRegions}"/>
Maxim's avatar
Maxim committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

        <div class="col-lg-10 col-md-9 col-sm-9 col-xs-12 main-col-header">
            <div class="nav-header clearfix">

                <div class="pull-right list-view-controls">

                    <div class="btn-group" id="shareLink">
                        <a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                           aria-haspopup="true" aria-expanded="false" id="menuShareLink">
                            <span class="glyphicon glyphicon-share"></span>
                            <span><spring:message code="share.link"/></span>
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li class="padding10">
                                <p><spring:message code="share.link.text"/></p>
                                <input id="shortLink" type="text"
                                       placeholder="<spring:message code="share.link.placeholder" />" value=""/>
                            </li>
                        </ul>
                    </div>

                    <a class="btn btn-default" id="exploreLink"
                       href="<c:url value="/explore"><c:param name="filter" value="${jsonFilter}" /></c:url>">
                        <span class="glyphicon glyphicon-list"></span>
                        <span style="margin-left: 0.5em;"><spring:message code="view.accessions"/></span></a>
                    <a class="btn btn-default" id="mapLink"
                       href="<c:url value="/explore/map"><c:param name="filter" value="${jsonFilter}" /></c:url>">
                        <span class="glyphicon glyphicon-globe"></span>
                        <span style="margin-left: 0.5em;"><spring:message code="maps.view-map"/></span></a>
                </div>

                <div class="pull-left list-view-controls">
                    <a class="btn btn-default btn-back" href="">
                        <spring:message code="navigate.back"/></a>
70
                </div>
Maxim's avatar
Maxim committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

            </div>

        </div>

        <div id="content-area" class="col-lg-10 col-md-9 col-sm-9 col-xs-12">
            <div id="mode-content">
                <h3 class="row row-section-heading">
                    <span class="glyphicon glyphicon-leaf"></span>
                    <spring:message code="data-overview.institutes"/>
                </h3>
                <overview:group-row>
                    <overview:row termResult="${statsInstCode}" type="instCode"
                                  messageCode="filter.institute.code"/>
                    <overview:row termResult="${statsInstCountry}" type="country"
                                  messageCode="filter.institute.country.iso3"/>
                </overview:group-row>

                <h3 class="row row-section-heading"><span class="glyphicon glyphicon-leaf"></span>
                    <spring:message code="data-overview.composition"/>
                </h3>
                <overview:group-row>
                    <overview:row termResult="${statsCrops}" type="crop" messageCode="filter.crops"/>
                    <overview:row termResult="${statsSampStat}" type="i18n.accession.sampleStatus"
                                  messageCode="filter.sampStat"/>
                </overview:group-row>
                <overview:group-row>
                    <overview:row termResult="${statsGenus}" type="genus" messageCode="filter.taxonomy.genus"/>
                    <overview:row termResult="${statsSpecies}" type="species"
                                  messageCode="filter.taxonomy.species"/>
                </overview:group-row>

                <h3 class="row row-section-heading"><span class="glyphicon glyphicon-leaf"></span>
                    <spring:message code="data-overview.sources"/>
                </h3>
                <overview:group-row>
                    <overview:row termResult="${statsOrgCty}" type="country" messageCode="filter.orgCty.iso3"/>
                    <overview:row termResult="${statsDonorCode}" type="instCode"
                                  messageCode="data-overview.donorCode"/>
                </overview:group-row>

                <h3 class="row row-section-heading"><span class="glyphicon glyphicon-leaf"></span>
                    <spring:message code="data-overview.availability"/>
                </h3>
                <overview:group-row>
                    <overview:row termResult="${statsMLS}" type="bool" messageCode="data-overview.mlsStatus"/>
                    <overview:row termResult="${statsAvailable}" type="bool" messageCode="filter.available"/>
                    <overview:row termResult="${statsHistoric}" type="bool" messageCode="filter.historic"/>
                </overview:group-row>

                <h3 class="row row-section-heading"><span class="glyphicon glyphicon-leaf"></span>
                    <spring:message code="data-overview.management"/>
                </h3>
                <overview:group-row>
                    <overview:row termResult="${statsDuplSite}" type="instCode" count="${accessionCount}"
                                  messageCode="filter.duplSite"/>
                    <overview:row termResult="${statsSGSV}" type="bool" messageCode="filter.sgsv"/>
                </overview:group-row>

                <overview:group-row>
                    <overview:row termResult="${statsStorage}" type="i18n.accession.storage"
                                  count="${accessionCount}"
                                  messageCode="filter.storage"/>
                </overview:group-row>
135
            </div>
Maxim's avatar
Maxim committed
136
        </div>
137
    </div>
Maxim's avatar
Maxim committed
138
</div>
139 140

<content tag="javascript">
Maxim's avatar
Maxim committed
141 142 143 144 145
    <script type="text/javascript">
        var jsonData = ${jsonFilter};
        localStorage.setItem("historyStep", 1);

        $(document).ready(function () {
146 147 148
            $('#explore-li').find("a").addClass('active active-group');
            $('#explore-li').addClass('active');

Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
149
            BrowseUtil.applySuggestions(jsonData, messages);
Maxim's avatar
Maxim committed
150 151 152 153 154 155 156 157 158

            $(document.getElementsByClassName("btn btn-default btn-back")).on('click', function (event) {
                event.preventDefault();
                var stepValue = localStorage.getItem("historyStep");
                window.history.go(-stepValue);
            });

            $.each($('#collapseFilters').find("div.panel-collapse"), function () {
                <c:forEach items="${appliedFilters}" var="appliedFilter">
Maxym Borodenko's avatar
Maxym Borodenko committed
159 160 161 162
                    <c:set var="normalizedAppliedFilter" value="${appliedFilter.key.replace(':', '_')}"/>
                    var collapseDiv = $(this).find($("div[id*='${normalizedAppliedFilter}']"));
                    if (collapseDiv[0] !== undefined) {
                        $(this).collapse("show");
163
                        $(this).children().children().find('.applyBtn').removeClass('disabled');
Maxym Borodenko's avatar
Maxym Borodenko committed
164
                    }
Maxim's avatar
Maxim committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
                </c:forEach>
            });

            $(window).on("popstate", function(e) {
                if (e.originalEvent.state !== null) {
                    jsonData = JSON.parse(decodeURIComponent((new RegExp('[?|&]filter=' + '([^&;]+?)(&|#|;|$)').exec(location.search)
                            || [null, ''])[1].replace(/\+/g, '%20'))) || [];
                    page = decodeURIComponent((new RegExp('[?|&]page=' + '([^&;]+?)(&|#|;|$)').exec(location.search)
                            || [null, ''])[1].replace(/\+/g, '%20')) || 1;
                    results = decodeURIComponent((new RegExp('[?|&]results=' + '([^&;]+?)(&|#|;|$)').exec(location.search)
                            || [null, ''])[1].replace(/\+/g, '%20')) || 50;
                    var filter = JSON.stringify(jsonData);
                    var requestUrl = '//' + location.host + location.pathname + "/json" +
                            "?filter=" + encodeURIComponent(filter);
                    $.ajax({
                        url: requestUrl,
                        method: 'get',
                        success: function (response) {
                            renderData(response);
                        }
                    });
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
186
                    BrowseUtil.applySuggestions(jsonData, messages);
Maxim's avatar
Maxim committed
187 188 189 190 191
                } else {
                    location.reload();
                }
            });

192
            $('body').on('input', '.panel-group .input-group .form-control', function () {
193
                BrowseUtil.validateInput($(this));
194 195
            });

Maxim's avatar
Maxim committed
196 197 198 199 200 201
            GenesysFilterUtil.registerAutocomplete(".filters", jsonData);

            $("body").on("keypress", ".string-type", function (e) {
                if (e.keyCode == 13) {
                    var btn = $(this).parent().find("button");
                    var selectedValue = $(this).parent().parent().find(".like-switcher option:selected").val();
202
                    if (selectedValue === 'like') {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
203
                        GenesysFilter.filterLike(btn, jsonData, BrowseUtil.i18nFilterMessage);
Maxim's avatar
Maxim committed
204 205 206 207 208 209 210
                    } else {
                        GenesysFilter.filterAutocomplete(btn, jsonData);
                    }
                }
            });

            $("body").on("click", ".filter-auto", function () {
211 212 213 214 215
                var filterVal = $(this).parent().parent().find('.string-type').val();
                if($.trim(filterVal) !== '') {
                    $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
                }

Maxim's avatar
Maxim committed
216
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
217
                    BrowseUtil.enableFilter(this, jsonData);
Maxim's avatar
Maxim committed
218 219 220
                }

                var selectedValue = $(this).parent().parent().parent().find(".like-switcher option:selected").val();
221
                if (selectedValue === 'like') {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
222
                    GenesysFilter.filterLike($(this), jsonData, BrowseUtil.i18nFilterMessage);
Maxim's avatar
Maxim committed
223 224 225 226 227
                } else {
                    GenesysFilter.filterAutocomplete($(this), jsonData);
                }
            });

228
            $("body").on("change", ".geo-switcher", function () {
229
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
230 231 232 233 234 235
                if (jsonData[$(this).attr("i-key")] === undefined) {
                    BrowseUtil.enableFilter(this, jsonData);
                }
                GenesysFilter.filterSelectList($(this), jsonData);
            });

Maxim's avatar
Maxim committed
236
            $("body").on("click", ".filter-list", function () {
237 238
                var parentEl = $(this).parent().parent().parent();
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
Maxim's avatar
Maxim committed
239
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
240
                    BrowseUtil.enableFilter(this, jsonData);
Maxim's avatar
Maxim committed
241 242 243 244
                }
                var text = $(this).parent().text();
                text = text.substring(0, text.indexOf('('));
                GenesysFilter.filterList($(this), jsonData, text);
245 246 247 248 249 250 251 252 253 254

                if(!$(this).is(':checked')) {
                    var needToApply = true;
                    $.each($(parentEl).find('.filtval'), function () {
                        needToApply = false;
                    });
                    if(needToApply) {
                        applyFilters();
                    }
                }
Maxim's avatar
Maxim committed
255 256 257 258
            });

            $("body").on("click", ".filter-range", function () {
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
259
                    BrowseUtil.enableFilter(this, jsonData);
Maxim's avatar
Maxim committed
260
                }
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
261
                GenesysFilter.filterRange($(this), jsonData, BrowseUtil.i18nFilterMessage);
Maxim's avatar
Maxim committed
262 263 264
            });

            $("body").on("click", ".filter-bool", function () {
265 266
                var parentEl = $(this).parent().parent().parent();
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
Maxim's avatar
Maxim committed
267
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
268
                    BrowseUtil.enableFilter(this, jsonData);
Maxim's avatar
Maxim committed
269
                }
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
270
                GenesysFilter.filterBoolean($(this), jsonData, BrowseUtil.i18nFilterMessage);
271 272 273 274 275 276 277 278 279 280

                if(!$(this).is(':checked')) {
                    var needToApply = true;
                    $.each($(parentEl).find('.filtval'), function () {
                        needToApply = false;
                    });
                    if(needToApply) {
                        applyFilters();
                    }
                }
Maxim's avatar
Maxim committed
281 282 283
            });

            $('body').on('click', '.filter-crop', function () {
284
                $(this).parent().parent().find('.applyBtn').removeClass('disabled');
Maxim's avatar
Maxim committed
285 286 287 288 289 290 291 292 293 294 295 296
                GenesysFilter.filterCrop($(this), jsonData);
            });

            $("body").on("click", ".filtval", function (event) {
                event.preventDefault();
                var key = $(this).attr("i-key");
                var normKey = GenesysFilter.normKey(key);
                var value = $(this).attr("x-key").replace(normKey, "");

                if (value == "null") value = null;
                GenesysFilterUtil.removeValue(value, key, jsonData);
                applyFilters();
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
297
                BrowseUtil.applySuggestions(jsonData, messages);
Maxim's avatar
Maxim committed
298

299 300 301 302 303 304 305 306 307 308
                var needToDisableBtn = true;
                $.each($(this).parent().find('.filtval'), function (index) {
                    if(index > 0) {
                        needToDisableBtn = false;
                    }
                });

                if (needToDisableBtn === true) {
                    $(this).parent().find('.applyBtn').addClass('disabled');
                }
Maxim's avatar
Maxim committed
309
                $(this).remove();
310
                $('input[i-key="' + key + '"][value="' + value + '"]').prop('checked', false);
Maxim's avatar
Maxim committed
311
            });
Maxym Borodenko's avatar
Maxym Borodenko committed
312 313 314 315 316 317 318 319 320

            $("body").on("input paste", ".date-input", function (e) {
                e.preventDefault();
                var key = e.keyCode || e.charCode;
                var val = $(this).val();
                var len = $(this).val().length;
                var lastChar = val.substring(len, len-1);
                var isDigit = lastChar.match(/^[0-9]+$/) != null;
                var date = this.value;
321
                if (key === 8 || key === 46 && lastChar === '-')
Maxym Borodenko's avatar
Maxym Borodenko committed
322 323 324 325 326 327 328 329 330 331 332 333 334
                    return;
                if (this.value.length > 10) {
                    this.value = date.substring(0, 10);
                } else {
                    if (isDigit) {
                        if (date.match(/^\d{4}$/) !== null) {
                            this.value = date + '-';
                        } else if (date.match(/^\d{4}\-\d{2}$/) !== null) {
                            this.value = date + '-';
                        }
                    }
                    else {
                        this.value = val.substring(0, len-1);
335
                        BrowseUtil.validateInput($(this));
Maxym Borodenko's avatar
Maxym Borodenko committed
336 337 338
                    }
                }
            });
Maxim's avatar
Maxim committed
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376

            $("body").on("change", "#more-filters", function () {
                var key = $(this).val();
                var normKey = GenesysFilterUtil.normKey(key);
                var input = $(this).parent().find("input[type='text']");
                input.attr('id', normKey + "_input");
                if (key == "institute.country.iso3") {
                    input.attr('x-source', "/explore/ac/orgCty.iso3");
                } else {
                    input.attr('x-source', "/explore/ac/" + key);
                }

                var btn = $(this).parent().find("button.filter-auto");
                btn.attr("norm-key", normKey);
                btn.attr("i-key", key);
                jsonData[key] = [];
            });

            $("#menuShareLink").on("click", function () {
                if ($('#shortLink').val() === '') {
                    $.ajax({
                        type: 'POST',
                        url: '/explore/shorten-url',
                        data: {
                            'browser': "overview", 'filter': JSON.stringify(jsonData)
                        },
                        success: function (response) {
                            var inp = $("#shortLink");
                            inp.val(response.shortUrl);
                            inp.select();
                        }
                    });
                } else {
                    console.log('No repeat.');
                }
            });

            $("body").on("click", ".applyBtn", function () {
377 378 379 380 381
                if( !$(this).hasClass('disabled') ) {
                    $(this).parent().parent().find("button.filter-auto, button.filter-range").trigger("click");
                    applyFilters();
                    BrowseUtil.applySuggestions(jsonData, messages);
                }
Maxim's avatar
Maxim committed
382 383 384 385 386 387 388 389
            });

        });

        function applyFilters(path) {
            var stepValue = (parseInt(localStorage.getItem("historyStep")) + 1);
            localStorage.setItem("historyStep", stepValue);
            document.getElementById('loading-popup-id').style.display = "block";
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
390
            BrowseUtil.cleanJsonData(jsonData);
Maxim's avatar
Maxim committed
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502

            var filter = JSON.stringify(jsonData);
            var requestUrl = '//' + location.host + location.pathname + "/json" +
                    "?filter=" + encodeURIComponent(filter);
            var displayUrl = requestUrl.replace('/json', '');
            window.history.pushState(requestUrl, '', displayUrl);

            $.ajax({
                url: requestUrl,
                method: 'get',
                success: function (response) {
                    renderData(response);
                    document.getElementById('loading-popup-id').style.display = "none";
                },
                error: function () {
                    document.getElementById('error-loading-popup-id').style.display = "block";
                }
            });
        }

        function renderData(pagedData) {
            renderLinks(pagedData);
            renderOverview(pagedData);
        }

        function renderLinks(pagedData) {
            var re = /filter=(.*)/;
            $("#exploreLink").attr("href", $("#exploreLink").attr("href").replace(re, "filter=" + encodeURIComponent(JSON.stringify(jsonData))));
            $("#mapLink").attr("href", $("#mapLink").attr("href").replace(re, "filter=" + encodeURIComponent(JSON.stringify(jsonData))));
        }

        function renderOverview(pagedData) {
            $("#mode-content").remove();

            var divModeContent = $("<div id='mode-content'/>");

            $("<h3/>")
                    .addClass("row row-section-heading")
                    .append($("<span class='glyphicon glyphicon-leaf'/>"))
                    .append(messages["data-overview.institutes"])
                    .appendTo(divModeContent);
            renderRows(
                    ["filter.institute.code", "filter.institute.country.iso3"],
                    ["statsInstCode", "statsInstCountry"],
                    ["instCode", "country"], divModeContent, pagedData);

            $("<h3/>")
                    .addClass("row row-section-heading")
                    .append($("<span class='glyphicon glyphicon-leaf'/>"))
                    .append(messages["data-overview.composition"])
                    .appendTo(divModeContent);
            renderRows(
                    ["filter.crops", "filter.sampStat"],
                    ["statsCrops", "statsSampStat"],
                    ["crop", "i18n.accession.sampleStatus"], divModeContent, pagedData);
            renderRows(
                    ["filter.taxonomy.genus", "filter.taxonomy.species"],
                    ["statsGenus", "statsSpecies"],
                    ["genus", "species"], divModeContent, pagedData);

            $("<h3/>")
                    .addClass("row row-section-heading")
                    .append($("<span class='glyphicon glyphicon-leaf'/>"))
                    .append(messages["data-overview.sources"])
                    .appendTo(divModeContent);
            renderRows(
                    ["filter.orgCty.iso3", "data-overview.donorCode"],
                    ["statsOrgCty", "statsDonorCode"],
                    ["country", "instCode"], divModeContent, pagedData);

            $("<h3/>")
                    .addClass("row row-section-heading")
                    .append($("<span class='glyphicon glyphicon-leaf'/>"))
                    .append(messages["data-overview.availability"])
                    .appendTo(divModeContent);
            renderRows(
                    ["data-overview.mlsStatus", "filter.available", "filter.historic"],
                    ["statsMLS", "statsAvailable", "statsHistoric"],
                    ["bool", "bool", "bool"], divModeContent, pagedData);

            $("<h3/>")
                    .addClass("row row-section-heading")
                    .append($("<span class='glyphicon glyphicon-leaf'/>"))
                    .append(messages["data-overview.management"])
                    .appendTo(divModeContent);
            renderRows(
                    ["filter.duplSite", "filter.sgsv"],
                    ["statsDuplSite", "statsSGSV"],
                    ["instCode", "bool"], divModeContent, pagedData);
            renderRows(
                    ["filter.storage"],
                    ["statsStorage"],
                    ["i18n.accession.storage"], divModeContent, pagedData);

            $("#content-area").append(divModeContent);
        }

        function renderRows(messageCodes, statsNames, types, parentDiv, pagedData) {
            var divRow = $("<div/>").addClass("row");
            for (var i = 0; i < messageCodes.length; i++) {
                var message = messages[messageCodes[i]];
                renderTermList(pagedData[statsNames[i]], message, types[i], divRow);
            }
            divRow.appendTo(parentDiv);
        }

        function renderTermList(stats, message, type, parentDiv) {
            var terms = stats.terms;
            var div = $("<div/>").addClass("col-lg-6 col-md-6 col-sm-6 col-xs-12 row-section");
            $("<h4/>").addClass("section-heading").text(message).appendTo(div);
            div.appendTo(parentDiv);

503
            var div2 = $("<div/>").addClass("section-inner-content clearfix");
Maxim's avatar
Maxim committed
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546

            var termTable = $("<div/>").addClass("terms-table");
            for (var i = 0; i < terms.length; i++) {
                var divRow = $("<div/>").addClass("row");
                var divText = $("<div/>").addClass("col-lg-6 col-md-6 col-sm-6 col-xs-6").appendTo(divRow);
                var span = $("<span/>");
                var divCount = $("<div/>");
                var spanCount = $("<span/>");

                switch (type) {
                    case "country":
                    {
                        $("<a />", {
                            href: "/geo/" + terms[i].term.toUpperCase(),
                            text: messages["geo.iso3166-3." + terms[i].term]
                        }).appendTo(divText);
                        break;
                    }
                    case "crop":
                    {
                        span.text(messages[terms[i].term]).appendTo(divText);
                        break;
                    }
                    case "instCode":
                    {
                        $("<a />", {
                            href: "/wiews/" + terms[i].term.toUpperCase(),
                            text: terms[i].term.toUpperCase()
                        }).appendTo(divText);
                        break;
                    }
                    case "bool":
                    {
                        if (terms[i].term == "T") {
                            span.text(messages["boolean.true"]).appendTo(divText);
                        }
                        else if (terms[i].term == "F") {
                            span.text(messages["boolean.false"]).appendTo(divText);
                        }
                        break;
                    }
                    case "genus":
                    {
Matija Obreza's avatar
Matija Obreza committed
547 548 549 550
                        $("<i />", { text: terms[i].term })
                        .appendTo($("<a />", {
                            href: "/acn/t/" + terms[i].term
                        })).appendTo(divText);
Maxim's avatar
Maxim committed
551 552 553 554
                        break;
                    }
                    case "species":
                    {
Matija Obreza's avatar
Matija Obreza committed
555
                    	$("<i />", { text: terms[i].term }).appendTo(divText);
Maxim's avatar
Maxim committed
556 557 558 559 560 561
                        break;
                    }
                    default:
                    {
                        if (type.startsWith('i18n')) {
                            var key = type.substring(5) + '.' + terms[i].term;
Matija Obreza's avatar
Matija Obreza committed
562 563
                            $("<span />", { text: messages[key] })
                            .appendTo(divText);
Maxim's avatar
Maxim committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
                        }
                        else {
                            span.text(terms[i].term).appendTo(divText);
                        }
                    }
                }

                divCount.addClass("col-lg-6 col-md-6 col-sm-6 col-xs-6").appendTo(divRow);
                var count = terms[i].count.toLocaleString();
                spanCount.addClass("stats-number").text(count).appendTo(divCount);
                divRow.appendTo(termTable);
            }
            renderAdditionalRow(stats.otherCount, "data-overview.otherCount", termTable);
            renderAdditionalRow(stats.missingCount, "data-overview.missingCount", termTable);
            termTable.appendTo(div2);
            div2.appendTo(div);
        }

        function renderAdditionalRow(count, messageCode, parentDiv) {
            if (count > 0) {
                parentDiv.append($("<div/>").addClass("row")
                        .append($("<div/>").addClass("col-lg-6 col-md-6 col-sm-6 col-xs-6")
                                .append($("<span/>")
                                        .append($("<em />").text(messages[messageCode]))))
                        .append($("<div/>").addClass("col-lg-6 col-md-6 col-sm-6 col-xs-6")
                                .append($("<span/>").addClass("stats-number").text(count.toLocaleString()))));
            }
        }

    </script>
594 595
</content>
</body>
Maxim's avatar
Maxim committed
596
</html>