X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=6858861451ddbcf827a6478f986e777a11c6b51c;hb=8fcfc71f92d6f96e97c46413af0382d8a2e5cc1e;hp=f0ca309b4487c23c9c9bbdabb4f389b93e3fe95e;hpb=46ca73eadbd598ee219bdc48724e14c8c08b40ef;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index f0ca309..6858861 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -37,11 +37,10 @@ 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': @@ -57,6 +56,7 @@ var educationDegreeAll; var educationDegreeName; var subgrades; var names; +var multiples; // Publicity follows the following ordering: private < ax < public. var publicity = []; @@ -77,12 +77,10 @@ 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) @@ -91,34 +89,29 @@ 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(' ' + - 'site public' + - '' + - '' + - ''); - } else { - $('#flag_cb_' + i).after(' ' + - 'site privé' + - '' + - ''); - } -} - 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(';'); @@ -127,15 +120,6 @@ function updateNameDisplay(isFemale) }); } -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() @@ -277,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 = '' + + ' ' + + '
' + + ' ' + + ' ' + + ' site public' + + '  ' + + ' ' + + '
' + + '
' + + ' ' + + ' ' + + ' cross' + + ' ' + + '
' + + ' ' + + ''; + + $('#hobby').before(html); +} + +function removeHobby(id) +{ + $('#hobby_' + id).remove(); +} + // Addresses {{{1 function toggleAddress(id, val) @@ -317,34 +339,46 @@ function checkCurrentAddress(id) } } -function addAddress() +function addAddress(pid) { var i = 0; while ($('#addresses_' + i + '_cont').length != 0) { i++; } $('#add_address').before('
'); - $('#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 validGeoloc(prefid, id, geoloc) +function deleteGeocoding(prefid) { - if (geoloc == 1) { - $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val()); - $('#' + prefid + '_cont').find('[name*=postalText]').val(''); + if($('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox:checked').length == 0) { + return true; } - if (geoloc > 0) { - $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove(); - } - $('#' + prefid + '_cont').find('[name*=text]').removeClass('error'); - $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc); - $('.' + prefid + '_geoloc').remove(); + + 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. " + + "\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 ?"); } // {{{1 Phones @@ -437,10 +471,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(); @@ -449,55 +490,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 += '