source: trunk/grails-app/views/studyCompare/pages/_page_one.gsp @ 2237

Last change on this file since 2237 was 2237, checked in by work@…, 12 years ago
  • improved initial study compare page gives visual feedback
File size: 2.4 KB
Line 
1<%
2/**
3 * first wizard page / tab
4 *
5 * @author Jeroen Wesbeek
6 * @since  20120123
7 *
8 * Revision information:
9 * $Rev:  67319 $
10 * $Author:  duh $
11 * $Date:  2010-12-22 17:45:42 +0100 (Wed, 22 Dec 2010) $
12 */
13%>
14<af:page>
15<script type="text/javascript">
16var criteria = {};
17
18handleCheckEvent();
19
20function handleCheckEvent(event) {
21        var check = $(event);
22        var value = check.attr('value');
23        var parent = check.parent().parent();
24        var parentId = parent.attr('id');
25
26        if (criteria[parentId] == undefined) criteria[parentId] = [];
27
28        // add or remove data
29        if (check.is(':checked') && criteria[parentId].indexOf(value) < 0) {
30                criteria[parentId].push(value);
31        } else if (criteria[parentId].indexOf(value) >= 0) {
32                criteria[parentId].splice(criteria[parentId].indexOf(value),1);
33        }
34
35        // fetch matched studies
36        $('#studyOverview').html('').addClass('waitForLoad');//.removeClass('waitForLoad');
37    $('#matchedStudies').html('').addClass('waitForLoad');
38    $.getJSON(
39                baseUrl + "/ajax/studies",
40                criteria,
41                function(data) {
42            // update matched study feedback
43            $('#matchedStudies').html(data.matched+' of '+data.total+' readable studies matched your criteria').removeClass('waitForLoad');
44
45            // show matching studies
46                        var studies = '';
47                        for (var i=0; i<data.studies.length; i++) {
48                                studies = studies + data.studies[i] + '<br/>';
49                        }
50                        $('#studyOverview').removeClass('waitForLoad').html(studies);
51
52            // (un)mark property checkboxes
53            $.each(['uniqueSpecies','uniqueEventTemplateNames','uniqueSamplingEventTemplateNames','modules'],function(index,property) {
54                $('input:checkbox[name="'+property+'[]"]').each(function() {
55                    element = $(this);
56                    if (data[property][ element.val() ]) {
57                        element.parent().removeClass('dimmed');
58                    } else {
59                        element.parent().addClass('dimmed');
60                    }
61                });
62            });
63                }
64        );
65}
66</script>
67
68<div class="selector">
69        <div name="species" id="uniqueSpecies" class="ajax"></div>
70        <div name="event templates" id="uniqueEventTemplateNames" class="ajax"></div>
71        <div name="sampling event templates" id="uniqueSamplingEventTemplateNames" class="ajax"></div>
72    <div name="modules" id="modules" class="ajax"></div>
73</div>
74<div id="matchedStudies"></div>
75<div id="studyOverview"></div>
76
77</af:page>
Note: See TracBrowser for help on using the repository browser.