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
	                    +"<pathexpr>placekey</pathexpr>"
48
	                +"</queryterm>"
49
                +"</querygroup>"
50
                +"<querygroup operator=\"UNION\">"
51
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
52
                        +"<value>" + searchString + "</value>"
53
                        +"<pathexpr>surName</pathexpr>"
54
                    +"</queryterm>"
55
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
56
                        +"<value>" + searchString + "</value>"
57
                        +"<pathexpr>givenName</pathexpr>"
58
                    +"</queryterm>"
59
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
60
                        +"<value>" + searchString + "</value>"
61
                        +"<pathexpr>keyword</pathexpr>"
62
                    +"</queryterm>"
63
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
64
                        +"<value>" + searchString + "</value>"
65
                        +"<pathexpr>para</pathexpr>"
66
                    +"</queryterm>"
67
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
68
                        +"<value>" + searchString + "</value>"
69
                        +"<pathexpr>geographicDescription</pathexpr>"
70
                    +"</queryterm>"
71
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
72
                        +"<value>" + searchString + "</value>"
73
                        +"<pathexpr>literalLayout</pathexpr>"
74
                    +"</queryterm>"
75
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
76
                        +"<value>" + searchString + "</value>"
77
                        +"<pathexpr>title</pathexpr>"
78
                    +"</queryterm>"
79
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
80
                        +"<value>" + searchString + "</value>"
81
                        +"<pathexpr>@packageId</pathexpr>"
82
                    +"</queryterm>"
83
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
84
                        +"<value>" + searchString + "</value>"
85
                        +"<pathexpr>abstract/para</pathexpr>"
86
                    +"</queryterm>"
87
                +"</querygroup>"
88
            +"</querygroup>"
89
            +"</pathquery>";
90

    
91
    } else {
92
        queryTermString = "";
93
        if (searchString != "%"){
94
            queryTermString = "<queryterm searchmode=\"contains\" casesensitive=\"false\">"
95
                                  +"<value>" + searchString + "</value>"
96
                              +"</queryterm>";
97
        }
98
        submitFormObj.query.value = "<pathquery version=\"1.2\">"
99
            +"<querytitle>Web-Search</querytitle>"
100
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
101
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>"
102
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN</returndoctype>"
103
            +"<returndoctype>-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN</returndoctype>"
104
            +"<returndoctype>-//NCEAS//resource//EN</returndoctype>"
105
            +"<returndoctype>-//NCEAS//eml-dataset//EN</returndoctype>"
106
            +"<returndoctype>metadata</returndoctype>"
107
            +"<returnfield>originator/individualName/surName</returnfield>"
108
            +"<returnfield>originator/individualName/givenName</returnfield>"
109
            +"<returnfield>creator/individualName/surName</returnfield>"
110
            +"<returnfield>creator/individualName/givenName</returnfield>"
111
            +"<returnfield>originator/organizationName</returnfield>"
112
            +"<returnfield>creator/organizationName</returnfield>"
113
            +"<returnfield>dataset/title</returnfield>"
114
            +"<returnfield>keyword</returnfield>"
115
            //fgdc fields
116
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
117
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
118
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
119
            +"<querygroup operator=\"INTERSECT\">"
120
                +"<querygroup operator=\"UNION\">"
121
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
122
	                    +"<value>National Center for Ecological Analysis and Synthesis</value>"
123
	                    +"<pathexpr>organizationName</pathexpr>"
124
	                +"</queryterm>"
125
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
126
	                    +"<value>%</value>"
127
	                    +"<pathexpr>placekey</pathexpr>"
128
	                +"</queryterm>"
129
                +"</querygroup>"
130
                + queryTermString
131
            +"</querygroup>"
132
            +"</pathquery>";
133

    
134
    }
135
    return true;
136
}
137

    
138
function browseAll(searchFormId) {
139
	var searchForm = document.getElementById(searchFormId);
140
	var searchString = searchForm.searchstring;
141
    var checkBox = document.getElementById("searchAll");
142
    searchString.value="";
143
    checkBox.checked = true;
144
    if (checkSearch(searchForm)) {
145
		searchForm.submit();
146
	}
147

    
148
}
149

    
150
function searchAll(){
151
    var checkBox = document.getElementById("searchCheckBox");
152
    if (checkBox.checked == true) {
153
        alert("You have selected to search all possible existing fields. This search will take longer.");
154
    }
155
}
(11-11/12)