Project

General

Profile

1 1976 jones
 /*
2
  *   '$RCSfile$'
3
  *     Purpose: Default style sheet for KNB project web pages
4
  *              Using this stylesheet rather than placing styles directly in
5
  *              the KNB web documents allows us to globally change the
6
  *              formatting styles 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
10
  *
11
  *    '$Author$'
12
  *      '$Date$'
13
  *  '$Revision$'
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 3596 walbridge
/* loginStatus: Uses XHR request to check for current session login status */
36 3734 leinfelder
function loginStatus(servletPath, cgiPrefix){
37 3596 walbridge
    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 1976 jones
52 3596 walbridge
    if (!httpRequest){
53
        alert("no httpRequest object");
54
        return false;
55
    }
56 1976 jones
57 3596 walbridge
    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 1976 jones
63 3596 walbridge
                if (response.indexOf("public") > 0) {
64 3734 leinfelder
                    login_block.innerHTML = '<a href="' + cgiPrefix + '/register-dataset.cgi?cfg=nceas&' +
65 3596 walbridge
                                            'stage=loginform">Login</a>';
66
                }
67
                else
68
                {
69 3734 leinfelder
                    login_block.innerHTML = '<a href="' + cgiPrefix + '/register-dataset.cgi?cfg=nceas&' +
70 3596 walbridge
                                            'stage=logout">Logout</a>';
71
                }
72
            }
73
        }
74
    }
75 1976 jones
76 3734 leinfelder
    httpRequest.open("GET", servletPath + "?action=getloggedinuserinfo", true);
77 3596 walbridge
    httpRequest.send(null);
78
}