Project

General

Profile

« Previous | Next » 

Revision 5129

Here are the three javascript libraries associated with the PARC skin. The only real changes are in the search.js file, where metacat searches have absolute XPaths in the search criteria. The return fields remain as relative XPaths to be consistent with the rendering code for the skin.

View differences:

lib/style/skins/parc/parc.js
1
/*
2
  *   '$RCSfile$'
3
  *     Purpose: Default javascript library for PARC project web pages 
4
  *              Using this library rather than placing javascript directly in 
5
  *              the PARC web documents allows us to globally change the 
6
  *              functions of the entire site in one easy place.
7
  *   Copyright: 2000 Regents of the University of California and the
8
  *               National Center for Ecological Analysis and Synthesis
9
  *     Authors: Matt Jones, Christopher Jones
10
  *
11
  *    '$Author: leinfelder $'
12
  *      '$Date: 2008-06-17 14:16:32 -0600 (Tue, 17 Jun 2008) $'
13
  *  '$Revision: 4006 $'
14
  *
15
  * This program is free software; you can redistribute it and/or modify
16
  * it under the terms of the GNU General Public License as published by
17
  * the Free Software Foundation; either version 2 of the License, or
18
  * (at your option) any later version.
19
  *
20
  * This program is distributed in the hope that it will be useful,
21
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
  * GNU General Public License for more details.
24
  *
25
  * You should have received a copy of the GNU General Public License
26
  * along with this program; if not, write to the Free Software
27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
  */
29

  
30
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
31
 * * * * * *  CONFIGURATION SETTINGS - EDIT THESE FOR YOUR ENVIRONMENT * * * * 
32
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
33

  
34
 
35
/* loginStatus: Uses XHR request to check for current session login status */
36
function loginStatus(servletPath, cgiPrefix){
37
    var httpRequest = false;
38
    try {
39
          httpRequest = new XMLHttpRequest();
40
    } catch (trymicrosoft) {
41
        try {
42
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
43
        } catch (othermicrosoft) {
44
            try {
45
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
46
            } catch (failed) {
47
                request = null;
48
            }
49
        }
50
    }
51

  
52
    if (!httpRequest){
53
        alert("no httpRequest object");
54
        return false;
55
    }
56

  
57
    httpRequest.onreadystatechange = function() {
58
        if(httpRequest.readyState == 4) {
59
            if (httpRequest.status == 200) {
60
                var response = httpRequest.responseText;
61
                var login_block = document.getElementById('login_block');
62

  
63
                if (response.indexOf("public") > 0) {
64
                    login_block.innerHTML = '<a href="' + cgiPrefix + '/register-dataset.cgi?cfg=parc&' +
65
                                            'stage=loginform">Login</a>';
66
                }
67
                else
68
                {
69
                    login_block.innerHTML = '<a href="' + cgiPrefix + '/register-dataset.cgi?cfg=parc&' +
70
                                            'stage=logout">Logout</a>';
71
                }
72
            }
73
        }
74
    }
75

  
76
    httpRequest.open("GET", servletPath + "?action=getloggedinuserinfo", true);
77
    httpRequest.send(null);
78
}
0 79

  
lib/style/skins/parc/search.js
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 PARC Catalog?")) {
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.1.0</returndoctype>"
21
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
22
            +"<returndoctype>metadata</returndoctype>"
23
            +"<returnfield>originator/individualName/surName</returnfield>"
24
            +"<returnfield>originator/individualName/givenName</returnfield>"
25
            +"<returnfield>creator/individualName/surName</returnfield>"
26
            +"<returnfield>creator/individualName/givenName</returnfield>"
27
            +"<returnfield>originator/organizationName</returnfield>"
28
            +"<returnfield>creator/organizationName</returnfield>"
29
            +"<returnfield>dataset/title</returnfield>"
30
            +"<returnfield>keyword</returnfield>"
31
            //fgdc fields
32
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
33
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
34
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
35
            +"<querygroup operator=\"INTERSECT\">"
36
            	+"<querygroup operator=\"UNION\">"
37
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
38
	                    +"<value>Palmyra Atoll Research Consortium</value>"
39
	                    +"<pathexpr>/eml/dataset/creator/organizationName</pathexpr>"
40
	                +"</queryterm>"
41
                +"</querygroup>"
42
                +"<querygroup operator=\"UNION\">"
43
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
44
                        +"<value>" + searchString + "</value>"
45
                        +"<pathexpr>/eml/dataset/creator/individualName/surName</pathexpr>"
46
                    +"</queryterm>"
47
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
48
                        +"<value>" + searchString + "</value>"
49
                        +"<pathexpr>/eml/dataset/creator/individualName/givenName</pathexpr>"
50
                    +"</queryterm>"
51
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
52
                        +"<value>" + searchString + "</value>"
53
                        +"<pathexpr>/eml/dataset/keywordSet/keyword</pathexpr>"
54
                    +"</queryterm>"
55
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
56
                        +"<value>" + searchString + "</value>"
57
                        +"<pathexpr>para</pathexpr>"
58
                    +"</queryterm>"
59
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
60
                        +"<value>" + searchString + "</value>"
61
                        +"<pathexpr>/eml/dataset/coverage/geographicCoverage/geographicDescription</pathexpr>"
62
                    +"</queryterm>"
63
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
64
                        +"<value>" + searchString + "</value>"
65
                        +"<pathexpr>literalLayout</pathexpr>"
66
                    +"</queryterm>"
67
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
68
                        +"<value>" + searchString + "</value>"
69
                        +"<pathexpr>/eml/dataset/title</pathexpr>"
70
                    +"</queryterm>"
71
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
72
                        +"<value>" + searchString + "</value>"
73
                        +"<pathexpr>/eml/@packageId</pathexpr>"
74
                    +"</queryterm>"
75
                    +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
76
                        +"<value>" + searchString + "</value>"
77
                        +"<pathexpr>/eml/dataset/abstract/para</pathexpr>"
78
                    +"</queryterm>"
79
                +"</querygroup>"
80
            +"</querygroup>"
81
            +"</pathquery>";
82

  
83
    } else {
84
        queryTermString = "";
85
        if (searchString != "%"){
86
            queryTermString = "<queryterm searchmode=\"contains\" casesensitive=\"false\">"
87
                                  +"<value>" + searchString + "</value>"
88
                              +"</queryterm>";
89
        }
90
        submitFormObj.query.value = "<pathquery version=\"1.2\">"
91
            +"<querytitle>Web-Search</querytitle>"
92
            +"<returndoctype>eml://ecoinformatics.org/eml-2.1.0</returndoctype>"
93
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.1</returndoctype>"
94
            +"<returndoctype>eml://ecoinformatics.org/eml-2.0.0</returndoctype>"
95
            +"<returndoctype>metadata</returndoctype>"
96
            +"<returnfield>originator/individualName/surName</returnfield>"
97
            +"<returnfield>originator/individualName/givenName</returnfield>"
98
            +"<returnfield>creator/individualName/surName</returnfield>"
99
            +"<returnfield>creator/individualName/givenName</returnfield>"
100
            +"<returnfield>originator/organizationName</returnfield>"
101
            +"<returnfield>creator/organizationName</returnfield>"
102
            +"<returnfield>dataset/title</returnfield>"
103
            +"<returnfield>keyword</returnfield>"
104
            //fgdc fields
105
            +"<returnfield>idinfo/citation/citeinfo/title</returnfield>"
106
            +"<returnfield>idinfo/citation/citeinfo/origin</returnfield>"
107
			+"<returnfield>idinfo/keywords/theme/themekey</returnfield>"
108
            +"<querygroup operator=\"INTERSECT\">"
109
                +"<querygroup operator=\"UNION\">"
110
	                +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
111
	                    +"<value>Palmyra Atoll Research Consortium</value>"
112
	                    +"<pathexpr>/eml/dataset/creator/organizationName</pathexpr>"
113
	                +"</queryterm>"
114
                +"</querygroup>"
115
                + queryTermString
116
            +"</querygroup>"
117
            +"</pathquery>";
118

  
119
    }
120
    return true;
121
}
122

  
123
function browseAll(searchFormId) {
124
	var searchForm = document.getElementById(searchFormId);
125
	var searchString = searchForm.searchstring;
126
    var checkBox = document.getElementById("searchAll");
127
    searchString.value="";
128
    checkBox.checked = true;
129
    if (checkSearch(searchForm)) {
130
		searchForm.submit();
131
	}
132

  
133
}
134

  
135
function searchAll(){
136
    var checkBox = document.getElementById("searchCheckBox");
137
    if (checkBox.checked == true) {
138
        alert("You have selected to search all possible existing fields. This search will take longer.");
139
    }
140
}
0 141

  
lib/style/skins/parc/navigation.js
1
sfHover = function() {
2
	var sfEls = document.getElementById("main_nav").getElementsByTagName("li");
3
	
4
	for (var i=0; i<sfEls.length; i++) {
5
		sfEls[i].onmouseover=function() {
6
			this.className+=" sfhover";
7
		}
8
		sfEls[i].onmouseout=function() {
9
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
10
		}
11
	}
12
}
13

  
14
if (window.attachEvent) window.attachEvent("onload", sfHover);
0 15

  

Also available in: Unified diff