Changeset 389 for tapas/web/init_script.jsp
- Timestamp:
- 03/02/12 18:07:28 (12 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/init_script.jsp
r388 r389 1 <%@ page import="com.ether.Context" %> 1 <script type="text/javascript"> 2 var InterfaceInit = Class.create( { 2 3 3 <script type="text/javascript"> 4 var InterfaceTemplate = Class.create( { 4 initialize: function() 5 { 6 /** *********** CONTAINERS *********** **/ 7 this.containerForm = $( "#formulaire" ); 5 8 6 initialize: function() 7 { 8 /** *********** CONTAINERS *********** **/ 9 this.containerTools = $( "#tools" ); 10 this.containerLogin = $( "#loginModule" ); 11 this.containerMenuData = $( "#menuData" ); 9 this.createForm(); 12 10 13 /** *********** VARIABLES *********** **/ 14 this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; 15 this.path = "<%=request.getContextPath()%>"; 16 setPath( this.path ); 17 this.webmaster = "<%=Context.getWebmaster(request)%>"; 18 this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; 19 <%--this.jSONUser = <%=Context.getJSONUser( request )%> ? <%=Context.getJSONUser( request )%> : false;--%> 11 }, 20 12 21 / ** ************ CREATE ************ **/22 // this.createLogin(); 23 this.createTools();24 this.createMenuData();25 this.updateLoginOrLogout();26 },13 // CREATES ******************************************************** 14 createForm: function() 15 { 16 // Create button elements 17 this.input1 = $( document.createElement( "input" ) ); 18 var input2 = $( document.createElement( "input" ) ); 27 19 28 // CREATES ******************************************************** 29 createTools: function() 30 { 31 var mailButton = new Button( {value:templateTexts["label.mail"], parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} ); 20 this.input1.attr( {id:"1"} ); 21 this.containerForm.append( this.input1 ); 32 22 33 var valueLanguage = templateTexts["label.language.fr"]; 34 if( this.isLanguageFr ) 35 valueLanguage = templateTexts["label.language.en"]; 23 input2.attr( {id:"2"} ); 24 this.containerForm.append( input2 ); 36 25 37 var languageButton = new Button( {value:valueLanguage, parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 38 var homeButton = new Button( {value:templateTexts["label.home"], parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} ); 39 }, 26 var submitButton = new Button( {value:initTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} ); 40 27 41 createLogin: function() 42 { 43 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 } ); 44 this.loginModule.setJSONUser( this.jSONUser ); 45 this.loginModule.display(); 46 setLoginModule( this.loginModule ); 47 }, 28 }, 48 29 49 createMenuData: function()50 {51 this.containerMenuData.empty();52 30 53 var ulData = $( document.createElement( "ul" ) ); 54 this.containerMenuData.append( ulData ); 31 // REQUESTS ******************************************************** 32 requestCreateXML: function() 33 { 34 // alert(this.input1.val()+' - '+$("#2").val()); 35 $.ajax( { 36 url: "project?methodName=createUserRequest&input1="+this.input1.val()+"&input2="+$("#2").val(), 37 success:jQuery.proxy( this.handleCreateXML, this ) 38 } ); 39 }, 55 40 56 var liExtract = $( document.createElement( "li" ) ); 57 liExtract.append( '<a onclick=\'javascript:neededLogin("/DataAccess.do")\'><span>' + templateTexts["data.access.extract.short"] + '</span></a>' ); 58 ulData.append( liExtract ); 41 // HANDLES ******************************************************** = retours ajax 42 handleCreateXML: function( result ) 43 { 44 // alert("XML créé"); 45 var bob = jQuery.parseJSON( result ).result; 46 alert(bob); 59 47 60 var liDownload = $( document.createElement( "li" ) ); 61 liDownload.append( '<a onclick=\'javascript:neededLogin("/PrepareTree.do")\'><span>' + templateTexts["data.upload.short"] + '</span></a>' ); 62 ulData.append( liDownload ); 63 }, 48 }, 64 49 65 // REQUESTS ********************************************************66 50 67 // EVENTS ******************************************************** 68 onClickHome: function() 69 { 70 document.location.href = "index.jsp"; 71 }, 51 // EVENTS ******************************************************** 72 52 73 onClickLanguage: function() 74 { 75 if( this.isLanguageFr ) 76 document.location.href = this.path + "/English.do?requestUri=" + this.relativePageUri; 77 else 78 document.location.href = this.path + "/French.do?requestUri=" + this.relativePageUri; 79 }, 53 onClickSubmit: function() 54 { 55 this.requestCreateXML(); 56 } 80 57 81 onClickMail: function()82 {83 document.location.href = "mailto:" + this.webmaster + "?subject=[TAPAS]";84 },85 58 86 onClickInscription: function() 87 { 88 var dataProtocol = "resources/jsp/dataProtocol_fr.jsp"; 89 if( !this.isLanguageFr ) 90 dataProtocol = "resources/jsp/dataProtocol_en.jsp"; 59 } ); 91 60 92 var $dialog = $( '<div></div>' )93 .load( dataProtocol )94 .dialog( {95 autoOpen: false,96 title: loginTexts["login.inscription"],97 height: 800,98 width: 75099 } );100 $dialog.dialog( 'open' );101 61 102 // TODO : see with $dialog.ready() to manage buttons103 },104 105 updateLoginOrLogout: function()106 {107 <%--if( "<%=UserRole.ADMINISTRATOR%>" == getJSONUserRole() )--%>108 <%--$( "#button_bo" ).show();--%>109 <%--else--%>110 <%--$( "#button_bo" ).hide();--%>111 }112 113 } );114 115 /** ******************************* **/116 /** *********** ACCOUNT *********** **/117 /** ******************************* **/118 function onClickAcceptDataProtocol()119 {120 if( '' == $( "#lastName" ).val() || '' == $( "#email" ).val() || '' == $( "#password" ).val() )121 {122 showErrorAccount( null, templateTexts["login.dataProtocolFields"] );123 return;124 }125 126 if( $( "#checkboxUser" ).attr( 'checked' ) )127 createAccount();128 else129 showErrorAccount( null, templateTexts["login.dataProtocolAccept"] );130 }131 132 function createAccount()133 {134 var parametersUrl = "name=" + $( "#lastName" ).val() + "&firstName=" + $( "#firstName" ).val() + "&email=" + $( "#email" ).val() + "&pwd=" + $( "#password" ).val();135 var request = $.ajax( {136 url: "project?methodName=createAccount&" + parametersUrl,137 success:handleCreateAccount,138 error: showErrorAccount139 } );140 }141 142 function handleCreateAccount()143 {144 $( "#infosAccount" ).hide();145 $( "#infosAccount" ).removeClass( "containerErrors" );146 $( "#infosAccount" ).addClass( "containerInfos" );147 $( "#infosAccount" ).html( templateTexts["login.dataProtocol.account"] );148 $( "#infosAccount" ).show();149 }150 151 function showErrorAccount( result, text )152 {153 $( "#infosAccount" ).hide();154 $( "#infosAccount" ).removeClass( "containerInfos" );155 $( "#infosAccount" ).addClass( "containerErrors" );156 if( null != result )157 $( "#infosAccount" ).html( templateTexts[result.responseText] );158 else159 $( "#infosAccount" ).html( text );160 161 $( "#infosAccount" ).show();162 }163 62 </script>
Note: See TracChangeset
for help on using the changeset viewer.