hedera-web/forms/account/conf/conf.js

78 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
Hedera.Conf = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Hedera.Form
,activate: function ()
{
2018-01-02 13:16:41 +00:00
this.$('user-model').setInfo ('c', 'myClient', 'hedera');
}
2016-10-11 14:45:10 +00:00
,onPassChangeClick: function ()
{
this.$('old-password').value = '';
this.$('new-password').value = '';
this.$('repeat-password').value = '';
2016-10-14 10:58:35 +00:00
var recoverPass = this.$('user-form').get ('recoverPass');
this.$('old-password').style.display = recoverPass ? 'none' : 'block';
2016-10-11 14:45:10 +00:00
this.$('change-password').show ();
2016-10-14 10:58:35 +00:00
if (recoverPass)
2016-10-11 14:45:10 +00:00
this.$('new-password').focus ();
2016-10-14 10:58:35 +00:00
else
this.$('old-password').focus ();
2016-10-11 14:45:10 +00:00
}
,onPassModifyClick: function ()
2015-03-06 23:33:54 +00:00
{
2016-10-11 14:45:10 +00:00
try {
var oldPassword = this.$('old-password').value;
var newPassword = this.$('new-password').value;
var repeatedPassword = this.$('repeat-password').value;
if (newPassword == '' && repeatedPassword == '')
throw new Error (_('Passwords empty'));
if (newPassword !== repeatedPassword)
throw new Error (_('Passwords doesn\'t match'));
2016-10-27 11:22:04 +00:00
var params = {
2018-01-02 13:16:41 +00:00
oldPassword: oldPassword,
newPassword: newPassword
2016-10-27 11:22:04 +00:00
};
this.conn.send ('core/change-password', params,
this._onPassChange.bind (this));
2016-10-11 14:45:10 +00:00
}
catch (e)
{
2016-10-11 14:45:10 +00:00
Htk.Toast.showError (e.message);
}
}
2016-10-27 11:22:04 +00:00
,_onPassChange: function (json, error)
{
2016-10-27 11:22:04 +00:00
if (json)
{
2016-10-11 14:45:10 +00:00
this.$('change-password').hide ();
Htk.Toast.showMessage (_('Password changed!'));
2016-10-14 10:58:35 +00:00
this.$('user-form').refresh ();
2016-10-11 14:45:10 +00:00
}
2016-10-27 11:22:04 +00:00
else
2016-10-11 14:45:10 +00:00
{
2017-05-02 12:33:48 +00:00
Htk.Toast.showError (error.message);
2016-10-11 14:45:10 +00:00
this.$('old-password').select ();
}
2015-03-06 23:33:54 +00:00
}
2016-10-11 14:45:10 +00:00
,onPassInfoClick: function ()
2015-03-06 23:33:54 +00:00
{
2016-10-11 14:45:10 +00:00
this.$('password-info').show ();
}
2015-07-23 15:58:48 +00:00
,onAddressesClick: function ()
{
2018-01-02 13:16:41 +00:00
this.hash.set ({form: 'account/address-list'});
}
});