@@ -118,8 +118,10 @@ var setupLoginFields = function() {
118
118
$ ( '#login_form .formfield.textinput input' ) . focus ( hideTextLabel ) ;
119
119
$ ( '#login_form .formfield.textinput input' ) . blur ( onBlurTextInput ) ;
120
120
$ ( '#login_form .formfield.textinput input' ) . change ( testLoginSubmitEnable ) ;
121
- $ ( '#login_form .formfield.textinput input' ) . keydown ( function ( ) {
122
- setTimeout ( testLoginSubmitEnable , 0 ) ;
121
+ $ ( '#login_form .formfield.textinput input' ) . keydown ( function ( e ) {
122
+ if ( e . which != 13 ) {
123
+ setTimeout ( testLoginSubmitEnable , 0 ) ;
124
+ }
123
125
} ) ;
124
126
125
127
//submit on enter or button click
@@ -139,9 +141,11 @@ var setupLogoutFields = function() {
139
141
$ ( '#logout_form .formfield.textinput input' ) . focus ( hideTextLabel ) ;
140
142
$ ( '#logout_form .formfield.textinput input' ) . blur ( onBlurTextInput ) ;
141
143
$ ( '#logout_form .formfield.textinput input' ) . change ( testLoginSubmitEnable ) ;
142
- $ ( '#logout_form .formfield.textinput input' ) . keydown ( function ( ) {
143
- setTimeout ( testLoginSubmitEnable , 0 ) ;
144
- } ) ;
144
+ $ ( '#logout_form .formfield.textinput input' ) . keydown ( function ( e ) {
145
+ if ( e . which != 13 ) {
146
+ setTimeout ( testLoginSubmitEnable , 0 ) ;
147
+ }
148
+ } ) ;
145
149
146
150
//submit on enter or button click
147
151
$ ( '#logout_form .formfield.textinput .pass' ) . keypress ( function ( e ) {
@@ -160,9 +164,11 @@ var setupConfigureFields = function() {
160
164
$ ( '#configure_form .formfield.textinput input' ) . focus ( hideTextLabel ) ;
161
165
$ ( '#configure_form .formfield.textinput input' ) . blur ( onBlurTextInput ) ;
162
166
$ ( '#configure_form .formfield.textinput input' ) . change ( testConfigureSubmitEnable ) ;
163
- $ ( '#configure_form .formfield.textinput input' ) . keydown ( function ( ) {
164
- setTimeout ( testConfigureSubmitEnable , 0 ) ;
165
- } ) ;
167
+ $ ( '#configure_form .formfield.textinput input' ) . keydown ( function ( e ) {
168
+ if ( e . which != 13 ) {
169
+ setTimeout ( testConfigureSubmitEnable , 0 ) ;
170
+ }
171
+ } ) ;
166
172
167
173
$ ( '#configure_form .submit' ) . click ( configureClick ) ;
168
174
} ;
@@ -172,9 +178,18 @@ var setupAddPasswordFields = function() {
172
178
$ ( '#addpassword_form .formfield.textinput input' ) . focus ( hideTextLabel ) ;
173
179
$ ( '#addpassword_form .formfield.textinput input' ) . blur ( onBlurTextInput ) ;
174
180
$ ( '#addpassword_form .formfield.textinput input' ) . change ( testAddPasswordSubmitEnable ) ;
175
- $ ( '#addpassword_form .formfield.textinput input' ) . keydown ( function ( ) {
176
- setTimeout ( testAddPasswordSubmitEnable , 0 ) ;
177
- } ) ;
181
+ $ ( '#addpassword_form .formfield.textinput input' ) . keydown ( function ( e ) {
182
+ if ( e . which != 13 ) {
183
+ setTimeout ( testAddPasswordSubmitEnable , 0 ) ;
184
+ }
185
+ } ) ;
186
+
187
+ $ ( '#addpassword_form .formfield.textinput .pass_repeat' ) . keypress ( function ( e ) {
188
+ if ( e . which == 13 ) {
189
+ e . preventDefault ( ) ;
190
+ addPasswordClick ( ) ;
191
+ }
192
+ } ) ;
178
193
179
194
$ ( '#addpassword_form .submit' ) . click ( addPasswordClick ) ;
180
195
} ;
@@ -185,10 +200,19 @@ var setupChangePasswordFields = function() {
185
200
$ ( '#changepassword_form .formfield.textinput input' ) . focus ( hideTextLabel ) ;
186
201
$ ( '#changepassword_form .formfield.textinput input' ) . blur ( onBlurTextInput ) ;
187
202
$ ( '#changepassword_form .formfield.textinput input' ) . change ( testChangePasswordSubmitEnable ) ;
188
- $ ( '#changepassword_form .formfield.textinput input' ) . keydown ( function ( ) {
189
- setTimeout ( testChangePasswordSubmitEnable , 0 ) ;
203
+ $ ( '#changepassword_form .formfield.textinput input' ) . keydown ( function ( e ) {
204
+ if ( e . which != 13 ) {
205
+ setTimeout ( testChangePasswordSubmitEnable , 0 ) ;
206
+ }
190
207
} ) ;
191
208
209
+ $ ( '#changepassword_form .formfield.textinput .pass_repeat' ) . keypress ( function ( e ) {
210
+ if ( e . which == 13 ) {
211
+ e . preventDefault ( ) ;
212
+ changePasswordClick ( ) ;
213
+ }
214
+ } ) ;
215
+
192
216
$ ( '#changepassword_form .submit' ) . click ( changePasswordClick ) ;
193
217
$ ( '#changepassword_form .cancel' ) . click ( function ( ) {
194
218
window . location . href = "/" ;
@@ -201,7 +225,8 @@ var loginClick = function( what ) {
201
225
if ( pagemode === "logout" ) {
202
226
$form = $ ( '#logout_form' ) ;
203
227
}
204
-
228
+
229
+ $form . find ( '.errormessage' ) . css ( 'visibility' , 'hidden' ) ;
205
230
$form . find ( '.pass' ) . removeClass ( 'error' ) ;
206
231
$ . post (
207
232
appurl + '/api/login' ,
@@ -213,7 +238,7 @@ var loginClick = function( what ) {
213
238
if ( data . status === "success" ) {
214
239
window . location . href = "/app/coder" ;
215
240
} else {
216
-
241
+ $form . find ( '.errormessage' ) . text ( data . error ) . css ( 'visibility' , 'visible' ) ;
217
242
$form . find ( '.pass' ) . addClass ( 'error' ) ;
218
243
}
219
244
}
@@ -249,13 +274,12 @@ var configureClick = function() {
249
274
} ;
250
275
251
276
var addPasswordClick = function ( ) {
252
- $this = $ ( this ) ;
253
277
var $form = $ ( '#addpassword_form' ) ;
254
278
255
279
$form . find ( '.pass, .pass_repeat' ) . removeClass ( 'error' ) ;
256
280
$form . find ( '.errormessage' ) . css ( 'visibility' , 'hidden' ) ;
257
- var pass = $this . parent ( ) . find ( '.pass' ) . val ( ) ;
258
- var pass_repeat = $this . parent ( ) . find ( '.pass_repeat' ) . val ( ) ;
281
+ var pass = $form . find ( '.pass' ) . val ( ) ;
282
+ var pass_repeat = $form . find ( '.pass_repeat' ) . val ( ) ;
259
283
260
284
if ( ! isValidPassword ( pass ) ) {
261
285
$form . find ( '.pass' ) . addClass ( 'error' ) ;
@@ -287,14 +311,14 @@ var addPasswordClick = function() {
287
311
288
312
289
313
var changePasswordClick = function ( ) {
290
- $this = $ ( this ) ;
314
+
291
315
var $form = $ ( '#changepassword_form' ) ;
292
316
293
317
$form . find ( '.oldpass, .pass, .pass_repeat' ) . removeClass ( 'error' ) ;
294
318
$form . find ( '.errormessage' ) . css ( 'visibility' , 'hidden' ) ;
295
- var oldpass = $this . parent ( ) . find ( '.oldpass' ) . val ( ) ;
296
- var pass = $this . parent ( ) . find ( '.pass' ) . val ( ) ;
297
- var pass_repeat = $this . parent ( ) . find ( '.pass_repeat' ) . val ( ) ;
319
+ var oldpass = $form . find ( '.oldpass' ) . val ( ) ;
320
+ var pass = $form . find ( '.pass' ) . val ( ) ;
321
+ var pass_repeat = $form . find ( '.pass_repeat' ) . val ( ) ;
298
322
299
323
if ( oldpass === "" ) {
300
324
$form . find ( '.oldpass' ) . addClass ( 'error' ) ;
0 commit comments