dcbfbb3057e508554dc6bb3dd7f493f148665040
[myslice.git] / portal / static / js / my_account.edit_profile.js
1 /*
2                         *********
3  ******* JQuery for the MySlice [Local] account buttons ********************* 
4                         ********
5 Authors:
6   Mohammed Yasin Rahman <mohammed-yasin.rahman@lip6.fr>
7 Copyright 2013, UPMC Sorbonne Universités / LIP6
8    
9  */
10
11 jQuery(document).ready(function(){
12                       // jquery functionalities of different buttons [Edit, Cancel, Upload]
13                       //edit name
14                       jQuery("#edit_name").click(function(){
15
16                               jQuery("#span_name").show();
17                               jQuery("#nameval").hide();
18                               jQuery("#edit_name").hide();
19                               // enforcing when one edit is clicked the rest will not work at same time
20                               jQuery("#span_pass").hide();
21                               jQuery("#edit_pass").show();
22                               jQuery("#passval").show();
23                               jQuery("#span_aff").hide();
24                               jQuery("#edit_aff").show();
25                               jQuery("#affval").show();
26                               jQuery("#span_email").hide();
27                               jQuery("#edit_email").show();
28                               jQuery("#emailval").show();
29                               jQuery("#span_upload").hide();
30                               jQuery("#keyval").show();
31                               jQuery("#dl_file").show();
32                               jQuery("#upload_file").show();
33                       });
34                       jQuery("#cancel_name_change").click(function(){
35
36                               jQuery("#span_name").hide();
37                               jQuery("#nameval").show();
38                               jQuery("#edit_name").show();
39
40
41                       });
42                       //edit pass
43                       jQuery("#edit_pass").click(function(){
44
45                               jQuery("#span_pass").show();
46                               jQuery("#passval").hide();
47                               jQuery("#edit_pass").hide();
48                               // enforcing when one edit is clicked the rest will not work at same time
49                               jQuery("#span_name").hide();
50                               jQuery("#edit_name").show();
51                               jQuery("#nameval").show();
52                               jQuery("#span_aff").hide();
53                               jQuery("#edit_aff").show();
54                               jQuery("#affval").show();
55                               jQuery("#span_email").hide();
56                               jQuery("#edit_email").show();
57                               jQuery("#emailval").show();
58                               jQuery("#span_upload").hide();
59                               jQuery("#keyval").show();
60                               jQuery("#dl_file").show();
61                               jQuery("#upload_file").show();
62                       });
63                       jQuery("#cancel_pass_change").click(function(){
64
65                               jQuery("#span_pass").hide();
66                               jQuery("#passval").show();
67                               jQuery("#edit_pass").show();
68                       });
69                       // both password should be same
70                       jQuery("#editForm").validate({
71                         rules: {
72                             password: { 
73                                 required: true
74                                 }, 
75                             confirmpassword: { 
76                                 required: true, equalTo: "#password"
77                                 }
78                             }
79                       });
80                       //edit affiliation
81                       jQuery("#edit_aff").click(function(){
82
83                               jQuery("#span_aff").show();
84                               jQuery("#affval").hide();
85                               jQuery("#edit_aff").hide();
86                               // enforcing when one edit is clicked the rest will not work at same time
87                               jQuery("#span_pass").hide();
88                               jQuery("#edit_pass").show();
89                               jQuery("#passval").show();
90                               jQuery("#span_name").hide();
91                               jQuery("#edit_name").show();
92                               jQuery("#nameval").show();
93                               jQuery("#span_email").hide();
94                               jQuery("#edit_email").show();
95                               jQuery("#emailval").show();
96                               jQuery("#span_upload").hide();
97                               jQuery("#keyval").show();
98                               jQuery("#dl_file").show();
99                               jQuery("#upload_file").show();
100                       });
101                       jQuery("#cancel_aff_change").click(function(){
102
103                               jQuery("#span_aff").hide();
104                               jQuery("#affval").show();
105                               jQuery("#edit_aff").show();
106                       });
107                       //edit email
108                       /* edit email will be done by PI if needed
109                       jQuery("#edit_email").click(function(){
110
111                               jQuery("#span_email").show();
112                               jQuery("#emailval").hide();
113                               jQuery("#edit_email").hide();
114                               // enforcing when one edit is clicked the rest will not work at same time
115                               jQuery("#span_pass").hide();
116                               jQuery("#edit_pass").show();
117                               jQuery("#passval").show();
118                               jQuery("#span_aff").hide();
119                               jQuery("#edit_aff").show();
120                               jQuery("#affval").show();
121                               jQuery("#span_name").hide();
122                               jQuery("#edit_name").show();
123                               jQuery("#nameval").show();
124                               jQuery("#span_upload").hide();
125                               jQuery("#keyval").show();
126                               jQuery("#dl_file").show();
127                               jQuery("#upload_file").show();
128                       });
129                       jQuery("#cancel_email_change").click(function(){
130
131                               jQuery("#span_email").hide();
132                               jQuery("#emailval").show();
133                               jQuery("#edit_email").show();
134                       }); */
135                       //upload pub keys
136                       jQuery("#upload_file").click(function(){
137
138                               jQuery("#span_upload").show();
139                               jQuery("#dl_file").hide();
140                               jQuery("#upload_file").hide();
141                               jQuery("#keyval").hide();
142                               // enforcing when one edit is clicked the rest will not work at same time
143                               jQuery("#span_name").hide();
144                               jQuery("#edit_name").show();
145                               jQuery("#nameval").show();
146                               jQuery("#span_pass").hide();
147                               jQuery("#edit_pass").show();
148                               jQuery("#passval").show();
149                               jQuery("#span_aff").hide();
150                               jQuery("#edit_aff").show();
151                               jQuery("#affval").show();
152                               jQuery("#span_email").hide();
153                               jQuery("#edit_email").show();
154                               jQuery("#emailval").show();
155                       });
156                       jQuery("#cancel_upload").click(function(){
157
158                               jQuery("#span_upload").hide();
159                               jQuery("#keyval").show();
160                               jQuery("#dl_file").show();
161                               jQuery("#upload_file").show();
162                       });
163                   });
164
165 // alert box for the "Generate new Key Pair button"
166 function myFunction()
167 {
168 alert("You have requested to generate new key pairs. Please download and save the new keypairs after receiving the success message.");
169 }
170
171 function emailAlert()
172 {
173 alert("To edit email please contact the administratior. You will be redirected to the support page now");
174 window.location.href = "/portal/contact/";
175 }
176
177 function affAlert()
178 {
179 alert("To edit affiliation please contact the administratior. You will be redirected to the support page now");
180 window.location.href = "/portal/contact/";
181 }
182 /*
183  // alert having ok or cancel option
184 function show_confirm()
185 {
186 var r=confirm("Press a button!");
187 if (r==true)
188   {
189   alert("You pressed OK!");
190   }
191 else
192   {
193   alert("You pressed Cancel!");
194   }
195 }
196 */
197
198