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 | this.language = '<spring:message code="language"/>'; |
---|
16 | this.webmaster = "<%=WebHelper.getProperty(request, "mail.webmaster")%>"; |
---|
17 | this.jSONUser = <%=WebHelper.getJSONUser( request )%> ? <%=WebHelper.getJSONUser( request )%> : false; |
---|
18 | |
---|
19 | /** ************ CREATE ************ **/ |
---|
20 | this.createLogin(); |
---|
21 | this.createTools(); |
---|
22 | }, |
---|
23 | |
---|
24 | // CREATES ******************************************************** |
---|
25 | createTools: function() |
---|
26 | { |
---|
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 )} ); |
---|
28 | |
---|
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} ); |
---|
32 | }, |
---|
33 | |
---|
34 | createLogin: function() |
---|
35 | { |
---|
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 ) } ); |
---|
37 | loginModule.setJSONUser( this.jSONUser ); |
---|
38 | loginModule.display(); |
---|
39 | setLoginModule( this.loginModule ); |
---|
40 | }, |
---|
41 | |
---|
42 | // REQUESTS ******************************************************** |
---|
43 | requestChangeLocale: function() |
---|
44 | { |
---|
45 | $.ajax( { |
---|
46 | url: "project?methodName=setLocale&language=<spring:message code="label.language.value.to.switch"/>", |
---|
47 | success:function() |
---|
48 | { |
---|
49 | location.reload(); |
---|
50 | } |
---|
51 | } ); |
---|
52 | }, |
---|
53 | |
---|
54 | // HANDLES ******************************************************** = retours ajax |
---|
55 | |
---|
56 | // EVENTS ******************************************************** |
---|
57 | onClickBO: function() |
---|
58 | { |
---|
59 | document.location.href = "backoffice?methodName=home"; |
---|
60 | }, |
---|
61 | |
---|
62 | onClickHome: function() |
---|
63 | { |
---|
64 | document.location.href = "index.jsp"; |
---|
65 | }, |
---|
66 | |
---|
67 | onClickLanguage: function() |
---|
68 | { |
---|
69 | this.requestChangeLocale(); |
---|
70 | }, |
---|
71 | |
---|
72 | onClickMail: function() |
---|
73 | { |
---|
74 | document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]"; |
---|
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' ); |
---|
92 | } |
---|
93 | |
---|
94 | } ) |
---|
95 | ; |
---|
96 | |
---|
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 | |
---|
146 | </script> |
---|