2010-04-18 15:03:02 +02:00
|
|
|
## -*- coding: utf-8 -*- \
|
2009-01-23 18:03:39 +01:00
|
|
|
<%doc>
|
|
|
|
Helper JavaScript for the data input form.
|
2010-04-18 15:03:02 +02:00
|
|
|
Copyright © 2009, 2010 Jan Dittberner <jan@dittberner.info>
|
2009-01-23 18:03:39 +01:00
|
|
|
|
|
|
|
This file is part of DDPortfolio service.
|
|
|
|
|
|
|
|
DDPortfolio service is free software: you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
DDPortfolio service is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public
|
|
|
|
License along with this program. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>.
|
2010-04-18 15:03:02 +02:00
|
|
|
</%doc>\
|
2009-01-23 18:03:39 +01:00
|
|
|
function updateFields(data, textStatus) {
|
|
|
|
if (data.isdd == 1) {
|
|
|
|
$('#name').attr('value', data.name).attr('readonly', 'readonly');
|
|
|
|
$('#gpgfp').attr('value', data.gpgfp);
|
|
|
|
$('#username').attr('value', data.username).attr(
|
|
|
|
'readonly', 'readonly');
|
|
|
|
$('#nonddemail').attr('value', data.email).focus();
|
|
|
|
$('#aliothusername').attr('value', data.username);
|
|
|
|
|
|
|
|
$('#namefield').show();
|
|
|
|
$('#gpgfpfield').show();
|
|
|
|
$('#usernamefield').show();
|
|
|
|
$('#nonddemailfield').show();
|
|
|
|
$('#aliothusernamefield').show();
|
|
|
|
|
|
|
|
$('#nonddemail').focus().select();
|
|
|
|
} else {
|
|
|
|
$('#nonddemail').attr('value', data.email);
|
|
|
|
$('#name').removeAttr('readonly');
|
|
|
|
$('#username').removeAttr('readonly').attr('value', '');
|
|
|
|
$('#gpgfp').attr('value', '');
|
|
|
|
|
|
|
|
$('#usernamefield').hide();
|
|
|
|
$('#gpgfpfield').hide();
|
|
|
|
$('#nonddemailfield').hide();
|
|
|
|
$('#namefield').show();
|
|
|
|
$('#aliothusernamefield').show();
|
|
|
|
|
|
|
|
$('#name').focus().select();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBlurEmail() {
|
|
|
|
$.ajax({
|
2010-05-03 20:26:07 +02:00
|
|
|
'url' : '${h.url(controller="showformscripts", action="fetchdddata")}',
|
2009-01-23 18:03:39 +01:00
|
|
|
'data' : {'email' : $('#email').attr('value')},
|
|
|
|
'dataType' : 'json',
|
|
|
|
'success' : updateFields,
|
|
|
|
'error' : function(request, textStatus, errorThrown) {
|
|
|
|
$('#email').focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
var fields = new Array(
|
|
|
|
'#namefield', '#usernamefield',
|
|
|
|
'#nonddemailfield', '#aliothusernamefield');
|
|
|
|
for (var index in fields) {
|
|
|
|
if (!$(fields[index]).hasClass('witherrors')) {
|
|
|
|
$(fields[index]).hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#email').blur(onBlurEmail).focus();
|
|
|
|
});
|