'
+ '
'
@@ -172,283 +258,329 @@ function removeNetworking(id)
function updateNetworking(i)
{
- var name = document.getElementById('networking_name_' + i);
- var type = document.getElementById('networking_type_' + i);
- if (type != null && name != null) {
- name.value = type.options[type.selectedIndex].text;
- }
-
+ $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
}
-// Addresses
+// Hobby {{{1
-function removeObject(id, pref)
+function addHobby()
{
- document.getElementById(id).style.display = "none";
- document.forms.prof_annu[pref + "[removed]"].value = "1";
+ var i = 0;
+ while ($('#hobby_' + i).length != 0) {
+ ++i;
+ }
+ var html = '
'
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' | '
+ + '
';
+
+ $('#hobby').before(html);
}
-function restoreObject(id, pref)
+function removeHobby(id)
{
- document.getElementById(id).style.display = '';
- document.forms.prof_annu[pref + "[removed]"].value = "0";
+ $('#hobby_' + id).remove();
}
-function getAddressElement(adrid, adelement)
+// Addresses {{{1
+
+function toggleAddress(id, val)
{
- return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
+ $('#addresses_' + id + '_grayed').toggle();
+ $('#addresses_' + id).toggle();
+ $('#addresses_' + id + '_cont').find('[name*=removed]').val(val);
+ checkCurrentAddress();
}
-function checkCurrentAddress(newCurrent)
+function checkCurrentAddress(id)
{
- var hasCurrent = false;
+ var hasCurrentAddress = id ? true : false;
var i = 0;
- while (getAddressElement(i, 'pub') != null) {
- var radio = getAddressElement(i, 'current');
- var removed = getAddressElement(i, 'removed');
- if (removed.value == "1" && radio.checked) {
- radio.checked = false;
- } else if (radio.checked && radio != newCurrent) {
- radio.checked = false;
- } else if (radio.checked) {
- hasCurrent = true;
+ while ($('#addresses_' + i + '_cont').length != 0) {
+ if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 1) {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
+ }
+ if (!hasCurrentAddress && $('#addresses_' + i + '_cont').find('[name*=current]:checked').length != 0) {
+ hasCurrentAddress = true;
+ } else {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
}
i++;
}
- if (!hasCurrent) {
+ if (!hasCurrentAddress) {
i = 0;
- while (getAddressElement(i, 'pub') != null) {
- var radio = getAddressElement(i, 'current');
- var removed = getAddressElement(i, 'removed');
- if (removed.value != "1") {
- radio.checked= true;
- return;
- }
- i++;
+ while ($('#addresses_' + i + '_cont').length != 0) {
+ if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 0) {
+ $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', 'checked');
+ break;
+ }
+ i++;
}
}
-}
-
-function removeAddress(id, pref)
-{
- removeObject(id, pref);
- checkCurrentAddress(null);
- if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
- document.getElementById(id + '_grayed').style.display = '';
+ if (id) {
+ $('#addresses_' + id + '_cont').find('[name*=current]').attr('checked', 'checked');
}
}
-function restoreAddress(id, pref)
+function addAddress(pid)
{
- document.getElementById(id + '_grayed').style.display = 'none';
- checkCurrentAddress(null);
- restoreObject(id, pref);
+ var i = 0;
+ while ($('#addresses_' + i + '_cont').length != 0) {
+ i++;
+ }
+ $('#add_address').before('
');
+ $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i + '/' + pid,
+ checkCurrentAddress());
+}
+
+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 addAddress()
+function deleteGeocoding(prefid)
{
- var i = 0;
- while (getAddressElement(i, 'pub') != null) {
- i++;
+ if($('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox:checked').length == 0) {
+ return true;
}
- $("#add_adr").before('
');
- Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
+
+ 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 ?");
}
-function addTel(prefid, prefname)
+// {{{1 Phones
+
+function addTel(prefid, prefname, subField, mainField, mainId)
{
var i = 0;
var prefix = prefid + '_';
- while (document.getElementById(prefix + i) != null) {
+ while ($('#' + prefix + i).length != 0) {
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, pref)
+function addPhoneComment(id)
{
- document.getElementById(id+'_comment').style.display = '';
- document.getElementById(id+'_addComment').style.display = 'none';
+ $('#' + id + '_comment').show();
+ $('#' + id + '_addComment').hide();
}
function removePhoneComment(id, pref)
{
- document.getElementById(id+'_comment').style.display = 'none';
- document.forms.prof_annu[pref+ '[comment]'].value = '';
- document.getElementById(id+'_addComment').style.display = '';
+ $('#' + id + '_comment').hide();
+ $('#' + id + '_comment').find("[name='" + pref + "[comment]']").val('');
+ $('#' + id + '_addComment').show();
}
-// Geoloc
-
-function validGeoloc(id, pref)
+function renumberPhone(prefname, prefid, i)
{
- document.getElementById(id + '_geoloc').style.display = 'none';
- document.getElementById(id + '_geoloc_error').style.display = 'none';
- document.getElementById(id + '_geoloc_valid').style.display = 'none';
- document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
- document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
- document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value;
- attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
- function() { document.forms.prof_annu[pref + "[text]"].blur(); });
- document.forms.prof_annu[pref + "[text]"].className = '';
-}
+ var telid = i - 1;
+ var telprefOld = prefname + '[' + i + ']';
+ var telpref = prefname + '[' + telid + ']';
+ var idOld = prefid + '_' + i;
+ var id = prefid + '_' + telid;
-function validAddress(id, pref)
-{
- document.getElementById(id + '_geoloc').style.display = 'none';
- document.getElementById(id + '_geoloc_error').style.display = 'none';
- document.getElementById(id + '_geoloc_valid').style.display = 'none';
- document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
- attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
- function() { document.forms.prof_annu[pref + "[text]"].blur(); });
- document.forms.prof_annu[pref + "[text]"].className = '';
+ $('#' + 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
-// Groups
-
-function updateGroup(type)
+function addBinet()
{
- var val = document.forms.prof_annu[type + '_sel'].value;
- if (val == '0' || document.getElementById(type + '_' + val) != null) {
- document.getElementById(type + '_add').style.display = 'none';
- } else {
- document.getElementById(type + '_add').style.display = '';
- }
+ var id = $('#binets_table').find('[name=binets_sel]').val();
+ var text = $('#binets_table').find('select option:selected').text();
+ var html = '
'
+ + ' '
+ + ' '
+ + ' | '
+ + ' '
+ + ' '
+ + text
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' | '
+ + '
';
+ $('#binets_table').after(html);
+ updateElement('binets');
}
-function removeGroup(cat, id)
+function updateGroupSubLink()
{
- $('#' + cat + '_' + id).remove();
- updateGroup(cat);
+ var href = $('[name*=groupesx_sub]').val() ? $('[name*=groupesx_sub]').val() : 'http://www.polytechnique.net';
+ $('#groupesx_sub').attr('href', href);
}
-function addGroup(cat)
-{
- var cb = document.forms.prof_annu[cat + '_sel'];
- var id = cb.value;
- var text = cb.options[cb.selectedIndex].text;
- var html = '
'
- + ' '
- + ' '
- + ' | '
- + ' '
- + ' '
- + text
- + ' '
- + ' '
- + ' '
- + ' '
- + ' | '
- + '
';
- $('#' + cat).after(html);
- updateGroup(cat);
-}
+// {{{1 Medals
-function updateGroupSubLink(cb)
+function prepareMedal(i)
{
- var href = cb.value ? cb.value : "http://www.polytechnique.net";
- document.getElementById("groupesx_sub").href = href;
+ getMedalName($('#medal_' + i).find('[name="medals[' + i + '][id]"]').val());
+ buildGrade(i);
}
-
-// Medals
-
function updateMedal()
{
- var val = document.forms.prof_annu['medal_sel'].value;
- if (val == '' || document.getElementById('medal_' + val) != null) {
- document.getElementById('medal_add').style.display = 'none';
+ var val = $('#medals').find('[name*=medal_sel]').val();
+
+ if ((multiple[val] && subgrades[val]) || $('.medal_name_' + val).length == 0) {
+ $('#medal_add').show();
} else {
- document.getElementById('medal_add').style.display = '';
+ $('#medal_add').hide();
}
}
function getMedalName(id)
{
- document.getElementById('medal_name_' + id).innerHTML = 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 :