// Names {{{1
-function toggleNamesAdvanced()
+function toggleNamesAdvanced(togglePrivate)
{
- $('.names_advanced').toggle();
+ $('.names_advanced_public').toggle();
+ if (togglePrivate) {
+ $('.names_advanced_private').toggle();
+ }
}
function addSearchName(isFemale)
while ($('#search_name_' + i).length != 0) {
i++;
}
- $('#search_name_' + i)
- .updateHtml('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);
+ });
}
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('<span id="flag_' + i + '"> ' +
- '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
- '<input type="hidden" name="search_names[' + i + '][pub]" value="1"/>' +
- '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
- '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
- } else {
- $('#flag_cb_' + i).after('<span id="flag_' + i + '"> ' +
- '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
- '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
- '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
- }
-}
-
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++) {
+
+ for (var i = 0; i < 4; ++i) {
+ searchnames += $('.names_advanced').find('[name*=' + lastnames[i] + ']').val() + ';';
+ }
+ searchnames += '-;'
+ for (var i = 0; i < 2; ++i) {
+ searchnames += $('.names_advanced').find('[name*=' + firstnames[i] + ']').val() + ';';
+ }
+ searchnames += '-';
+
+ var has_private = false;
+ 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() + ';;';
+ 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(';');
});
}
-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('');
- }
-}
-
// Promotions {{{1
function togglePromotionEdition()
$('#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 = '<tr id="hobby_' + i + '">'
+ + ' <td colspan="2">'
+ + ' <div style="float: left; width: 200px;">'
+ + ' <span class="flags">'
+ + ' <input type="checkbox" name="hobbies[' + i + '][pub]"/>'
+ + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
+ + ' </span> '
+ + ' <select name="hobbies[' + i + '][type]">'
+ + ' <option value="Sport">Sport</option>'
+ + ' <option value="Loisir">Loisir</option>'
+ + ' <option value="Hobby">Hobby</option>'
+ + ' </select>'
+ + ' </div>'
+ + ' <div style="float: left">'
+ + ' <input type="text" name="hobbies[' + i + '][text]" value="" size="30"/>'
+ + ' <a href="javascript:removeHobby(' + i + ')">'
+ + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
+ + ' </a>'
+ + ' </div>'
+ + ' </td>'
+ + '</tr>';
+
+ $('#hobby').before(html);
+}
+
+function removeHobby(id)
+{
+ $('#hobby_' + id).remove();
+}
+
// Addresses {{{1
function toggleAddress(id, val)
}
}
-function addAddress()
+function addAddress(pid)
{
var i = 0;
while ($('#addresses_' + i + '_cont').length != 0) {
i++;
}
$('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
- $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i,
+ $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i + '/' + pid,
checkCurrentAddress());
}
-function addressChanged(prefid)
+function addressChanged(prefid, color)
{
+ var text = $('#' + prefid + '_cont').find("[name*='[text]']").val();
$('#' + prefid + '_cont').find('[name*=changed]').val("1");
+ $.xpost('map_url/', { text:text, color:color }, function(data) {
+ if (data) {
+ $('#' + prefid + '_static_map_url').show();
+ $('#' + prefid + '_static_map_url').find('img').attr('src', data);
+ } else {
+ $('#' + prefid + '_static_map_url').hide();
+ $('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox').removeAttr('checked');
+ }
+ });
}
-function deleteGeocoding()
+function deleteGeocoding(prefid)
{
- var confirmation = confirm(
+ if($('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox:checked').length == 0) {
+ return true;
+ }
+
+ return confirm(
"La localisation de l'adresse sert à deux choses : te placer dans "
+ "le planisphère et te faire apparaître dans la recherche avancée par "
- + "pays, région, département, ville. La supprimer t'en fera disparaître. "
+ + "pays, région, département, ville... La supprimer t'en fera disparaître. "
+ "\nIl ne faut le faire que si cette localisation "
+ "est réellement erronée. Avant de supprimer cette localisation, l'équipe de "
+ "Polytechnique.org tentera de la réparer.\n\nConfirmes-tu ta "
+ "demande de suppression de cette localisation ?");
- if (confirmation) {
- alert('Warning: not implemented yet.');
- }
}
// {{{1 Phones
};
}
-function addJob()
+function addJob(pid)
{
var i = 0;
while ($('#jobs_' + i).length != 0) {
++i;
}
- $.xget('profile/ajax/job/' + i, makeAddJob(i));
+ $.xget('profile/ajax/job/' + i + '/' + pid, makeAddJob(i));
}
function addEntreprise(id)
}
/**
- * Prepare display for autocomplete suggestions in job terms
- * @param row an array of (title of term, id of term)
- * @return text to display
- * If id is negative, it is because there are too much terms to
- * be displayed.
- */
-function displayJobTerm(row)
-{
- if (row[1] < 0) {
- return '... <em>parcourir les résultats dans un arbre</em> ...';
- }
- return row[0];
-}
-
-/**
* Function called when a job term has been selected from autocompletion
* in search
* @param li is the list item (<li>) that has been clicked
* The context is the jsquery autocomplete object.
*/
-function selectJobTerm(li)
+function selectJobTerm(id, value, jobid)
{
- var jobid = this.extraParams.jobid;
- if (li.extra[0] >= 0) {
- addJobTerm(jobid,li.extra[0],$(li).text());
+ if (id >= 0) {
+ addJobTerm(jobid, id, value);
}
var search_input;
if (jobid < 0) {
search_input = $('.term_search')[0];
} else {
- search_input = $('#jobs_'+jobid+' .term_search')[0];
+ search_input = $('#jobs_' + jobid + ' .term_search')[0];
}
- if (li.extra[0] >= 0) {
+ if (id >= 0) {
search_input.value = '';
search_input.focus();
} else {
- search_input.value = li.selectValue.replace(/%$/,'');
- toggleJobTermsTree(jobid, li.selectValue);
+ search_input.value = value.replace(/%$/, '');
+ toggleJobTermsTree(jobid, ''); // Use given value instead
}
}
function registerEnterpriseAutocomplete(id)
{
- $(".enterpriseName").each(
- function() {
+ $('.enterprise_name').each(function() {
if (id == -1 || this.name == "jobs[" + id + "][name]") {
- $(this).autocomplete($.plURL("search/autocomplete/entreprise"),
- {
- selectOnly:1,
- field:this.name,
- matchSubset:0,
- width:$(this).width()
- });
- }
- });
-
- $(".sectorName").each(
- function() {
- if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") {
- $(this).autocomplete($.plURL("search/autocomplete/subSubSector"),
- {
- selectOnly:1,
- field:this.name,
- matchSubset:0,
- width:$(this).width()
- });
+ $(this).autocomplete({
+ source: $.plURL('search/autocomplete/entreprise/') + this.name,
+ change: function(event, ui) {
+ if (ui.item != null && ui.item.field != null) {
+ $(this).val(ui.item.field);
+ }
+ }
+ });
}
- });
+ });
}
// {{{1 Multiusage functions