X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=6858861451ddbcf827a6478f986e777a11c6b51c;hb=8fcfc71f92d6f96e97c46413af0382d8a2e5cc1e;hp=dcd3fec9d4eab37d8ade37e2f6c91c72eeea927d;hpb=7f7b00425f9cb2dc2a611cd1ca985813893d5bfe;p=platal.git
diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js
index dcd3fec..6858861 100644
--- a/htdocs/javascript/profile.js
+++ b/htdocs/javascript/profile.js
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,15 +37,14 @@ function wizPage_onLoad(id)
updateGroupSubLink();
break;
case 'deco':
- for (var i in names) {
- if ($('#medal_' + i).length != 0) {
- getMedalName(i);
- buildGrade(i, $('#medal_' + i).find('[name*=medal_' + i + '_grade]').val());
- }
+ var i = 0;
+ while ($('#medal_' + i).length != 0) {
+ prepareMedal(i);
+ ++i;
}
break;
case 'emploi':
- if ($('#job_0').find("[name='jobs[0][name]']").val() == '') {
+ if ($('#jobs_0').find("[name='jobs[0][name]']").val() == '') {
registerEnterpriseAutocomplete(0);
}
break;
@@ -57,6 +56,13 @@ var educationDegreeAll;
var educationDegreeName;
var subgrades;
var names;
+var multiples;
+
+// Publicity follows the following ordering: private < ax < public.
+var publicity = [];
+publicity['private'] = 0;
+publicity['ax'] = 1;
+publicity['public'] = 2;
// Names {{{1
@@ -71,9 +77,9 @@ function addSearchName(isFemale)
while ($('#search_name_' + i).length != 0) {
i++;
}
- Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i + '/' + isFemale, function(data){
- $('#searchname').before(data);
- changeNameFlag(i);
+ $('#search_name_' + i).updateHtml('profile/ajax/searchname/' + i + '/' + isFemale,
+ function(data) {
+ $('#searchname').before(data);
});
}
@@ -83,48 +89,35 @@ function removeSearchName(i, isFemale)
updateNameDisplay(isFemale);
}
-function changeNameFlag(i)
-{
- $('#flag_' + i).remove();
- var typeid = $('#search_name_' + i).find('select').val();
- var type = $('#search_name_' + i).find('select :selected').text();
- if ($('[name=sn_type_' + typeid + '_' + i + ']').val() > 0) {
- $('#flag_cb_' + i).after(' ' +
- '' +
- '' +
- '' +
- '');
- } else {
- $('#flag_cb_' + i).after(' ' +
- '
' +
- '' +
- '');
- }
-}
-
function updateNameDisplay(isFemale)
{
+ var lastnames = new Array('lastname_main', 'lastname_ordinary', 'lastname_marital', 'pseudonym');
+ var firstnames = new Array('firstname_main', 'firstname_ordinary');
var searchnames = '';
- for (var i = 0; i < 10; i++) {
- if ($('#search_name_' + i).find(':text').val()) {
- searchnames += $('#search_name_' + i).find('[name*=typeid]').val() + ';';
- searchnames += $('#search_name_' + i).find(':text').val() + ';;';
- }
+
+ for (var i = 0; i < 4; ++i) {
+ searchnames += $('.names_advanced').find('[name*=' + lastnames[i] + ']').val() + ';';
}
- Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames + '/' + isFemale, function(data){
- var name = data.split(';');
- $('#public_name').html(name[0]);
- $('#private_name').html(name[0] + name[1]);
- });
-}
+ searchnames += '-;'
+ for (var i = 0; i < 2; ++i) {
+ searchnames += $('.names_advanced').find('[name*=' + firstnames[i] + ']').val() + ';';
+ }
+ searchnames += '-';
-function toggleParticle(id)
-{
- if ($('#search_name_' + id).find("[name*='[particle]']").val() == '') {
- $('#search_name_' + id).find("[name*='[particle]']").val(1);
- } else {
- $('#search_name_' + id).find("[name*='[particle]']").val('');
+ var has_private = false;
+ for (var i = 0; i < 10; ++i) {
+ if ($('#search_name_' + i).find(':text').val()) {
+ searchnames += ';' + $('#search_name_' + i).find('[name*=type]').val() + ';' + $('#search_name_' + i).find(':text').val();
+ has_private = true;
+ }
}
+ searchnames += (has_private ? '' : ';');
+ $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale,
+ function(data){
+ var name = data.split(';');
+ $('#public_name').html(name[0]);
+ $('#private_name').html(name[0] + name[1]);
+ });
}
// Promotions {{{1
@@ -202,7 +195,7 @@ function addEdu()
i++;
$('#edu_add').addClass(prefix + i);
i--;
- $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
+ $.xget('profile/ajax/edu/' + i + '/' + class_parity,
function(data) {
$('#edu_add').before(data);
prepareType(i);
@@ -268,6 +261,44 @@ function updateNetworking(i)
$('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
}
+// Hobby {{{1
+
+function addHobby()
+{
+ var i = 0;
+ while ($('#hobby_' + i).length != 0) {
+ ++i;
+ }
+ var html = '