source: tapas/web/resources/templates/templateEther_script.jsp @ 416

Last change on this file since 416 was 416, checked in by vmipsl, 12 years ago

User : ajout laboratoire & pays
BO : idem
Création compte : idem
DataProtocole?
Clean accent properties
Language

File size: 5.9 KB
Line 
1<%@ page import="com.ether.WebHelper" %>
2<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
3
4<script type="text/javascript">
5    var InterfaceTemplate = Class.create( {
6
7        initialize: function()
8        {
9            /** *********** CONTAINERS *********** **/
10            this.containerTools = $( "#tools" );
11            this.containerLogin = $( "#loginModule" );
12            this.containerMenuData = $( "#menuData" );
13
14            /** *********** VARIABLES *********** **/
15            // TODO : vérifier cette adresse de webmaster !!!!
16            this.language = '<spring:message code="language"/>';
17            this.webmaster = "rboipsl@ipsl.jussieu.fr";
18            this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false;
19
20            /** ************ CREATE ************ **/
21            this.createLogin();
22            this.createTools();
23        },
24
25        // CREATES ********************************************************
26        createTools: function()
27        {
28            var backofficeButton = new Button( {value:'<spring:message code="label.backoffice"/>', parent:this.containerTools, id:"button_bo", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickBO, this )} );
29
30            var mailButton = new Button( {value:'<spring:message code="label.mail"/>', parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} );
31            var languageButton = new Button( {value:'<spring:message code="label.language.to.switch"/>', parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
32            var homeButton = new Button( {value:'<spring:message code="label.home"/>', parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} );
33        },
34
35        createLogin: function()
36        {
37            var loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", webmaster: this.webmaster, isNeededInscription:true, callbackInscription:jQuery.proxy( this.onClickInscription, this ) } );
38            loginModule.setJSONUser( this.jSONUser );
39            loginModule.display();
40            setLoginModule( this.loginModule );
41        },
42
43        // REQUESTS ********************************************************
44        requestChangeLocale: function()
45        {
46            $.ajax( {
47                url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>",
48                success:function()
49                {
50                    location.reload();
51                }
52            } );
53        },
54
55        // HANDLES ******************************************************** = retours ajax
56
57        // EVENTS ********************************************************
58        onClickBO: function()
59        {
60            document.location.href = "backoffice?methodName=home";
61        },
62
63        onClickHome: function()
64        {
65            document.location.href = "index.jsp";
66        },
67
68        onClickLanguage: function()
69        {
70            this.requestChangeLocale();
71        },
72
73        onClickMail: function()
74        {
75            document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]";
76        },
77
78        onClickInscription: function()
79        {
80            var dataProtocol = "resources/jsp/dataProtocol_fr.jsp";
81            if( "fr" != this.language )
82                dataProtocol = "resources/jsp/dataProtocol_en.jsp";
83
84            var $dialog = $( '<div></div>' )
85                    .load( dataProtocol )
86                    .dialog( {
87                                 autoOpen: false,
88                                 title: '<spring:message code="login.inscription" />',
89                                 height:800,
90                                 width:750
91                             } );
92            $dialog.dialog( 'open' );
93        }
94
95    } )
96            ;
97
98    /** ******************************* **/
99    /** *********** ACCOUNT *********** **/
100    /** ******************************* **/
101    function onClickAcceptDataProtocol()
102    {
103        if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )
104        {
105            showErrorAccount( null, "<spring:message code='login.dataProtocolFields'/>" );
106            return;
107        }
108
109        if( $( "#checkboxUser" ).attr( 'checked' ) )
110            createAccount();
111        else
112            showErrorAccount( null, "<spring:message code='login.dataProtocolAccept'/>" );
113    }
114
115    function createAccount()
116    {
117        var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val() + "&laboratory=" + $( "#laboratory" ).val() + "&country=" + $( "#country" ).val();
118        var request = $.ajax( {
119            url: "project?methodName=createAccount&" + parametersUrl,
120            success:handleCreateAccount,
121            error: showErrorAccount
122        } );
123    }
124
125    function handleCreateAccount()
126    {
127        $( "#infosAccount" ).hide();
128        $( "#infosAccount" ).removeClass( "containerErrors" );
129        $( "#infosAccount" ).addClass( "containerInfos" );
130        $( "#infosAccount" ).html( '<spring:message code="login.dataProtocol.account"/>' );
131        $( "#infosAccount" ).show();
132    }
133
134    function showErrorAccount( result, text )
135    {
136        $( "#infosAccount" ).hide();
137        $( "#infosAccount" ).removeClass( "containerInfos" );
138        $( "#infosAccount" ).addClass( "containerErrors" );
139        if( null != result )
140            $( "#infosAccount" ).html( templateTexts[result.responseText] );
141        else
142            $( "#infosAccount" ).html( text );
143
144        $( "#infosAccount" ).show();
145    }
146
147</script>
Note: See TracBrowser for help on using the repository browser.