X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=htdocs%2Fjavascript%2Fprofile.js;h=3a10c1700580defa8a392778afa7cf95d2d73430;hb=7757efd6c4bf3542c57efa4b248de641b39a7003;hp=ce2273e00ed5474e47ff8237c1cfa9d36ff3225f;hpb=12ddbc2037b16496dfb9d91c4f7091850146fcde;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index ce2273e..3a10c17 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,10 +77,12 @@ 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); + changeNameFlag(i); + }); } function removeSearchName(i, isFemale) @@ -111,11 +119,12 @@ function updateNameDisplay(isFemale) searchnames += $('#search_name_' + i).find(':text').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]); - }); + $.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) @@ -161,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 += ''; } + // XXX: to be removed once SQL table profile_merge_issues is. + if (sel != '' && html == '') { + html += ''; + } $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html); } @@ -194,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); @@ -307,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) @@ -315,24 +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*=geocodedText]').val()); - $('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val()); - } - if (geoloc > 0) { - $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove(); - $('#' + prefid + '_cont').find("[name*='[geocodedPostalText]']").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*=geocodeChosen]').val(geoloc); - $('.' + prefid + '_geoloc').remove(); } // {{{1 Phones -function addTel(prefid, prefname) +function addTel(prefid, prefname, subField, mainField, mainId) { var i = 0; var prefix = prefid + '_'; @@ -340,7 +361,7 @@ 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(prefname, prefid, id) @@ -420,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(); @@ -432,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 :