source: ether_statistics/web/resources/templates/templateMegapoli_script.jsp @ 578

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

Nouveau projet

File size: 10.0 KB
Line 
1<%@ page import="com.ether.user.UserRole" %>
2<%@ page import="com.medias.Context" %>
3
4<script type="text/javascript">
5var InterfaceTemplate = Class.create( {
6
7    initialize: function()
8    {
9        /** *********** CONTAINERS *********** **/
10        this.containerTitle = $( "#title" );
11        this.containerTools = $( "#tools" );
12        this.containerLogin = $( "#loginModule" );
13        this.containerMenuData = $( "#menuData" );
14
15        /** *********** VARIABLES *********** **/
16        this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>;
17        this.path = "<%=request.getContextPath()%>";
18        setPath( this.path );
19        this.webmaster = "<%=Context.getWebmaster(request)%>";
20        this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>";
21        this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;
22        this.screenWidthLimit = 1336;
23
24        /** ************ CREATE ************ **/
25        this.createTitle();
26        this.createLogin();
27        this.createTools();
28        this.createMenuData();
29        jQuery.proxy( this.createLeftSlides(), this );
30        this.updateLoginOrLogout();
31    },
32
33    // CREATES ********************************************************
34    createTitle: function()
35    {
36        this.containerTitle.addClass( "containerTitle" );
37        this.containerTitle.html( templateTexts["app.fulltitle"] );
38    },
39
40    createTools: function()
41    {
42//        var backofficeButton = new Button( {value:templateTexts["app.backoffice"], parent:this.containerTools, id:"button_bo", className: "blue_button", classNameText:"blue_button_text", title : templateTexts["app.backoffice.help"], onClick:jQuery.proxy( this.onClickBO, this )} );
43//        backofficeButton.hide();
44//
45        var mailButton = new Button( {value:templateTexts["data.upload.metadata.contact.mail"], parent:this.containerTools, id:"button_mail", className: "blue_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickMail, this )} );
46
47        var valueLanguage = templateTexts["app.fr"];
48        if( this.isLanguageFr )
49            valueLanguage = templateTexts["app.en"];
50
51        var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "blue_button", classNameText:"blue_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );
52        var homeButton = new Button( {value:templateTexts["app.home"], parent:this.containerTools, id:"button_home", className: "blue_button", classNameText:"blue_button_text", onClick:this.onClickHome} );
53
54        var divSmallLogoEther = $( document.createElement( "div" ) );
55        divSmallLogoEther.attr( {id:"smallLogoEther", class:"containerSmallLogoEther"} );
56        divSmallLogoEther.append( '<a href="http://ether.ipsl.jussieu.fr" target="help"><img src="resources/images/logo_Ether.jpg" width="40px" height="40px"/></a>' );
57        this.containerTools.append( divSmallLogoEther );
58
59        this.updateLogoEther();
60    },
61
62    createLogin: function()
63    {
64        this.loginModule = new LoginButton( {parent:this.containerLogin, urlLogin:"project?methodName=login", urlLogout:"project?methodName=logout", isNeededInscription:true, callbackInscription:jQuery.proxy( this.onClickInscription, this ), anotherOnClickLogin:this.updateLoginOrLogout, anotherOnClickLogout:this.updateLoginOrLogout } );
65        this.loginModule.setJSONUser( this.jSONUser );
66        this.loginModule.display();
67        setLoginModule( this.loginModule );
68    },
69
70    createMenuData: function()
71    {
72        this.containerMenuData.empty();
73
74        var ulData = $( document.createElement( "ul" ) );
75        this.containerMenuData.append( ulData );
76
77        var liExtract = $( document.createElement( "li" ) );
78        liExtract.append( '<a onclick=\'javascript:neededLogin("/DataAccess.do")\'><span>' + templateTexts["data.access.extract.short"] + '</span></a>' );
79        ulData.append( liExtract );
80
81        var liDownload = $( document.createElement( "li" ) );
82        liDownload.append( '<a onclick=\'javascript:neededLogin("/PrepareTree.do")\'><span>' + templateTexts["data.upload.short"] + '</span></a>' );
83        ulData.append( liDownload );
84    },
85
86    createLeftSlides: function()
87    {
88        var contentSlideCredits = "resources/jsp/credits_fr.jsp";
89        var contentSlideMentions = "resources/jsp/mentions_fr.jsp";
90        var contentSlideInfos = "resources/jsp/informations_fr.jsp";
91
92//        var contentButtonCredits = "<button class='big_blue_button' title='" + templateTexts["app.credits"] + "'><div class='big_blue_button_text'>C</div></button>";
93//        var contentButtonMentions = "<button class='big_blue_button' title='" + templateTexts["app.mentions"] + "'><div class='big_blue_button_text'>M</div></button>";
94//        var contentButtonInfos = "<button class='big_blue_button' title='" + templateTexts["app.infos"] + "'><div class='big_blue_button_text'>I</div></button>";
95
96        var contentButtonCredits = "<img src='resources/images/utils/credits.png' title='" + templateTexts["app.credits"] + "'/>";
97        var contentButtonMentions = "<img src='resources/images/utils/legals.png' title='" + templateTexts["app.mentions"] + "'/>";
98        var contentButtonInfos = "<img src='resources/images/utils/infos_2.png' title='" + templateTexts["app.infos"] + "'/>";
99
100        if( !this.isLanguageFr )
101        {
102            contentSlideCredits = "resources/jsp/credits_en.jsp";
103            contentSlideMentions = "resources/jsp/mentions_en.jsp";
104            contentSlideInfos = "resources/jsp/informations_en.jsp";
105        }
106        var divSlideCredits = new Slide( { contentId:"slideContentCredits", buttonId: "slideCredits", parent:$( "#creditSlide" ), isIndexToChange:true,
107            contentButton:contentButtonCredits , contentPageSlide:contentSlideCredits} );
108
109        var divSlideMentions = new Slide( { contentId:"slideContentMentions", buttonId: "slideMentions", parent:$( "#mentionSlide" ),specificButtonClass:"containerSlideButtonMentions", isIndexToChange:true,
110            contentButton:contentButtonMentions, contentPageSlide:contentSlideMentions} );
111
112        var divSlideInfos = new Slide( { contentId:"slideContentInfos", buttonId: "slideInfos", parent:$( "#infoSlide" ), specificButtonClass:"containerSlideButtonInfos", isIndexToChange:true,
113            contentButton:contentButtonInfos, contentPageSlide:contentSlideInfos} );
114    },
115
116    // REQUESTS ********************************************************
117
118    // EVENTS ********************************************************
119    onClickHome: function()
120    {
121        document.location.href = "index.jsp";
122    },
123
124    onClickLanguage: function()
125    {
126        if( this.isLanguageFr )
127            document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri;
128        else
129            document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri;
130    },
131
132    onClickBO: function()
133    {
134        document.location.href = this.path + "/backoffice";
135    },
136
137    onClickMail: function()
138    {
139        document.location.href = "mailto:" + this.webmaster + "?subject=[MEGAPOLI]";
140    },
141
142    onClickInscription: function()
143    {
144        var dataProtocol = "resources/jsp/dataProtocol_fr.jsp";
145        if( !this.isLanguageFr )
146            dataProtocol = "resources/jsp/dataProtocol_en.jsp";
147
148        var $dialog = $( '<div></div>' )
149                .load( dataProtocol )
150                .dialog( {
151                             autoOpen: false,
152                             title: loginTexts["login.inscription"],
153                             height: 800,
154                             width: 750
155                         } );
156        $dialog.dialog( 'open' );
157
158        // TODO : see with $dialog.ready() to manage buttons
159    },
160
161    /**
162     * This method display a small Ether logo if the screen is too small to contain the big one
163     */
164    updateLogoEther: function()
165    {
166        if( this.screenWidthLimit > innerWidth )
167        {
168            $( "#logoEther" ).hide();
169            $( "#linkLogoEther" ).hide();
170            $( "#smallLogoEther" ).show();
171        }
172        else
173        {
174            $( "#logoEther" ).show();
175            $( "#linkLogoEther" ).show();
176            $( "#smallLogoEther" ).hide();
177        }
178    },
179
180    updateLoginOrLogout: function()
181    {
182        if( "<%=UserRole.ADMINISTRATOR%>" == getJSONUserRole() )
183            $( "#button_bo" ).show();
184        else
185            $( "#button_bo" ).hide();
186    }
187
188} );
189
190/** ******************************* **/
191/** *********** ACCOUNT *********** **/
192/** ******************************* **/
193function onClickAcceptDataProtocol()
194{
195    if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )
196    {
197        showErrorAccount( null, templateTexts["login.dataProtocolFields"] );
198        return;
199    }
200
201    if( $( "#checkboxUser" ).attr( 'checked' ) )
202        createAccount();
203    else
204        showErrorAccount( null, templateTexts["login.dataProtocolAccept"] );
205}
206
207function createAccount()
208{
209    var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val();
210    var request = $.ajax( {
211        url: "project?methodName=createAccount&" + parametersUrl,
212        success:handleCreateAccount,
213        error: showErrorAccount
214    } );
215}
216
217function handleCreateAccount()
218{
219    $( "#infosAccount" ).hide();
220    $( "#infosAccount" ).removeClass( "containerErrors" );
221    $( "#infosAccount" ).addClass( "containerInfos" );
222    $( "#infosAccount" ).html( templateTexts["login.dataProtocol.account"] );
223    $( "#infosAccount" ).show();
224}
225
226function showErrorAccount( result, text )
227{
228    $( "#infosAccount" ).hide();
229    $( "#infosAccount" ).removeClass( "containerInfos" );
230    $( "#infosAccount" ).addClass( "containerErrors" );
231    if( null != result )
232        $( "#infosAccount" ).html( templateTexts[result.responseText] );
233    else
234        $( "#infosAccount" ).html( text );
235
236    $( "#infosAccount" ).show();
237}
238</script>
Note: See TracBrowser for help on using the repository browser.