Project

General

Profile

1
function encodeXML(theString) {
2
	return theString.replace(/&/g, '&')
3
		.replace(/</g, '&lt;')
4
		.replace(/>/g, '&gt;')
5
		.replace(/"/g, '&quot;');
6
}
7

    
8
function trim(stringToTrim) {
9
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
10
}
11

    
12
function checkSearch(submitFormObj) {
13
    var searchString = trim(submitFormObj.searchstring.value);
14
	searchString = encodeXML(searchString);
15
    var checkBox = document.getElementById("searchAll");
16

    
17
    if (searchString=="") {
18
        if (confirm("Show *all* data in the PARC Catalog?")) {
19
            searchString = "%";
20
        } else {
21
            return false;
22
        }
23
    }
24

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

    
107
    } else {
108
        queryTermString = "";
109
        if (searchString != "%"){
110
            queryTermString = "<queryterm searchmode=\"contains\" casesensitive=\"false\">"
111
                                  +"<value>" + searchString + "</value>"
112
                              +"</queryterm>";
113
        }
114
        submitFormObj.query.value = "<pathquery version=\"1.2\">"
115
            +"<querytitle>Web-Search</querytitle>"
116
            +"<returndoctype>eml://ecoinformatics.org/eml-2.1.1</returndoctype>"
117
            +"<returndoctype>eml://ecoinformatics.org/eml-2.1.0</returndoctype>"
118
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
119
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>"
120
            +"<returndoctype>metadata</returndoctype>"
121
            +"<returnfield>originator/individualName/surName</returnfield>"
122
            +"<returnfield>originator/individualName/givenName</returnfield>"
123
            +"<returnfield>creator/individualName/surName</returnfield>"
124
            +"<returnfield>creator/individualName/givenName</returnfield>"
125
            +"<returnfield>originator/organizationName</returnfield>"
126
            +"<returnfield>creator/organizationName</returnfield>"
127
            +"<returnfield>dataset/title</returnfield>"
128
            +"<returnfield>dataset/title/value</returnfield>"
129
            +"<returnfield>keyword</returnfield>"
130
            +"<returnfield>keyword/value</returnfield>"
131
            //fgdc fields
132
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
133
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
134
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
135
            +"<querygroup operator=\"INTERSECT\">"
136
                +"<querygroup operator=\"UNION\">"
137
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
138
	                    +"<value>Palmyra Atoll Research Consortium</value>"
139
	                    +"<pathexpr>creator/organizationName</pathexpr>"
140
	                +"</queryterm>"
141
                +"</querygroup>"
142
                + queryTermString
143
            +"</querygroup>"
144
            +"</pathquery>";
145

    
146
    }
147
    return true;
148
}
149

    
150
function browseAll(searchFormId) {
151
	var searchForm = document.getElementById(searchFormId);
152
	var searchString = searchForm.searchstring;
153
    var checkBox = document.getElementById("searchAll");
154
    searchString.value="";
155
    checkBox.checked = true;
156
    if (checkSearch(searchForm)) {
157
		searchForm.submit();
158
	}
159

    
160
}
161

    
162
function searchAll(){
163
    var checkBox = document.getElementById("searchCheckBox");
164
    if (checkBox.checked == true) {
165
        alert("You have selected to search all possible existing fields. This search will take longer.");
166
    }
167
}
(13-13/14)