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