Project

General

Profile

1 7656 leinfelder
/**
2
 * Performs the search
3
 */
4
function doSearch(serviceURL, searchFormId, browseAll) {
5
	var solrQuery = getSolrQuery(searchFormId);
6
	//alert(solrQuery);
7
	var url = serviceURL + "/" + solrQuery;
8
	// go directly there!
9
	document.location = url;
10 3469 walbridge
}
11
12 7656 leinfelder
/**
13
 * Constructs the SOLR query to use
14
 */
15
function getSolrQuery(searchFormId, browseAll) {
16
	var submitFormObj = document.getElementById(searchFormId);
17 3469 walbridge
    var searchString = trim(submitFormObj.searchstring.value);
18 7656 leinfelder
    if (browseAll) {
19
    	searchString = "";
20
    }
21
    var qformat = submitFormObj.qformat.value;
22 3469 walbridge
23
    if (searchString=="") {
24 7537 leinfelder
        if (confirm("Show *all* data?")) {
25 7656 leinfelder
            searchString = "*";
26 3469 walbridge
        } else {
27
            return false;
28
        }
29
    }
30
31 7656 leinfelder
    var formats =
32
    	"("
33
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.1.1\""
34
        +" OR "
35
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.1.0\""
36
        +" OR "
37
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.0.1\""
38
        +" OR "
39
        +"formatId: \"eml\\://ecoinformatics.org/eml-2.0.0\""
40
        +" OR "
41
        +"formatId: \"-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN\""
42
        +" OR "
43
        +"formatId: \"-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN\""
44
        +" OR "
45
        +"formatId: \"-//NCEAS//resource//EN\""
46
        +" OR "
47
        +"formatId: \"-//NCEAS//eml-dataset//EN\""
48
        +" OR "
49
        +"formatId: \"metadata\""
50
    	+")";
51
52
	var solrQuery = "q="
53
		+ searchString
54
		+" AND "
55
    	+ formats
56
    	+" AND "
57
    	+"("
58
            +"contactOrganization: \"National Center for Ecological Analysis and Synthesis\""
59
        +")"
60
        +"&wt=" + qformat;
61
62
    	solrQuery = encodeURIComponent(solrQuery);
63
64
    return solrQuery;
65 3469 walbridge
}
66
67 7656 leinfelder
function trim(stringToTrim) {
68
    return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
69 3742 leinfelder
}