X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=3a10c1700580defa8a392778afa7cf95d2d73430;hb=57fa97b3b0820a76b26a1d17c078c3663b161922;hp=a85063bfabe658ae374c8f9088dba9e47fce719e;hpb=3f5cf357e7ab02c9cbf616bc8cc3a70278af62cc;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index a85063b..3a10c17 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2009 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,18 +37,15 @@ 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': - for (var i = 0 ; $('#job_' + i).length != 0; ++i) { - updateJobSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSector]']").val()); - updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubSector]']").val()); - updateJobAlternates(i); + if ($('#jobs_0').find("[name='jobs[0][name]']").val() == '') { + registerEnterpriseAutocomplete(0); } break; } @@ -59,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 @@ -67,22 +71,24 @@ function toggleNamesAdvanced() $('.names_advanced').toggle(); } -function addSearchName() +function addSearchName(isFemale) { var i = 0; while ($('#search_name_' + i).length != 0) { i++; } - Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){ - $('#searchname').before(data); - changeNameFlag(i); - }); + $('#search_name_' + i) + .updateHtml('profile/ajax/searchname/' + i + '/' + isFemale, + function(data) { + $('#searchname').before(data); + changeNameFlag(i); + }); } -function removeSearchName(i) +function removeSearchName(i, isFemale) { $('#search_name_' + i).remove(); - updateNameDisplay(); + updateNameDisplay(isFemale); } function changeNameFlag(i) @@ -104,7 +110,7 @@ function changeNameFlag(i) } } -function updateNameDisplay() +function updateNameDisplay(isFemale) { var searchnames = ''; for (var i = 0; i < 10; i++) { @@ -113,11 +119,12 @@ function updateNameDisplay() searchnames += $('#search_name_' + i).find(':text').val() + ';;'; } } - Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){ - var name = data.split(';'); - $('#public_name').html(name[0]); - $('#private_name').html(name[0] + name[1]); - }); + $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale, + function(data){ + var name = data.split(';'); + $('#public_name').html(name[0]); + $('#private_name').html(name[0] + name[1]); + }); } function toggleParticle(id) @@ -129,23 +136,30 @@ function toggleParticle(id) } } +// Promotions {{{1 + +function togglePromotionEdition() +{ + $(".promotion_edition").toggle(); +} + // Nationalities {{{1 function delNationality(i) { - $('#nationalite' + i).hide().find('select').val(''); + $('#nationality' + i).hide().find('select').val(''); } function addNationality() { var i = 0; - if ($('#nationalite2').find('select').val() == "") { + if ($('#nationality2').find('select').val() == "") { i = 2; - } else if ($('#nationalite3').find('select').val() == "") { + } else if ($('#nationality3').find('select').val() == "") { i = 3; } if ((i == 2) || (i == 3)) { - $('#nationalite' + i).show(); + $('#nationality' + i).show(); } } @@ -156,7 +170,11 @@ function prepareType(id) var edu = $('.edu_' + id).find("[name='edus[" + id + "][eduid]']").val() - 1; var sel = $('.edu_' + id).find('[name=edu_' + id + '_tmp]').val(); var html = ''; - var length = educationDegree[edu].length; + if (educationDegree[edu]) { + var length = educationDegree[edu].length; + } else { + var length = 0; + } for (i = 0; i < length; ++i) { html += ''; + } $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html); } @@ -189,7 +211,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); @@ -302,7 +324,8 @@ function addAddress() i++; } $('#add_address').before('
'); - Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress()); + $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i, + checkCurrentAddress()); } function addressChanged(prefid) @@ -310,23 +333,27 @@ function addressChanged(prefid) $('#' + prefid + '_cont').find('[name*=changed]').val("1"); } -function validGeoloc(prefid, id, geoloc) +function deleteGeocoding(prefid, hrpid) { - if (geoloc == 1) { - $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geoloc]').val()); - $('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val()); - } - if (geoloc > 0) { - $('#' + prefid + '_cont').find("[name*='[geoloc]']").remove(); + var confirmation = 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. " + + "\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) { + var address = $('#' + prefid).find("[name*='[text]']").val(); + $.xpost('profile/ajax/address/del/' + hrpid, { address:address }); + $('#' + prefid + '_geocoding_removal').html('Localisation en attente de validation.'); } - $('#' + prefid + '_cont').find('[name*=text]').removeClass('error'); - $('#' + prefid + '_cont').find('[name*=geoloc_choice]').val(geoloc); - $('.' + prefid + '_geoloc').remove(); } // {{{1 Phones -function addTel(prefid, prefname) +function addTel(prefid, prefname, subField, mainField, mainId) { var i = 0; var prefix = prefid + '_'; @@ -334,12 +361,19 @@ function addTel(prefid, prefname) i++; } $('#' + prefix + 'add').before('
'); - Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); + $('#' + prefix + i).updateHtml('profile/ajax/tel/' + prefid + '/' + prefname + '/' + i + '/' + subField + '/' + mainField + '/' + mainId); } -function removeTel(id) +function removeTel(prefname, prefid, id) { - $('#' + id).remove(); + var total = 0; + while ($('#' + prefid + '_' + total).length != 0) { + ++total; + } + $('#' + prefid + '_' + id).remove(); + for (var i = parseInt(id) + 1; i < total; ++i) { + renumberPhone(prefname, prefid, i); + } } function addPhoneComment(id) @@ -355,6 +389,27 @@ function removePhoneComment(id, pref) $('#' + id + '_addComment').show(); } +function renumberPhone(prefname, prefid, i) +{ + var telid = i - 1; + var telprefOld = prefname + '[' + i + ']'; + var telpref = prefname + '[' + telid + ']'; + var idOld = prefid + '_' + i; + var id = prefid + '_' + telid; + + $('#' + idOld).attr('id', id); + $('#' + id).find('div.titre').html('N°' + i); + $('#' + id).find('a.removeTel').attr('href', 'javascript:removeTel(\'' + prefname + '\',\'' + prefid + '\',' + telid + ')'); + $('#' + id).find('select').attr('name', telpref + '[type]'); + $('#' + id).find("[name='" + telprefOld + "[display]']").attr('name', telpref + '[display]'); + $('#' + id).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]'); + $('#' + id).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')'); + $('#' + id).find('#' + idOld + '_addComment').attr('id', id + '_addComment'); + $('#' + id).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')'); + $('#' + id).find('#' + idOld + '_comment').attr('id', id + '_comment'); + $('#' + id).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]'); +} + // {{{1 Groups function addBinet() @@ -369,7 +424,7 @@ function addBinet() + '
' + text + '
' - + ' ' + + ' ' + ' cross' + ' ' + ' ' @@ -386,10 +441,17 @@ function updateGroupSubLink() // {{{1 Medals +function prepareMedal(i) +{ + getMedalName($('#medal_' + i).find('[name="medals[' + i + '][id]"]').val()); + buildGrade(i); +} + function updateMedal() { var val = $('#medals').find('[name*=medal_sel]').val(); - if (val && ($('#medal_' + val).length == 0)) { + + if ((multiple[val] && subgrades[val]) || $('.medal_name_' + val).length == 0) { $('#medal_add').show(); } else { $('#medal_add').hide(); @@ -398,55 +460,80 @@ function updateMedal() function getMedalName(id) { - $('#medal_name_' + id).html(names[id]); + $('.medal_name_' + id).html(names[id]); } -function buildGrade(id, current) +function buildGrade(i) { - var grade; - var subg = subgrades[id]; - var obj = $('#medal_grade_' + id); + var id = $('#medal_' + i).find('[name="medals[' + i + '][id]"]').val(); + var current = $('#medal_' + i).find('[name="medals_' + i + '_grade"]').val(); + var subg = subgrades[id]; + var obj = $('#medal_grade_' + i); if (!subg) { - obj.prepend(''); + obj.prepend(''); } else { - var html = 'Agrafe : '; html += ''; - for (grade = 0 ; grade < subg.length ; grade++) { + for (var grade = 0; grade < subg.length; ++grade) { html += '