'
+ '
'
@@ -276,12 +259,7 @@ 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 {{{1
@@ -334,20 +312,23 @@ function addAddress()
Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
}
-function addressChanged(id)
+function addressChanged(prefid)
{
- $('#addresses_' + id + '_cont').find('[name*=changed]').val("1");
+ $('#' + prefid + '_cont').find('[name*=changed]').val("1");
}
-function validGeoloc(id, geoloc)
+function validGeoloc(prefid, id, geoloc)
{
if (geoloc == 1) {
- $('#addresses_' + id + '_cont').find('[name*=text]').val($('#addresses_' + id + '_cont').find('[name*=geoloc]').val());
- $('#addresses_' + id + '_cont').find('[name*=postalText]').val($('#addresses_' + id + '_cont').find('[name*=geocodedPostalText]').val());
+ $('#' + 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();
}
- $('#addresses_' + id + '_cont').find('[name*=text]').removeClass('error');
- $('#addresses_' + id + '_cont').find('[name*=geoloc_choice]').val(geoloc);
- $('.addresses_' + id + '_geoloc').remove();
+ $('#' + prefid + '_cont').find('[name*=text]').removeClass('error');
+ $('#' + prefid + '_cont').find('[name*=geoloc_choice]').val(geoloc);
+ $('.' + prefid + '_geoloc').remove();
}
// {{{1 Phones
@@ -356,92 +337,103 @@ function addTel(prefid, prefname)
{
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);
}
-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();
}
-// Groups {{{1
-
-function updateGroup(type)
+function renumberPhone(prefname, prefid, i)
{
- 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 telid = i - 1;
+ var telprefOld = prefname + '[' + i + ']';
+ var telpref = prefname + '[' + telid + ']';
+ var idOld = prefid + '_' + i;
+ var id = prefid + '_' + telid;
-function removeGroup(cat, id)
-{
- $('#' + cat + '_' + id).remove();
- updateGroup(cat);
+ $('#' + 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]');
}
-function addGroup(cat)
+// {{{1 Groups
+
+function addBinet()
{
- 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);
+ 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 updateGroupSubLink(cb)
+function updateGroupSubLink()
{
- var href = cb.value ? cb.value : "http://www.polytechnique.net";
- document.getElementById("groupesx_sub").href = href;
+ var href = $('[name*=groupesx_sub]').val() ? $('[name*=groupesx_sub]').val() : 'http://www.polytechnique.net';
+ $('#groupesx_sub').attr('href', href);
}
-// Medals {{{1
+// {{{1 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 (val && ($('#medal_' + 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)
@@ -480,7 +472,7 @@ function makeAddProcess(id)
function addMedal()
{
- var id = document.forms.prof_annu['medal_sel'].value;
+ var id = $('#medals').find('[name=medal_sel]').val();
$.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
}
@@ -494,38 +486,55 @@ function removeMedal(id)
function removeJob(id, pref)
{
- document.getElementById(id + '_cont').style.display = 'none';
- if (document.forms.prof_annu[pref + '[new]'].value == '0') {
- document.getElementById(id + '_grayed').style.display = '';
- document.getElementById(id + '_grayed_name').innerHTML =
- document.forms.prof_annu[pref + "[name]"].value.replace('<', '<');
+ $('#' + id + '_cont').hide();
+ if ($('#' + id).find("[name='" + pref + "[new]']").val() == '0') {
+ $('#' + id + '_grayed').show();
+ $('#' + id + '_grayed_name').html($('#' + id).find("[name='" + pref + "[name]']").val());
}
- document.forms.prof_annu[pref + "[removed]"].value = "1";
+ $('#' + id).find("[name='" + pref + "[removed]']").val('1');
}
function restoreJob(id, pref)
{
- document.getElementById(id + '_cont').style.display = '';
- document.getElementById(id + '_grayed').style.display = 'none';
- document.forms.prof_annu[pref + "[removed]"].value = "0";
+ $('#' + id + '_cont').show();
+ $('#' + id + '_grayed').hide();
+ $('#' + id).find("[name='" + pref + "[removed]']").val('0');
}
-function updateJobSecteur(nb, id, pref, sel)
+function updateJobSector(id, sel)
{
- var secteur = document.forms.prof_annu[pref + '[secteur]'].value;
- if (secteur == '') {
- secteur = '-1';
+ var sector = $('#job_' + id).find("[name='jobs[" + id + "][sector]']").val();
+ if (sector == '') {
+ sector = '-1';
}
- Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id + '/' + pref + '/' + secteur + '/' + sel);
+ Ajax.update_html('job_' + id + '_subSector', 'profile/ajax/sector/' + id + '/job_' + id + '/jobs[' + id + ']/' + sector + '/' + sel);
}
-function updateJobSousSecteur(nb, id, pref, sel)
+function updateJobSubSector(id, sel)
{
- var ssecteur = document.forms.prof_annu[pref + '[ss_secteur]'].value;
- if (ssecteur == '') {
- ssecteur = '-1';
+ var subSector = $('#job_' + id).find("[name='jobs[" + id + "][subSector]']").val();
+ if (subSector == '') {
+ subSector = '-1';
}
- Ajax.update_html(id + '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur + '/' + sel);
+ Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/' + subSector + '/' + sel);
+}
+
+function updateJobAlternates(id)
+{
+ var subSubSector = $('#job_' + id).find("[name='jobs[" + id + "][subSubSector]']").val();
+ if (subSubSector != '') {
+ Ajax.update_html('job_' + id + '_alternates', 'profile/ajax/alternates/' + id + '/' + subSubSector);
+ }
+}
+
+function emptyJobSubSector(id)
+{
+ Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/-1/-1');
+}
+
+function emptyJobAlternates(id)
+{
+ Ajax.update_html('job_' + id + '_alternates', 'profile/ajax/alternates/' + id + '/-1');
}
function displayAllSector(id)
@@ -540,14 +549,13 @@ function makeAddJob(id)
{
$('#add_job').before(data);
registerEnterpriseAutocomplete(id);
- updateSecteur('job_' + id, 'jobs[' + id + ']', '');
};
}
function addJob()
{
var i = 0;
- while (document.getElementById('job_' + i) != null) {
+ while ($('#job_' + i).length != 0) {
++i;
}
$.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
@@ -560,162 +568,132 @@ function addEntreprise(id)
// {{{1 Skills
-function updateSkill(cat)
-{
- var val = document.forms.prof_annu[cat + '_sel'].value;
- var show = true;
- if (val == '') {
- show = false;
- }
- if (document.getElementById(cat + '_' + val) != null) {
- show = false;
- }
- document.getElementById(cat + '_add').style.display = show ? '' : 'none';
-}
-
function addSkill(cat)
{
- var sel = document.forms.prof_annu[cat + '_sel'];
- var val = sel.value;
- var text = sel.options[sel.selectedIndex].text;
+ var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
+ var text = $('#' + cat + '_table').find('[name=' + cat + '_sel] :selected').text();
$.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
function(data) {
- $('#' + cat).append(data);
- document.getElementById(cat + '_' + val + '_title').innerHTML = text;
- updateSkill(cat);
+ $('#' + cat).append(data);
+ $('#' + cat + '_' + val + '_title').text(text);
+ updateElement(cat);
});
}
-function removeSkill(cat, id)
-{
- $('#' + cat + '_' + id).remove();
- updateSkill(cat);
-}
-
-// Mentor {{{1
-
-function updateCountry()
-{
- var val = document.forms.prof_annu.countries_sel.value;
- var show = true;
- if (val == '' || val == '00') {
- show = false;
- }
- if (document.getElementById('countries_' + val) != null) {
- show = false;
- }
- document.getElementById('countries_add').style.display = show ? '' : 'none';
-}
+// {{{1 Mentor
function addCountry()
{
- var cb = document.forms.prof_annu.countries_sel;
- var val = cb.value;
- var text = cb.options[cb.selectedIndex].text;
+ var val = $('#countries_table').find('[name=countries_sel] :selected').val();
+ var text = $('#countries_table').find('[name=countries_sel] :selected').text();
var html = '
';
$('#countries').append(html);
- updateCountry();
+ updateElement('countries');
}
-function removeCountry(id)
+function updateSubSector()
{
- $('#countries_' + id).remove();
- updateCountry();
+ var s = $('#sectorSelection').find('[name=sectorSelection]').val();
+ var ss = $('#subSectorSelection').find("[name='jobs[-1][subSector]']").val();
+ if ((s == '' || ss == '') || $('#sectors_' + s + '_' + ss).length != 0) {
+ $('#addSector').hide();
+ } else {
+ $('#addSector').show();
+ }
}
-function updateSSecteur()
+
+function removeSector(s, ss)
{
- var s = document.forms.prof_annu.secteur_sel.value;
- var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value;
- var show = true;
- if (s == '' || ss == '') {
- show = false;
- }
- if (document.getElementById('secteurs_' + s + '_' + ss) != null) {
- show = false;
- }
- document.getElementById('secteurs_add').style.display = show ? 'block' : 'none';
+ $('#sectors_' + s + '_' + ss).remove();
+ updateSubSector();
}
-function updateSecteur()
+function updateSector()
{
- var secteur = document.forms.prof_annu.secteur_sel.value;
- if (secteur == '') {
- secteur = '-1';
- document.getElementById('ss_secteur_sel').innerHTML = '';
+ var sector = $('#sectorSelection').find('[name=sectorSelection]').val();
+ if (sector == '') {
+ sector = '-1';
+ $('#subSectorSelection').html('');
return;
}
- $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur,
+ $.get(platal_baseurl + 'profile/ajax/sector/-1/0/0/' + sector,
function(data) {
- data = '
'
- + '
'
- + '' + data;
- document.getElementById('ss_secteur_sel').innerHTML = data;
- $(document.forms.prof_annu['jobs[-1][ss_secteur]']).change(updateSSecteur);
+ data = '
'
+ + '
'
+ + '' + data;
+ $('#subSectorSelection').html(data);
+ $('#subSectorSelection').find("[name='jobs[-1][subSector]']").change(updateSubSector);
});
}
-function addSecteur()
+function addSector()
{
- var scb = document.forms.prof_annu.secteur_sel;
- var s = scb.value;
- var st = scb.options[scb.selectedIndex].text;
-
- var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]'];
- var ss = sscb.value;
- var sst = sscb.options[sscb.selectedIndex].text;
-
- var html = '
';
- $('#secteurs').append(html);
- updateSSecteur();
-}
+ var s = $('#sectorSelection').find('[name=sectorSelection]').val();
+ var ss = $('#subSectorSelection').find("[name='jobs[-1][subSector]']").val();
+ var sst = $('#subSectorSelection').find("[name='jobs[-1][subSector]'] :selected").text();
-function removeSecteur(s, ss)
-{
- $('#secteurs_' + s + '_' + ss).remove();
- updateSSecteur();
+ var html = '
';
+ $('#sectors').append(html);
+ updateSubSector();
}
function registerEnterpriseAutocomplete(id)
{
- $(".enterprise_name").each(
+ $(".enterpriseName").each(
function() {
if (id == -1 || this.name == "jobs[" + id + "][name]") {
$(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
{
- selectOnly:1,
- field:this.name,
- matchSubset:0,
- width:$(this).width()
+ selectOnly:1,
+ field:this.name,
+ matchSubset:0,
+ width:$(this).width()
});
}
- }
- );
+ });
- $(".sector_name").each(
+ $(".sectorName").each(
function() {
- if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") {
- $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur",
+ if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") {
+ $(this).autocomplete(platal_baseurl + "search/autocomplete/subSubSector",
{
- selectOnly:1,
- field:this.name,
- matchSubset:0,
- width:$(this).width()
+ selectOnly:1,
+ field:this.name,
+ matchSubset:0,
+ width:$(this).width()
});
}
- }
- );
+ });
+}
+
+// {{{1 Multiusage functions
+
+function updateElement(cat)
+{
+ var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
+ if (val == '' || $('#' + cat + '_' + val).length != 0) {
+ $('#' + cat + '_add').hide();
+ } else {
+ $('#' + cat + '_add').show();
+ }
+}
+
+function removeElement(cat, id)
+{
+ $('#' + cat + '_' + id).remove();
+ updateElement(cat);
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: