explore2.jsp 60.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html>

<%@include file="/WEB-INF/jsp/init.jsp" %>
<spring:message code='filter.internal.message.between' var="between" arguments=" "/>
<spring:message code='filter.internal.message.and' var="varEnd" arguments=" "/>
<spring:message code='filter.internal.message.more' var="moreThan" arguments=" "/>
<spring:message code='filter.internal.message.less' var="lessThan" arguments=" "/>
<spring:message code='filter.internal.message.like' var="like" arguments=" "/>
<spring:message code='boolean.true' var="varTrue"/>
<spring:message code='boolean.false' var="varFalse"/>
<spring:message code='boolean.null' var="varNull"/>

<html>
<head>
    <title><spring:message code="accession.page.data.title"/></title>
Maxim's avatar
Maxim committed
16
    <script type="text/javascript" src="<c:url value="/explore/i18n.js"/>"></script>
17
18
</head>

Taisiya Glushko's avatar
Taisiya Glushko committed
19
<body class="explore-page">
20
21
22
23
<cms:informative-h1 title="accession.page.data.title" fancy="${pagedData.number eq 0}"
                    info="accession.page.data.intro"/>
<!-- Begin page content -->
    <div class="container-fluid">
24

Maxim's avatar
Maxim committed
25
26
27
28
29
30
31
32
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content"></div>
            </div>
        </div>
        <!--End modal-->

33
34
        <div id="loading-popup-id" class="loading-popup">
            <div class="loading-popup-content">
Matija Obreza's avatar
Matija Obreza committed
35
                <p><spring:message code="prompt.loading-data" /></p>
36
37
38
            </div>
        </div>

39
        <div id="dialog" class="row"></div>
40
        <div class="">
41
            <!--Filters-->
Maxim's avatar
Maxim committed
42
            <filters:filter-list availableFilters="${availableFilters}" filters="${filters}"
Maxim's avatar
Maxim committed
43
                                 additionalFilters="${additionalFilters}" appliedFilters="${appliedFilters}"
44
                                 crops="${crops}" crop="${crop}" geoRegions="${geoRegions}"/>
Maxim's avatar
Maxim committed
45
            <!--List-->
Taisiya Glushko's avatar
Taisiya Glushko committed
46
            <div class="col-lg-10 col-md-9 col-sm-9 col-xs-12 main-col-header">
47
48
49
                <div class="nav-header clearfix">
                    <!-- Links -->
                    <div class="pull-right list-view-controls">
Maxim's avatar
Maxim committed
50
51
                        <div class="btn-group" id="displayColumns">
                            <ul class="nav nav-pills">
52
                                <li class="dropdown form-horizontal js-dropdown" id="selectColumns">
Maxim's avatar
Maxim committed
53
54
55
56
57
58
                                    <a class="dropdown-toggle btn btn-default" href="#">
                                        <b class="glyphicon glyphicon-th-list"></b>
                                        <spring:message code="columns.add"/>
                                    </a>
                                    <ul class="dropdown-menu view-columns">
                                        <li>
59
60
                                            <a id="columnsApply" style="margin-bottom: 10px" type="submit" class="btn btn-default">
                                                <spring:message code="columns.apply"/>
Maxim's avatar
Maxim committed
61
62
63
64
65
66
67
68
69
70
                                            </a>
                                        </li>
                                        <li class="dropdown-header">
                                            <spring:message code="columns.availableColumns"/>
                                        </li>
                                        <c:forEach items="${availableColumns}" var="columnName">
                                            <li>
                                                <label class="column-enable" for="cb-${columnName}">
                                                    <c:choose>
                                                        <c:when test="${selectedColumns.contains(columnName)}">
71
                                                            <input id="cb-${columnName}" type="checkbox" name="${columnName}" checked />
Maxim's avatar
Maxim committed
72
73
                                                        </c:when>
                                                        <c:otherwise>
74
                                                            <input id="cb-${columnName}" type="checkbox" name="${columnName}"/>
Maxim's avatar
Maxim committed
75
76
77
78
79
80
81
82
83
84
85
                                                        </c:otherwise>
                                                    </c:choose>
                                                    <spring:message code="accession.${columnName}"/>
                                                </label>
                                            </li>
                                        </c:forEach>
                                    </ul>
                                </li>
                            </ul>
                        </div>

86
                        <div class="btn-group" id="shareLink">
87
                            <a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="menuShareLink">
Maxim's avatar
Maxim committed
88
89
                                <span class="glyphicon glyphicon-share"></span>
                                <span><spring:message code="share.link"/></span>
90
                                <span class="caret"></span>
Taisiya Glushko's avatar
Taisiya Glushko committed
91
                            </a>
92
93
94
                            <ul class="dropdown-menu">
                                <li class="padding10">
                                    <p><spring:message code="share.link.text"/></p>
95
                                    <input id="shortLink" placeholder="<spring:message code="share.link.placeholder" />" value=""/>
96
97
98
99
                                </li>
                            </ul>
                        </div>

Maxim's avatar
Maxim committed
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
135
136

                        <div class="btn-group" id="downloadLink"
                             <c:if test="${pagedData.totalElements ge 200000}">style="display: none"</c:if>>

                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                    aria-haspopup="true" aria-expanded="false">
                                <span class="glyphicon glyphicon-download"></span>
                                <span><spring:message code="download"/></span>
                                <span class="caret"></span>
                            </button>

                            <ul class="dropdown-menu">
                                <security:authorize access="isAuthenticated()">
                                    <li>
                                        <form style="display: inline-block" method="post"
                                              action="<c:url value="/download/explore/download/mcpd" />">
                                            <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                                            <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>
                                            <button class="btn btn-inline " type="submit">
                                                <span><spring:message code="filter.download-mcpd"/></span>
                                            </button>
                                        </form>
                                    </li>
                                </security:authorize>
                                <li>
                                    <form style="display: inline-block" method="post"
                                          action="<c:url value="/download/explore/dwca" />">
                                        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                                        <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>
                                        <button class="btn btn-inline" type="submit">
                                            <span><spring:message code="filter.download-dwca"/></span>
                                        </button>
                                    </form>
                                </li>
                            </ul>
                        </div>

137
                        <a class="btn btn-default" id="overviewLink"
Maxim's avatar
Maxim committed
138
                           style=${(empty additionalFilters)? "'display: inline'": "'display: none'" }
Maxim's avatar
Maxim committed
139
140
141
142
                           href="<c:url value="/explore/overview"><c:param name="filter">${jsonFilter}</c:param></c:url>">
                            <span class="glyphicon glyphicon-eye-open"></span>
                            <span><spring:message code="data-overview.short"/></span>
                        </a>
143
144
                        <a class="btn btn-default" id="mapLink"
                           href="<c:url value="/explore/map"><c:param name="filter">${jsonFilter}</c:param></c:url>"><span
Maxim's avatar
Maxim committed
145
146
147
                                class="glyphicon glyphicon-globe"></span>
                            <span><spring:message code="maps.view-map"/></span>
                        </a>
148
                    </div>
149
150
151
152
                    <div class="top-pagination-wrapper">
                        <!--Pagination-->
                        <filters:pagination pagedData="${pagedData}" jsonFilter="${jsonFilter}"/>
                    </div>
153
154
                </div>
            </div>
Taisiya Glushko's avatar
Taisiya Glushko committed
155
            <div id="content-area" class="col-lg-10 col-md-9 col-sm-9 col-xs-12 explore-table">
156
                <span id="table-top" class="table-anchor"></span>
157
158
159
                <table class="accessions">
                    <thead>
                    <tr>
Taisiya Glushko's avatar
Taisiya Glushko committed
160
161
                        <td class="idx-col"><p></p></td>
                        <td><p></p></td>
162
                        <td><p><spring:message code="accession.accessionName" /></p></td>
Taisiya Glushko's avatar
Taisiya Glushko committed
163
                        <c:forEach items="${selectedColumns}" var="column" varStatus="i">
164
                            <c:choose>
Taisiya Glushko's avatar
Taisiya Glushko committed
165
                                <c:when test="${i.count eq 1}">
166
167
                                    <td><p><spring:message code="accession.${column}"/></p></td>
                                </c:when>
Taisiya Glushko's avatar
Taisiya Glushko committed
168
                                <c:when test="${i.count eq 2}">
169
170
                                    <td class="notimportant hidden-xs"><p><spring:message code="accession.${column}"/></p></td>
                                </c:when>
Taisiya Glushko's avatar
Taisiya Glushko committed
171
172
173
                                <c:when test="${column eq 'taxonomy.species'}">
                                    <td class="notimportant hidden-sm hidden-xs"><p><spring:message code="accession.${column}"/></p></td>
                                </c:when>
174
175
176
177
178
179
180
181
182
183
184
                                <c:otherwise>
                                    <td class="notimportant hidden-sm hidden-xs"><p><spring:message code="accession.${column}"/></p></td>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${pagedData.content}" var="accession" varStatus="status">
                        <tr class="acn ${status.count % 2 == 0 ? 'even' : 'odd'} ${accession.historic ? 'historic-record' : ''}">
                            <td class="idx-col"><p>${status.count + pagedData.size * pagedData.number}</p></td>
Taisiya Glushko's avatar
Taisiya Glushko committed
185
                            <td><span class="sel" x-aid="${accession.id}" title="<spring:message code="selection.checkbox" />"></span></td>
186
                            <td><p><local:accession-details-link accession="${accession}" /></p></td>
Taisiya Glushko's avatar
Taisiya Glushko committed
187
                            <c:forEach items="${selectedColumns}" var="col" varStatus="i">
188
                                <c:choose>
189
190
191
192
                                    <c:when test="${col eq 'doi'}">
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>">
                                        	<p>
                                        		<c:if test="${accession.doi ne null}">
193
                                        			<a href="<c:url value="/${accession.doi}" />"><c:out value="${accession.doi}" /></a>
194
195
196
197
                                        		</c:if>
                                        	</p>
                                        </td>
                                    </c:when>
198
                                    <c:when test="${col eq 'taxonomy.sciName'}">
Matija Obreza's avatar
Matija Obreza committed
199
                                        <td class="<c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><span dir="ltr" class="sci-name"><c:out escapeXml="false" value="${accession.taxonomy.sciNameHtml}"/></span></p></td>
200
201
                                    </c:when>
                                    <c:when test="${col eq 'orgCty'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
202
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><c:out value="${jspHelper.getCountry(accession.orgCty.iso3).getName(pageContext.response.locale)}"/></p></td>
203
                                    </c:when>
204
205
206
                                    <c:when test="${col eq 'cropName'}">
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><c:out value="${accession.cropName}"/></p></td>
                                    </c:when>
207
                                    <c:when test="${col eq 'sampStat'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
208
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><spring:message code="accession.sampleStatus.${accession.sampStat}"/></p></td>
209
                                    </c:when>
210
211
212
213
214
215
                                    <c:when test="${col eq 'acceName'}">
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><c:out value="${accession.acceName}"/></p></td>
                                    </c:when>
                                    <c:when test="${col eq 'donorNumb'}">
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><c:out value="${accession.donorNumb}"/></p></td>
                                    </c:when>
216
                                    <c:when test="${col eq 'institute.code'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
217
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><a href="<c:url value="/wiews/${accession.institute.code}" />"><c:out
218
219
220
                                                value="${accession.institute.code}"/></a></p></td>
                                    </c:when>
                                    <c:when test="${col eq 'taxonomy.genus'}">
Matija Obreza's avatar
Matija Obreza committed
221
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><span dir="ltr" class="sci-name"><i><c:out value="${accession.taxonomy.genus}"/></i></span></p></td>
222
223
                                    </c:when>
                                    <c:when test="${col eq 'taxonomy.species'}">
Matija Obreza's avatar
Matija Obreza committed
224
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><span dir="ltr" class="sci-name"><i><c:out value="${accession.taxonomy.species}"/></i></span></p></td>
225
226
                                    </c:when>
                                    <c:when test="${col eq 'taxonomy.subtaxa'}">
Matija Obreza's avatar
Matija Obreza committed
227
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><span dir="ltr" class="sci-name"><i><c:out value="${accession.taxonomy.subtaxa}"/></i></span></p></td>
228
229
230
                                    </c:when>
                                    <c:when test="${col eq 'crops'}">
                                        <c:if test="${fn:length(accession.crops) == 0}">
Taisiya Glushko's avatar
Taisiya Glushko committed
231
                                            <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"></td>
232
233
                                        </c:if>
                                        <c:forEach items="${jspHelper.getCrops(accession.crops)}" var="crop">
Taisiya Glushko's avatar
Taisiya Glushko committed
234
                                            <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><a href="<c:url value="/c/${crop.shortName}" />"><c:out
235
236
237
238
                                                    value="${crop.getName(pageContext.response.locale)}"
                                                    /></a></p></td>
                                        </c:forEach>
                                    </c:when>
239
240
241
                                    <c:when test="${col eq 'pdci.score'}">
                                        <td class="notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"><p><fmt:formatNumber value="${accession.pdciScore}"/></p></td>
                                    </c:when>
242
243
244
245
246
247
248
249
250
251
252
253
254
255
                                    <c:otherwise>
                                        <c:set var="elVal" value="${accession}" />
                                        <c:forTokens items="${col}" delims="." var="item">
                                            <c:set var="elVal" value="${elVal[item]}" />
                                        </c:forTokens>
                                        <td class="notimportant hidden-sm hidden-xs"><p><c:out value="${elVal}"/></p></td>
                                        <c:remove var="elVal"/>
                                    </c:otherwise>
                                </c:choose>
                            </c:forEach>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
Taisiya Glushko's avatar
Taisiya Glushko committed
256
257
258
259
260
261
262
263
264
                    <div class="nav-header bottom-pagination-wrapper clearfix">
                        <!--Pagination-->
                        <filters:pagination pagedData="${pagedData}" jsonFilter="${jsonFilter}"/>
                        <nav class="text-center pull-right">
                            <ul class="pagination">
                                <li>
                                    <span><spring:message code="paged.resultsPerPage" /></span>
                                </li>
                                <li>
265
266
267
268
269
270
271
272
273
274
                                <span>
                                    <select class="form-control results-per-page">
                                        <option value="10" ${pagedData.size == 10 ? "selected" : ""}>10</option>
                                        <option value="20" ${pagedData.size == 20 ? "selected" : ""}>20</option>
                                        <option value="40" ${pagedData.size == 40 ? "selected" : ""}>40</option>
                                        <option value="50" ${pagedData.size == 50 ? "selected" : ""}>50</option>
                                        <option value="75" ${pagedData.size == 75 ? "selected" : ""}>75</option>
                                        <option value="100" ${pagedData.size == 100 ? "selected" : ""}>100</option>
                                    </select>
                                </span>
Taisiya Glushko's avatar
Taisiya Glushko committed
275
276
277
278
                                </li>
                            </ul>
                        </nav>
                    </div>
279
            </div>
Taisiya Glushko's avatar
Taisiya Glushko committed
280
281
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12"></div>

282
283
284
            <!--End of List-->
        </div>
    </div>
Taisiya Glushko's avatar
Taisiya Glushko committed
285

286
287
288
289
290
291
292

<content tag="javascript">
    <script type="text/javascript">
        var jsonData = ${jsonFilter};

        var page = ${pagedData.number};

293
294
        var totalPages = ${pagedData.totalPages};

295
296
        var results = ${pagedData.size};

Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
297
298
        var cropNames = [];

Taisiya Glushko's avatar
Taisiya Glushko committed
299
300
301
302
303
304
305
306
        var headersCopy = $(".accessions").find("thead td").clone();

        var headerSelects = [];

        var rowsCopy = $(".accessions").find("tbody tr").clone();

        var lastWindowWidth;

307
308
309
310
311
312
313
        var Page = {
            FIRST : 1,
            PREVIOUS : 2,
            NEXT : 3,
            LAST : 4
        };

314
        $(document).ready(function () {
315
            $('#explore-li').find('a').addClass('active active-group');
316
            $('#explore-li').addClass('active');
317

Maxim's avatar
Maxim committed
318
            if (jsonData.crops != null && jsonData.crops.length > 0) {
319
                $('#panel_additional_id').show();
Maxim's avatar
Maxim committed
320
321
322
323
            }

            $.each(jsonData, function(key) {
                if(key.startsWith('gm:')) {
324
                    $('#panel_additional_id').show();
Maxim's avatar
Maxim committed
325
326
327
                }
            });

Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
328
329
330
331
332
333
334
335
336
337
338
339
            cropNames = function(){
                var data = null;
                $.ajax({
                    url: "/explore/getCrops",
                    method: 'get',
                    async: false
                }).done(function (response) {
                    data = response;
                });
                return data;
            }();

340
            $("body").on("keypress", ".string-type", function (e) {
341
342
343
                if (e.keyCode === 13) {
                    var btn = $(this).parent().find('button');
                    var selectedValue = $(this).parent().parent().find('.like-switcher option:selected').val();
344

345
                    if (selectedValue === 'like') {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
346
                        GenesysFilter.filterLike(btn, jsonData, BrowseUtil.i18nFilterMessage);
347
348
349
350
351
                    } else {
                        GenesysFilter.filterAutocomplete(btn, jsonData);
                    }
                }
            });
352

353
            $('body').on('input', '.panel-group .input-group .form-control', function () {
354
                BrowseUtil.validateInput($(this));
355
            });
356
357

            $("body").on("click", ".filter-auto", function () {
358
359
360
361
362
                var filterVal = $(this).parent().parent().find('.string-type').val();
                if($.trim(filterVal) !== '') {
                    $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
                }

363
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
364
                    BrowseUtil.enableFilter(this, jsonData);
365
                }
366
367
                var selectedValue = $(this).parent().parent().parent().find('.like-switcher option:selected').val();
                if (selectedValue === 'like') {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
368
                    GenesysFilter.filterLike($(this), jsonData, BrowseUtil.i18nFilterMessage);
369
370
371
372
373
                } else {
                    GenesysFilter.filterAutocomplete($(this), jsonData);
                }
            });

374
            $("body").on("change", ".geo-switcher", function () {
375
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
376
377
378
379
380
381
                if (jsonData[$(this).attr("i-key")] === undefined) {
                    BrowseUtil.enableFilter(this, jsonData);
                }
                GenesysFilter.filterSelectList($(this), jsonData);
            });

Maxim's avatar
Maxim committed
382
            $("body").on("click", ".filter-list", function () {
383
384
                var parentEl = $(this).parent().parent().parent();
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
Maxim's avatar
Maxim committed
385
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
386
                    BrowseUtil.enableFilter(this, jsonData);
Maxim's avatar
Maxim committed
387
388
                }
                var text = $(this).parent().text();
389
390
391
392
393
394
395
396
                text = $.trim(text);
                text = text.substring(0, text.indexOf('('));
                GenesysFilter.filterList($(this), jsonData, text);

                if(!$(this).is(':checked')) {
                    var needToApply = true;
                    $.each($(parentEl).find('.filtval'), function () {
                        needToApply = false;
397
                    });
398
399
400
401
                    if(needToApply) {
                        applyFilters();
                    }
                }
Maxim's avatar
Maxim committed
402
403
            });

404
405
            $("body").on("click", ".filter-range", function () {
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
406
                    BrowseUtil.enableFilter(this, jsonData);
407
                }
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
408
                GenesysFilter.filterRange($(this), jsonData, BrowseUtil.i18nFilterMessage);
409
410
411
            });

            $("body").on("click", ".filter-bool", function () {
412
413
                var parentEl = $(this).parent().parent().parent();
                $(this).parent().parent().parent().find('.applyBtn').removeClass('disabled');
414
                if (jsonData[$(this).attr("i-key")] === undefined) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
415
                    BrowseUtil.enableFilter(this, jsonData);
416
                }
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
417
                GenesysFilter.filterBoolean($(this), jsonData, BrowseUtil.i18nFilterMessage);
418
419
420
421
422

                if(!$(this).is(':checked')) {
                    var needToApply = true;
                    $.each($(parentEl).find('.filtval'), function () {
                        needToApply = false;
423
                    });
424
425
426
427
                    if(needToApply) {
                        applyFilters();
                    }
                }
428
429
            });

430
            $('body').on('click', '.filter-crop', function () {
431
                $(this).parent().parent().find('.applyBtn').removeClass('disabled');
432
433
434
435
                GenesysFilter.filterCrop($(this), jsonData);
            });

            $("body").on("click", ".applyBtn", function () {
436
                if( !$(this).hasClass('disabled') ) {
437
438
439
                $(this).parent().parent().find("button.filter-auto, button.filter-range").trigger("click");
                applyFilters();
                BrowseUtil.applySuggestions(jsonData, messages);
440
                }
Maxim's avatar
Maxim committed
441
442
443
444
            });

            $("body").on("click", ".removeFilterBtn", function () {
                var className = $(this).parent().parent().attr("class");
Maxim's avatar
Maxim committed
445
446
                var filterId = "#panel_" + className.replace(" col-xs-12", "");
                var filter = className.replace("gm_", "gm:").replace("_id", "").replace(" col-xs-12", "");
Maxim's avatar
Maxim committed
447
448
449
450
451
452
453
454
455
456
457

                delete jsonData[filter];
                $(filterId).remove();

                if (!isExistAdditionalFilters()) {
                    $("#overviewLink").show();

                    if (jsonData.crops == null || jsonData.crops.length == 0) {
                        $("#panel_additional_id").hide();
                    }
                }
458

459
                applyFilters();
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
460
                BrowseUtil.applySuggestions(jsonData, messages);
461
462
            });

Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
463
            BrowseUtil.applySuggestions (jsonData, messages);
464
465
466
467
468
469
470
471

            $("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, "");

472
                if (value === 'null') value = null;
473
474
                GenesysFilterUtil.removeValue(value, key, jsonData);
                applyFilters();
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
475
                BrowseUtil.applySuggestions(jsonData, messages);
476

477
478
479
480
481
482
483
484
485
486
                var needToDisableBtn = true;
                $.each($(this).parent().find('.filtval'), function (index) {
                    if(index > 0) {
                        needToDisableBtn = false;
                    }
                });

                if (needToDisableBtn === true) {
                    $(this).parent().find('.applyBtn').addClass('disabled');
                }
487
                $(this).remove();
Maxim's avatar
Maxim committed
488
489
                $('input[i-key="' + key + '"][value="' + value + '"]').prop('checked', false);

490
                if (jsonData["crops"] !== undefined && jsonData["crops"].length === 0) {
Maxim's avatar
Maxim committed
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
                    delete jsonData["crops"];
                    $("#panel_additional_id").hide();
                }
            });

            $("body").on("click", ".addFiltersBtn", function () {
                $.ajax("<c:url value="/modal" />", {
                    type: 'GET',
                    data: "shortName=" + jsonData.crops,
                    success: function (data) {
                        $(".modal-content").empty();
                        $(".modal-content").append(data);

                        for (var additionalFilterName in jsonData) {
                            $(".modal-body .filter-block label > input[value='" + additionalFilterName + "']").prop("checked", true);
                        }
                    },
                    error: function (error) {
                        console.log(error);
                    }
                });
            });

Maxym Borodenko's avatar
Maxym Borodenko committed
514
515
516
517
518
519
520
521
            $("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;
522
                if (key === 8 || key === 46 && lastChar === '-')
Maxym Borodenko's avatar
Maxym Borodenko committed
523
524
525
526
527
528
529
530
531
532
533
534
535
                    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);
536
                        BrowseUtil.validateInput($(this));
Maxym Borodenko's avatar
Maxym Borodenko committed
537
538
539
540
                    }
                }
            });

Maxim's avatar
Maxim committed
541
542
543
544
545
546
547
548
549
550
551
552
553
554
            $("body").on("click", ".additional", function () {
                var id = $(this).attr("id");
                var filterId = "#panel_" + id.replace("_id", "");
                var filter = id.replace("gm_", "gm:").replace("_id", "");

                if ($(this).is(":checked")) {
                    GenesysFilterUtil.appendFilter(filter, filterId, jsonData);
                    $("#overviewLink").hide();
                }
                else {
                    delete jsonData[filter];
                    $(filterId).remove();
                    $("#overviewLink").show();
                }
555
556
557
            });

            $("#menuShareLink").on("click", function () {
558
                $("#selectColumns").removeClass('open');
559
560
561
562
563
                if ($('#shortLink').val() === '') {
                    $.ajax({
                        type: 'POST',
                        url: '/explore/shorten-url',
                        data: {
Maxim's avatar
Maxim committed
564
                            'page': 1, 'filter': JSON.stringify(jsonData), browser: "explorer"
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
                        },
                        success: function (response) {
                            var inp = $("#shortLink");
                            inp.val(response.shortUrl);
                            inp.select();
                        }
                    });
                } else {
                    console.log('No repeat.');
                }
            });

            $("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] = [];
            });

594
595
            $("body").on("click", ".firstPage", function(e) {
                e.preventDefault();
596
597
598
599
600
                if ($(this).closest("li").hasClass("disabled") === false) {
                    applyFiltersWithPageNumber(1);
                    var element_to_scroll_to = $('#table-top')[0];
                    element_to_scroll_to.scrollIntoView();
                }
601
602
603
604
            });

            $("body").on("click", ".nextPage", function(e) {
                e.preventDefault();
605
606
607
608
609
610
                if ($(this).closest("li").hasClass("disabled") === false) {
                    page = (page ) === 501 ? page : page + 1;
                    applyFiltersWithPageNumber(page + 1);
                    var element_to_scroll_to = $('#table-top')[0];
                    element_to_scroll_to.scrollIntoView();
                }
611
612
613
614
            });

            $("body").on("click", ".previousPage", function(e) {
                e.preventDefault();
615
616
617
618
619
620
                if ($(this).closest("li").hasClass("disabled") === false) {
                    page = page === 0 ? 0 : (page - 1);
                    applyFiltersWithPageNumber(page + 1);
                    var element_to_scroll_to = $('#table-top')[0];
                    element_to_scroll_to.scrollIntoView();
                }
621
622
623
624
            });

            $("body").on("click", ".lastPage", function(e) {
                e.preventDefault();
625
626
627
628
629
                if ($(this).closest("li").hasClass("disabled") === false) {
                    applyFiltersWithPageNumber(totalPages);
                    var element_to_scroll_to = $('#table-top')[0];
                    element_to_scroll_to.scrollIntoView();
                }
630
631
632
633
634
635
636
637
638
639
            });

            $("body").on("click", ".close", function(e) {
                e.preventDefault();
                $('#error-loading-popup-id').hide();
                $('#loading-popup-id').hide();
            });

            $(".top-pagination-wrapper #paginationInputField").on("keypress", function(e) {
                if(e.which === 13) {
640
                    e.preventDefault();
641
                    applyFiltersWithPageNumber($(this).val());
642
643
                    var tableToScrollTo = $('#table-top')[0];
                    tableToScrollTo.scrollIntoView();
644
                }
645
646
            });

647
648
649
650
651
652
653
654
655
656
            $(".bottom-pagination-wrapper #paginationInputField").on("keypress", function(e) {
                if(e.which === 13) {
                    e.preventDefault();
                    applyFiltersWithPageNumber($(this).val());
                    var tableToScrollTo = $('#table-top')[0];
                    tableToScrollTo.scrollIntoView();
                }
            });

            $("body").on("input paste", "#paginationInputField", function (e) {
657
                e.preventDefault();
658
659
660
                if (/\D/g.test(this.value)) {
                    // Filter non-digits from input value.
                    this.value = this.value.replace(/\D/g, '');
Maxym Borodenko's avatar
Maxym Borodenko committed
661
662
                } else if (this.value === '0') {
                    this.value = '';
663
                }
664
665
666
667
668
669
670
671
672
            });

            $(".results-per-page").on("change", function () {
                results = $(this).val();
                applyFilters();
            });

            $.each($('#collapseFilters').find("div.panel-collapse"), function () {
                <c:forEach items="${appliedFilters}" var="appliedFilter">
Maxym Borodenko's avatar
Maxym Borodenko committed
673
674
675
676
                    <c:set var="normalizedAppliedFilter" value="${appliedFilter.key.replace(':', '_')}"/>
                    var collapseDiv = $(this).find($("div[id*='${normalizedAppliedFilter}']"));
                    if (collapseDiv[0] !== undefined) {
                        $(this).collapse("show");
677
678
                        if(!$(this).is('#panel_additional_collapse')) {
                            $(this).children().children().find('.applyBtn').removeClass('disabled');
679
                        }
Maxym Borodenko's avatar
Maxym Borodenko committed
680
                    }
681
682
                </c:forEach>
            });
Maxim's avatar
Maxim committed
683

684
685
686
687
688
689
690
            $(document).bind('click', function(e) {
                var clicked = $(e.target);
                if (!clicked.parents().hasClass('view-columns') && !clicked.parents().hasClass('js-dropdown')) {
                    $('#selectColumns').removeClass('open');
                }
            });

Maxim's avatar
Maxim committed
691
692
693
            $('li#selectColumns a').on('click', function (event) {
                event.preventDefault();
                $(this).parent().toggleClass('open');
694
            });
Taisiya Glushko's avatar
Taisiya Glushko committed
695

Maxim's avatar
Maxim committed
696
697
698
699
700
701
            $('#columnsApply').on('click', function () {
                var columns = [];
                [].forEach.call($('.view-columns li'), function (el) {
                    if ($(el).find('input:checkbox').is(':checked')) {
                        columns.push($(el).find('input:checkbox').prop('name'));
                    }
702
                });
Maxim's avatar
Maxim committed
703
                var filter = JSON.stringify(jsonData);
704
705
706
                var results = decodeURIComponent((new RegExp('[?|&]results=' + '([^&;]+?)(&|#|;|$)').exec(location.search)
                    || [null, ''])[1].replace(/\+/g, '%20')) || 50;
                var url = '<c:url value="/explore" />' + '?filter=' + filter + "&columns=" + columns.toString() + "&results=" + results;
Maxim's avatar
Maxim committed
707
                window.location.href = encodeURI(url);
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
            });

            $(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?page=" + page + "&filter=" + filter + "&results=" + results;
                    $.ajax({
                        url: requestUrl,
                        method: 'get',
                        success: function (response) {
                            renderData(response);
                        }
                    });
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
727
                    BrowseUtil.applySuggestions(jsonData, messages);
728
729
730
731
732
733
734
735
736
737
738
739
740
741
                } else {
                    location.reload();
                }
            });

            GenesysFilterUtil.registerAutocomplete(".filters", jsonData);

            $.ajax({
                url: "/explore/booleanSuggestions",
                method: 'get',
                data: {
                    filter: JSON.stringify(jsonData)
                },
                success: function (response) {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
742
                    BrowseUtil.renderBooleanSuggestions(response);
743
744
                }
            });
Taisiya Glushko's avatar
Taisiya Glushko committed
745

Maxim's avatar
Maxim committed
746
747
748
749
750
751
752
753
754
755
            function isExistAdditionalFilters() {
                for(var filter in jsonData) {
                    if(filter.toString().startsWith("gm:")) {
                        return true;
                    }
                }
                return false;
            }


Taisiya Glushko's avatar
Taisiya Glushko committed
756
757
758
759
760
761
762
763
764
            function restoreHeaders() {
                $.each($("select.column-changer"), function () {
                    var index = $(this).attr("x-id");
                    var oldHeader = $(headersCopy[index]).html();
                    $(this).parent().html(oldHeader);
                });
            }

            function resize() {
765
                if (window.innerWidth < 992) {
Taisiya Glushko's avatar
Taisiya Glushko committed
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
                    var headers = $(".accessions").find("thead td");
                    $.each(headersCopy, function (index) {
                        if (index >= 3 && headerSelects[index] != true) {
                            var select = $("<select/>", {
                                'class': 'column-changer',
                                'x-id': index
                            });

                            var selectedOption = $("<option/>", {
                                value: $(this).text(),
                                text: $(this).text(),
                                'x-id': index,
                                selected: true
                            });
                            selectedOption.appendTo(select);

                            for (var i = 3; i < headers.length; i++) {
                                if ($(headers[i]).text() !== $(headers[index]).text()) {
                                    var option = $("<option/>", {
                                        value: $(headersCopy[i]).text(),
                                        text: $(headersCopy[i]).text(),
                                        'x-id': i
                                    });

                                    option.appendTo(select);
                                }
                            }

                            $(headers[index]).html(select);
                            select.after('<span class="glyphicon glyphicon-menu-down"></span>');
                            headerSelects[index] = true;
                        }
                    });

                    $.each($("select.column-changer"), function () {
                        $(this).on("change", function() {
                            var cols;
                            var from = $(this).find("option:selected").attr("x-id");
                            var to = $(this).attr("x-id");
                            $.each($(".accessions").find("tbody tr"), function(index) {
                                cols = $(this).children('td');
                                var val = $(rowsCopy[index]).children().eq(from).html();
                                cols.eq(to).html(val);
                            });
                        });
                    });
                } else {
                    restoreHeaders();
                    headerSelects = [];
                    if (lastWindowWidth < 992) {
                        var path = "?page=" + (page + 1) + "&" + "filter=" + encodeURIComponent(JSON.stringify(jsonData));
                        applyFilters(path);
                    }
                }

821
                lastWindowWidth = window.innerWidth;
Taisiya Glushko's avatar
Taisiya Glushko committed
822
823
824
825
826
827
828
            }

            resize();

            $(window).resize(function () {
                resize();
            });
829
830
        });

Maxim's avatar
Maxim committed
831
832
833
834
835
836
837
838
839
840
        function applyFilters (path) {
            document.getElementById('loading-popup-id').style.display = "block";
            var filter = JSON.stringify(jsonData);
            var requestUrl = '//' + location.host + location.pathname + "/json" +
                    (path !== undefined ? path : "?page=1&" + "filter=" + encodeURIComponent(filter));
            requestUrl += "&results=" + results;
            var displayUrl = requestUrl.replace('/json', '');

            window.history.pushState(requestUrl, '', displayUrl);
            $.ajax({
841
                beforeSend: function(xhrObj){
842
843
                    xhrObj.setRequestHeader("Content-Type", "application/json");
                    xhrObj.setRequestHeader("Accept", "application/json");
844
                },
Maxim's avatar
Maxim committed
845
846
847
848
849
850
851
852
853
854
                url: requestUrl,
                method: 'get',
                success: function (response) {
                    renderData(response);
                    document.getElementById('loading-popup-id').style.display = "none";
                    $.each($("select.column-changer"), function () {
                        $(this).change();
                    });
                },
                error: function () {
855
856
                    var message = $.trim('<spring:message code="prompt.loading-data-failed" />');
                    buildErrorPopup(message);
Maxim's avatar
Maxim committed
857
                    document.getElementById('error-loading-popup-id').style.display = "block";
858
                }
859
860
            }).done(function(res) {
                totalPages = res.totalPages;
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
            });
        }

        function renderData(pagedData) {
            page = pagedData.number;
            renderPagination(pagedData);
            renderLinks(pagedData);
            renderTableBody(pagedData);
        }

        function renderPagination (pagedData) {
            var re = /\B(?=(\d{3})+(?!\d))/g;
            var totalElements = pagedData.totalElements.toString().replace(re, ",");
            var totalPages = pagedData.totalPages.toString().replace(re, ",");
            $('nav').find(".results").html(messages["accessions.number"].replace("{0}", totalElements));
            $('.pagination').find(".totalPages").html(messages["paged.ofPages"].replace("{0}", totalPages));
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
            var nextPage = $('.nextPage');
            var lastPage = $('.lastPage');
            var firstPage = $('.firstPage');
            var previousPage = $('.previousPage');

            if (page + 1 === 1) {
                firstPage.closest("li").addClass("disabled");
                previousPage.closest("li").addClass("disabled");
                firstPage.children().remove();
                firstPage.append($("<span aria-hidden='true'>&laquo;</span>"));
                previousPage.children().remove();
                previousPage.append($("<span aria-hidden='true'>&lsaquo;</span>"))
            } else {
                firstPage.closest("li").removeClass("disabled");
                previousPage.closest("li").removeClass("disabled");
                previousPage.children().remove();
                previousPage.append($("<span aria-hidden='true'/>"));
                firstPage.children().remove();
                firstPage.append($("<span aria-hidden='true' />"));
                setPageUrl(firstPage.children(), 1, Page.FIRST);
                setPageUrl(previousPage.children(), page === 0 ? 1 : page, Page.PREVIOUS);
            }
            if (page + 1 === pagedData.totalPages) {
                nextPage.closest("li").addClass("disabled");
                lastPage.closest("li").addClass("disabled");
                nextPage.children().remove();
                nextPage.append($("<span aria-hidden='true'>&rsaquo;</span>"));
                lastPage.children().remove();
                lastPage.append($("<span aria-hidden='true'>&raquo;</span>"));
            } else {
                nextPage.closest("li").removeClass("disabled");
                lastPage.closest("li").removeClass("disabled");
                lastPage.children().remove();
                lastPage.append($("<span aria-hidden='true'/>"));
                nextPage.children().remove();
                nextPage.append($("<span aria-hidden='true'/>"));
                setPageUrl(nextPage.children(), page + 2, Page.NEXT);
                setPageUrl(lastPage.children(), pagedData.totalPages, Page.LAST);
            }
916
917
            $(".pagination-input").find("input").val(page + 1);
            $("input[name='filter']").val(JSON.stringify(jsonData));
918
919
920
921

            refreshTickedAccessions();
        }

922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
        function applyFiltersWithPageNumber (page) {
            document.getElementById('loading-popup-id').style.display = "block";
            var filter = JSON.stringify(jsonData);
            var requestUrl = '//' + location.host + location.pathname + "/json" + ((page !== undefined ? ("?page=" + page + "&") : "?page=1&") + "filter=" + encodeURIComponent(filter));
            requestUrl += "&results=" + results;
            var displayUrl = requestUrl.replace('/json', '');
            window.history.pushState(requestUrl, '', displayUrl);
            $.ajax({
                beforeSend: function(xhrObj){
                    xhrObj.setRequestHeader("Content-Type","application/json");
                    xhrObj.setRequestHeader("Accept","application/json");
                },
                url: requestUrl,
                method: 'get',
                success: function (response) {
                    renderData(response);
                    document.getElementById('loading-popup-id').style.display = "none";
                    $.each($("select.column-changer"), function () {
                        $(this).change();
                    });
                },
                error: function (error) {
                    buildErrorPopup(error.responseJSON.message);
                    document.getElementById('error-loading-popup-id').style.display = "block";
                }
            }).done(function(res) {
                page = res.number;
                totalPages = res.totalPages;
            });
        }

        function buildErrorPopup(message) {
            $('.container-fluid')
                .append($('<div id="error-loading-popup-id"/>').addClass('error-loading-popup')
                    .append($('<div/>').addClass('error-loading-popup-content')
                        .append($('<span/>').addClass('close')
                            .append($('<span/>').addClass('glyphicon glyphicon-remove')))
                        .append($('<p/>').append(message))));
        }

962
963
964
965
966
967
968
969
970
971
972
973
        function refreshTickedAccessions() {
            $.ajax({
                url : '/sel/json/selection',
                type : 'GET',
                success : function(data) {
                    if (data.length > 0) {
                        for (var i = data.length - 1; i >= 0; i--) {
                            $('.sel[x-aid=' + data[i] + ']').addClass('picked');
                        }
                    }
                }
            });
974
975
        }

976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
        function setPageUrl (parentElement, pageNumber, pageSymbol) {
            var el;
            switch (pageSymbol) {
                case Page.PREVIOUS:
                    el = $("<a>&lsaquo;</a>");
                    break;
                case Page.FIRST:
                    el = $("<a>&laquo;</a>");
                    break;
                case Page.NEXT:
                    el = $("<a>&rsaquo;</a>");
                    break;
                case Page.LAST:
                    el = $("<a>&raquo;</a>");
                    break;
            }
            $(parentElement).append($(el).attr("href", "?page=" + pageNumber + "&filter=" + encodeURI(JSON.stringify(jsonData))));
993
994
995
        }

        function renderLinks (pagedData) {
Maxim's avatar
Maxim committed
996
            $("#shortLink").val('');
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
            var downloadLink = $("#downloadLink");
            if (pagedData.totalElements <= 200000) {
                downloadLink.show();
                $.each($("#downloadLink").find("input[name='filter']"), function () {
                    $(this).val(JSON.stringify(jsonData));
                });
            } else {
                downloadLink.hide();
            }
            var re = /filter=(.*)/;
            $("#overviewLink").attr("href", $("#overviewLink").attr("href").replace(re, "filter=" + encodeURIComponent(JSON.stringify(jsonData))));
            $("#mapLink").attr("href", $("#mapLink").attr("href").replace(re, "filter=" + encodeURIComponent(JSON.stringify(jsonData))));
        }

        function renderTableBody(pagedData) {
            $("table").find("tbody").remove();
            var tbody = $("<tbody/>");
Taisiya Glushko's avatar
Taisiya Glushko committed
1014
            rowsCopy = [];
1015
1016
1017
1018
1019
1020
1021
1022
1023
            for (var i = 0; i < pagedData.numberOfElements; i++) {
                var row = $("<tr/>", {
                    'class': "acn " + (i % 2 == 0 ? 'odd' : 'even') + (pagedData.content[i].historic ? ' historic-record' : '')
                });
                $("<p/>", {
                    text: (i + 1) + pagedData.size * pagedData.number
                }).appendTo($("<td/>", {
                    'class': "idx-col"
                }).appendTo(row));
Taisiya Glushko's avatar
Taisiya Glushko committed
1024
                $("<span/>", {
1025
1026
1027
                    'class': "sel",
                    'x-aid': pagedData.content[i].id,
                    'title': "<spring:message code="selection.checkbox" />"
Taisiya Glushko's avatar
Taisiya Glushko committed
1028
                }).appendTo($("<td/>").appendTo(row));
1029
1030
1031
1032
                $("<b/>", {
                    text: pagedData.content[i].acceNumb
                }).appendTo(
                $("<a/>", {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
1033
                    href: '<c:url value="/acn/id/" />' + pagedData.content[i].id
1034
1035
                }).appendTo($("<p/>").appendTo($("<td/>").appendTo(row))));

Taisiya Glushko's avatar
Taisiya Glushko committed
1036
                <c:forEach items="${selectedColumns}" var="col" varStatus="i">
1037
                    <c:choose>
1038
	                    <c:when test="${col eq 'doi'}">
Maxym Borodenko's avatar
Maxym Borodenko committed
1039
1040
1041
1042
                            $("<a/>", { href: '<c:url value="/" />' + pagedData.content[i].doi, text: pagedData.content[i].doi })
                                .appendTo($("<p/>")
                                    .appendTo($("<td/>", { 'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>" })
                                        .appendTo(row)));
1043
1044
		                </c:when>
                		<c:when test="${col eq 'taxonomy.sciName'}">
1045
1046
1047
                            $("<span/>", {
                                dir: 'ltr',
                                'class': 'sci-name',
Matija Obreza's avatar
Matija Obreza committed
1048
1049
1050
                                html: pagedData.content[i].taxonomy.sciNameHtml
                            }).appendTo($("<p></p>").appendTo($("<td class='<c:if test="${i.count ge 2}">hidden-xs</c:if> <c:if test="${i.count gt 2}">hidden-sm</c:if>'></td>")
                            .appendTo(row)));
1051
1052
1053
                        </c:when>
                        <c:when test="${col eq 'orgCty'}">
                            $("<p/>", {
Maxym Borodenko's avatar
Maxym Borodenko committed
1054
                                text: pagedData.content[i].orgCty !== null ? messages['geo.iso3166-3.' + pagedData.content[i].orgCty.iso3] : ""
1055
                            }).appendTo($("<td/>", {
Taisiya Glushko's avatar
Taisiya Glushko committed
1056
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
1057
1058
                            }).appendTo(row));
                        </c:when>
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
                        <c:when test="${col eq 'acceName'}">
                        $("<p/>", {
                          	text: pagedData.content[i].acceName
                        }).appendTo($("<td/>", {
                            'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
                        }).appendTo(row));
                    		</c:when>
                        <c:when test="${col eq 'donorNumb'}">
                        $("<p/>", {
                          	text: pagedData.content[i].donorNumb
                        }).appendTo($("<td/>", {
                            'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
                        }).appendTo(row));
                    		</c:when>
1073
1074
1075
1076
                        <c:when test="${col eq 'sampStat'}">
                            $("<p/>", {
                                text: messages["accession.sampleStatus." + pagedData.content[i].sampStat]
                            }).appendTo($("<td/>", {
Taisiya Glushko's avatar
Taisiya Glushko committed
1077
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
1078
1079
1080
1081
                            }).appendTo(row));
                        </c:when>
                        <c:when test="${col eq 'institute.code'}">
                            $("<a/>", {
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
1082
                                href: '<c:url value="/wiews/" />' + pagedData.content[i].institute.code,
1083
                                text: pagedData.content[i].institute.code
Taisiya Glushko's avatar
Taisiya Glushko committed
1084
1085
                            }).appendTo($("<p></p>").appendTo($("<td/>", {
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
1086
1087
1088
                            }).appendTo(row)));
                        </c:when>
                        <c:when test="${col eq 'taxonomy.genus'}">
Matija Obreza's avatar
Matija Obreza committed
1089
1090
                        	$("<i/>", { text: pagedData.content[i].taxonomy.genus })
                            .appendTo($("<span/>", {
1091
                                dir: "ltr",
Matija Obreza's avatar
Matija Obreza committed
1092
                                'class': "sci-name"
Taisiya Glushko's avatar
Taisiya Glushko committed
1093
1094
                            }).appendTo($("<p></p>").appendTo($("<td/>", {
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
Matija Obreza's avatar
Matija Obreza committed
1095
                            }).appendTo(row))));
1096
1097
                        </c:when>
                        <c:when test="${col eq 'taxonomy.species'}">
Matija Obreza's avatar
Matija Obreza committed
1098
1099
1100
1101
1102
	                    	$("<i/>", { text: pagedData.content[i].taxonomy.species })
	                        .appendTo($("<span/>", {
	                            dir: "ltr",
	                            'class': "sci-name"
	                        }).appendTo($("<p></p>").appendTo($("<td/>", {
Taisiya Glushko's avatar
Taisiya Glushko committed
1103
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
Matija Obreza's avatar
Matija Obreza committed
1104
                            }).appendTo(row))));
1105
1106
                        </c:when>
                        <c:when test="${col eq 'taxonomy.subtaxa'}">
Matija Obreza's avatar
Matija Obreza committed
1107
1108
1109
1110
1111
	                        $("<i/>", { text: pagedData.content[i].taxonomy.subtaxa })
	                        .appendTo($("<span/>", {
	                            dir: "ltr",
	                            'class': "sci-name"
	                        }).appendTo($("<p></p>").appendTo($("<td/>", {
Taisiya Glushko's avatar
Taisiya Glushko committed
1112
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
Matija Obreza's avatar
Matija Obreza committed
1113
                            }).appendTo(row))));
1114
1115
                        </c:when>
                        <c:when test="${col eq 'crops'}">
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
1116
                            var cropNamesTd = $("<td/>", {
Taisiya Glushko's avatar
Taisiya Glushko committed
1117
                                'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
1118
1119
1120
1121
1122
1123
1124
                            });
                            if (pagedData.content[i].crops != null) {
                                $.each(pagedData.content[i].crops, function (index, shortName) {
                                    $("<a/>", {
                                        href: '<c:url value="/c/" />' + shortName,
                                        text: cropNames[shortName]
                                    }).appendTo(cropNamesTd);
1125
1126
                                });
                            }
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
1127
                            cropNamesTd.appendTo(row);
1128
                        </c:when>
1129
1130
1131
1132
1133
1134
1135
1136
1137
                        <c:when test="${col eq 'cropName'}">
                        $("<span/>", {
                            dir: "ltr",
                            'class': "sci-name",
                            text: pagedData.content[i].cropName
                        }).appendTo($("<p></p>").appendTo($("<td/>", {
                            'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
                        }).appendTo(row)));
                    	</c:when>
1138
1139
1140
1141
1142
1143
1144
                    	 <c:when test="${col eq 'pdci.score'}">
	                    	 $("<span/>", {
	                         text: ''+pagedData.content[i].pdciScore
		                     }).appendTo($("<p></p>").appendTo($("<td/>", {
		                         'class': "notimportant <c:if test='${i.count ge 2}'>hidden-xs</c:if> <c:if test='${i.count gt 2}'>hidden-sm</c:if>"
		                     }).appendTo(row)));
                   			</c:when>
Maxim's avatar
Maxim committed
1145
1146
1147
1148
1149
1150
1151
1152
                        <c:when test="${col eq 'geo.latitudeAndLongitude'}">
                        var geoLatitude = "";
                        var geoLongitude = "";
                        if (pagedData.content[i].geo != null) {
                            geoLatitude = pagedData.content[i].geo.latitude;
                            geoLongitude = pagedData.content[i].geo.longitude;
                        }
                        var geoText = "";
Maxim's avatar
Maxim committed
1153
                        if (geoLatitude !== null && geoLatitude.toString() != "") {
Maxim's avatar
Maxim committed
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
                            geoText = geoLatitude + ", " + geoLongitude
                        }
                        $("<span/>", {
                            dir: "ltr",
                            'class': "sci-name",
                            text: geoText
                        }).appendTo($("<p></p>").appendTo($("<td/&g