Project

General

Profile

1
function trim(stringToTrim) {
2
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
3
}
4

    
5
function checkSearch(submitFormObj) {
6
    var searchString = trim(submitFormObj.searchstring.value);
7
    var checkBox = document.getElementById("searchAll");
8

    
9
    if (searchString=="") {
10
        if (confirm("Show *all* data in the KNB?")) {
11
            searchString = "%";
12
        } else {
13
            return false;
14
        }
15
    }
16

    
17
    if (!checkBox.checked && searchString!="%") {
18
        submitFormObj.query.value = "<pathquery version=\"1.2\">"
19
            +"<querytitle>Web-Search</querytitle>"
20
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
21
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>"
22
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN</returndoctype>"
23
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN</returndoctype>"
24
            +"<returndoctype>-//NCEAS//resource//EN</returndoctype>"
25
            +"<returndoctype>-//NCEAS//eml-dataset//EN</returndoctype>"
26
            +"<returndoctype>metadata</returndoctype>"
27
            +"<returnfield>originator/individualName/surName</returnfield>"
28
            +"<returnfield>originator/individualName/givenName</returnfield>"
29
            +"<returnfield>creator/individualName/surName</returnfield>"
30
            +"<returnfield>creator/individualName/givenName</returnfield>"
31
            +"<returnfield>originator/organizationName</returnfield>"
32
            +"<returnfield>creator/organizationName</returnfield>"
33
            +"<returnfield>dataset/title</returnfield>"
34
            +"<returnfield>keyword</returnfield>"
35
            //fgdc fields
36
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
37
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
38
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
39
            +"<querygroup operator=\"INTERSECT\">"
40
            	+"<querygroup operator=\"UNION\">"
41
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
42
	                    +"<value>National Center for Ecological Analysis and Synthesis</value>"
43
	                    +"<pathexpr>organizationName</pathexpr>"
44
	                +"</queryterm>"
45
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
46
	                    //+"<value>%</value>"
47
	                    +"<value>National Center for Ecological Analysis and Synthesis</value>"	                    
48
	                    +"<pathexpr>placekey</pathexpr>"
49
	                +"</queryterm>"
50
                +"</querygroup>"
51
                +"<querygroup operator=\"UNION\">"
52
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
53
                        +"<value>" + searchString + "</value>"
54
                        +"<pathexpr>surName</pathexpr>"
55
                    +"</queryterm>"
56
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
57
                        +"<value>" + searchString + "</value>"
58
                        +"<pathexpr>givenName</pathexpr>"
59
                    +"</queryterm>"
60
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
61
                        +"<value>" + searchString + "</value>"
62
                        +"<pathexpr>keyword</pathexpr>"
63
                    +"</queryterm>"
64
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
65
                        +"<value>" + searchString + "</value>"
66
                        +"<pathexpr>para</pathexpr>"
67
                    +"</queryterm>"
68
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
69
                        +"<value>" + searchString + "</value>"
70
                        +"<pathexpr>geographicDescription</pathexpr>"
71
                    +"</queryterm>"
72
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
73
                        +"<value>" + searchString + "</value>"
74
                        +"<pathexpr>literalLayout</pathexpr>"
75
                    +"</queryterm>"
76
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
77
                        +"<value>" + searchString + "</value>"
78
                        +"<pathexpr>title</pathexpr>"
79
                    +"</queryterm>"
80
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
81
                        +"<value>" + searchString + "</value>"
82
                        +"<pathexpr>@packageId</pathexpr>"
83
                    +"</queryterm>"
84
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
85
                        +"<value>" + searchString + "</value>"
86
                        +"<pathexpr>abstract/para</pathexpr>"
87
                    +"</queryterm>"
88
                    
89
                    //FGDC fields
90
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
91
                        +"<value>" + searchString + "</value>"
92
                        +"<pathexpr>abstract</pathexpr>"
93
                    +"</queryterm>"
94
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
95
                        +"<value>" + searchString + "</value>"
96
                        +"<pathexpr>idinfo/citation/citeinfo/title</pathexpr>"
97
                    +"</queryterm>"
98
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
99
                        +"<value>" + searchString + "</value>"
100
                        +"<pathexpr>idinfo/citation/citeinfo/origin</pathexpr>"
101
                    +"</queryterm>"
102
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
103
                        +"<value>" + searchString + "</value>"
104
                        +"<pathexpr>idinfo/keywords/theme/themekey</pathexpr>"
105
                    +"</queryterm>"
106
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
107
                        +"<value>" + searchString + "</value>"
108
                        +"<pathexpr>placekey</pathexpr>"
109
                    +"</queryterm>"
110
                +"</querygroup>"
111
            +"</querygroup>"
112
            +"</pathquery>";
113

    
114
    } else {
115
        queryTermString = "";
116
        if (searchString != "%"){
117
            queryTermString = "<queryterm searchmode=\"contains\" casesensitive=\"false\">"
118
                                  +"<value>" + searchString + "</value>"
119
                              +"</queryterm>";
120
        }
121
        submitFormObj.query.value = "<pathquery version=\"1.2\">"
122
            +"<querytitle>Web-Search</querytitle>"
123
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
124
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>"
125
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN</returndoctype>"
126
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN</returndoctype>"
127
            +"<returndoctype>-//NCEAS//resource//EN</returndoctype>"
128
            +"<returndoctype>-//NCEAS//eml-dataset//EN</returndoctype>"
129
            +"<returndoctype>metadata</returndoctype>"
130
            +"<returnfield>originator/individualName/surName</returnfield>"
131
            +"<returnfield>originator/individualName/givenName</returnfield>"
132
            +"<returnfield>creator/individualName/surName</returnfield>"
133
            +"<returnfield>creator/individualName/givenName</returnfield>"
134
            +"<returnfield>originator/organizationName</returnfield>"
135
            +"<returnfield>creator/organizationName</returnfield>"
136
            +"<returnfield>dataset/title</returnfield>"
137
            +"<returnfield>keyword</returnfield>"
138
            //fgdc fields
139
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
140
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
141
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
142
            +"<querygroup operator=\"INTERSECT\">"
143
                +"<querygroup operator=\"UNION\">"
144
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
145
	                    +"<value>National Center for Ecological Analysis and Synthesis</value>"
146
	                    +"<pathexpr>organizationName</pathexpr>"
147
	                +"</queryterm>"
148
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
149
	                    //+"<value>%</value>"
150
	                    +"<value>National Center for Ecological Analysis and Synthesis</value>"	                    
151
	                    +"<pathexpr>placekey</pathexpr>"
152
	                +"</queryterm>"
153
                +"</querygroup>"
154
                + queryTermString
155
            +"</querygroup>"
156
            +"</pathquery>";
157

    
158
    }
159
    return true;
160
}
161

    
162
function browseAll(searchFormId) {
163
	var searchForm = document.getElementById(searchFormId);
164
	var searchString = searchForm.searchstring;
165
    var checkBox = document.getElementById("searchAll");
166
    searchString.value="";
167
    checkBox.checked = true;
168
    if (checkSearch(searchForm)) {
169
		searchForm.submit();
170
	}
171

    
172
}
173

    
174
function searchAll(){
175
    var checkBox = document.getElementById("searchCheckBox");
176
    if (checkBox.checked == true) {
177
        alert("You have selected to search all possible existing fields. This search will take longer.");
178
    }
179
}
(11-11/12)