X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=4b3c4700c67f836cf8bf2bfcab0ad18f3065bb86;hb=58acfe8b40d3417e7b1a5ffd868a52509d053558;hp=d59a36515c8f25c127c65d3d346b2df934dce221;hpb=dd9bac8f7903e9924525ad8db3e38650ff5ad1b6;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index d59a365..4b3c470 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -24,10 +24,14 @@ function wizPage_onLoad(id) { switch (id) { case 'general': - fillType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1[id]'].selectedIndex-1); - selectType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1_tmp'].value); - fillType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2[id]'].selectedIndex-1); - selectType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2_tmp'].value); + var i = 0; + var prefix = 'edu_'; + while ($('.' + prefix + i).length != 0) { + i++; + } + for (var j = 0; j < i; j++) { + prepareType(j); + } break; case 'poly': updateGroupSubLink(document.forms.prof_annu.groupesx_sub); @@ -47,48 +51,149 @@ function wizPage_onLoad(id) updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']', document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value); } + registerEnterpriseAutocomplete(-1); break; } } -var applisType; -var applisTypeAll; +var educationDegree; +var educationDegreeAll; +var educationDegreeName; // General var subgrades; var names; -function fillType(selectCtrl, appli, fill) +function fillType(selectCtrl, edu, fill) { var i; - var i0=0; + var i0 = 0; - for (i = selectCtrl.options.length; i >=0; i--) { + for (i = selectCtrl.options.length; i >= 0; i--) { selectCtrl.options[i] = null; } - if (fill || appli <0) { + if (fill || edu < 0) { selectCtrl.options[0] = new Option(' '); - i0=1; + i0 = 1; + } + if (edu >= 0) { + for (i = 0; i < educationDegree[edu].length; i++) { + selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegree[edu][i] - 1], educationDegree[edu][i]); + } + } else if (fill) { + for (i = 0; i < educationDegreeAll.length; i++) { + selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegreeAll[i] - 1], educationDegreeAll[i]); + } } - if (appli>=0) - for (i=0; i < applisType[appli].length; i++) - selectCtrl.options[i0+i] = new Option(applisType[appli][i]); - else if (fill) - for (i=0; i < applisTypeAll.length; i++) - selectCtrl.options[i0+i] = new Option(applisTypeAll[i]); } function selectType(selectCtrl, type) { for (i = 0; i < selectCtrl.options.length; i++) { - if (selectCtrl.options[i].text == type) - selectCtrl.selectedIndex=i; + if (selectCtrl.options[i].value == type) { + selectCtrl.selectedIndex = i; + } + } +} + +function prepareType(i) +{ + fillType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edus[" + i + "][eduid]"].selectedIndex - 1); + selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value); +} + +function addSearchName() +{ + var i = 0; + while (document.getElementById('search_name_' + i) != null) { + i++; + } + $('#add_search_name').before('
'); + Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i,function(){ + $('#search_name_'+i+' input')[1].focus(); + }); +} + +function removeSearchName(i) +{ + if (document.getElementById('search_name_'+i+'_new') != null) { + $('#search_name_'+i).remove(); + } else { + removeObject('search_name_'+i, 'search_name['+i+']'); + } +} + +function delNationality(i) +{ + $('#nationalite' + i).hide().find('select').val(''); +} + +function addNationality() +{ + var i = 0; + if ($('#nationalite2').find('select').val() == "") { + i = 2; + } else if ($('#nationalite3').find('select').val() == "") { + i = 3; + } + if ((i == 2) || (i == 3)) { + $('#nationalite' + i).show(); } } +function addNetworking() +{ + var i = 0; + var nws = 'networking_'; + while (document.getElementById(nws + i) != null) { + i++; + } + var namefirst = ''; + var html = '' + + ' ' + + '
' + + ' ' + + ' ' + + ' site public' + + '  ' + + ' ' + + ' ' + + '
' + + '
' + + ' ' + + ' ' + + ' cross' + + ' ' + + '
' + + ' ' + + ''; + $('#networking').before(html); +} + +function removeNetworking(id) +{ + $('#networking_' + id).remove(); +} + +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; + } + +} // Addresses @@ -165,18 +270,60 @@ function addAddress() Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); } -function addTel(id) +function addEdu() { var i = 0; - var adid = 'addresses_' + id; - var tel = adid + '_tel_'; - while (document.getElementById(tel + i) != null) { + var prefix = 'edu_'; + var class_parity; + + while ($('.' + prefix + i).length != 0) { i++; } - $('#' + adid + '_add_tel').before('
'); - Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i); + if (i % 2) { + class_parity = 'pair'; + } else { + class_parity = 'impair'; + } + $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity, + function(data) { + $('#edu_add').before(data); + prepareType(i); + }); } +function removeEdu(id) +{ + $('.' + id).remove(); +} + +function addTel(prefid, prefname) +{ + var i = 0; + var prefix = prefid + '_'; + while (document.getElementById(prefix + i) != null) { + i++; + } + $('#' + prefix + 'add').before('
'); + Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); +} + +function removeTel(id) +{ + $('#' + id).remove(); +} + +function addPhoneComment(id, pref) +{ + document.getElementById(id+'_comment').style.display = ''; + document.getElementById(id+'_addComment').style.display = 'none'; +} + +function removePhoneComment(id, pref) +{ + document.getElementById(id+'_comment').style.display = 'none'; + document.forms.prof_annu[pref+ '[comment]'].value = ''; + document.getElementById(id+'_addComment').style.display = ''; +} // Geoloc @@ -350,6 +497,7 @@ function makeAddJob(id) return function(data) { $('#add_job').before(data); + registerEnterpriseAutocomplete(id); updateSecteur('job_' + id, 'jobs[' + id + ']', ''); }; } @@ -405,7 +553,7 @@ function updateCountry() { var val = document.forms.prof_annu.countries_sel.value; var show = true; - if (val == '') { + if (val == '' || val == '00') { show = false; } if (document.getElementById('countries_' + val) != null) { @@ -420,11 +568,11 @@ function addCountry() var val = cb.value; var text = cb.options[cb.selectedIndex].text; var html = '
' - + '
' + text + '
' - + ' ' - + ' ' + + ' ' + ' ' + ' ' + + '
' + text + '
' + + ' ' + '
'; $('#countries').append(html); updateCountry(); @@ -454,6 +602,8 @@ function updateSecteur() var secteur = document.forms.prof_annu.secteur_sel.value; if (secteur == '') { secteur = '-1'; + document.getElementById('ss_secteur_sel').innerHTML = ''; + return; } $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur, function(data) { @@ -492,4 +642,21 @@ function removeSecteur(s, ss) updateSSecteur(); } +function registerEnterpriseAutocomplete(id) +{ + $(".enterprise_name").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() + }); + } + } + ); +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: