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

Last change on this file since 480 was 480, checked in by rboipsl, 12 years ago

insertion requete dans bdd
lancement process qsub
debut modif design

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