X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=75b5b8dcc6bd30ebed16c72a2a51db72f3201fb5;hb=c76545c351fae4e2298624ff9ee5bf854dc5a5b6;hp=ef96031f40aeddad60da9aa5250e2d2460182397;hpb=ed01acac4af9b0df4209b3e6e3e7d10284c76b9c;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index ef96031..75b5b8d 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -50,6 +50,9 @@ function wizPage_onLoad(id) updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubSector]']").val()); updateJobAlternates(i); } + if ($('#job_0').find("[name='jobs[0][name]']").val() == '') { + registerEnterpriseAutocomplete(0); + } break; } } @@ -320,14 +323,15 @@ function addressChanged(prefid) function validGeoloc(prefid, id, geoloc) { if (geoloc == 1) { - $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geoloc]').val()); + $('#' + 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*='[geoloc]']").remove(); + $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove(); + $('#' + prefid + '_cont').find("[name*='[geocodedPostalText]']").remove(); } $('#' + prefid + '_cont').find('[name*=text]').removeClass('error'); - $('#' + prefid + '_cont').find('[name*=geoloc_choice]').val(geoloc); + $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc); $('.' + prefid + '_geoloc').remove(); } @@ -344,15 +348,15 @@ function addTel(prefid, prefname) Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); } -function removeTel(id) +function removeTel(prefname, prefid, id) { var total = 0; - while ($('#tels_' + total).length != 0) { + while ($('#' + prefid + '_' + total).length != 0) { ++total; } - $('#tels_' + id).remove(); + $('#' + prefid + '_' + id).remove(); for (var i = parseInt(id) + 1; i < total; ++i) { - renumberPhone(i); + renumberPhone(prefname, prefid, i); } } @@ -369,25 +373,25 @@ function removePhoneComment(id, pref) $('#' + id + '_addComment').show(); } -function renumberPhone(i) +function renumberPhone(prefname, prefid, i) { var telid = i - 1; - var telprefOld = 'tels[' + i + ']'; - var telpref = 'tels[' + telid + ']'; - var idOld = 'tels_' + i; - var id = 'tels_' + telid; - - $('#tels_' + i).attr('id', 'tels_' + telid); - $('#tels_' + telid).find('div.titre').html('N°' + i); - $('#tels_' + telid).find('a.removeTel').attr('href', 'javascript:removeTel(' + telid + ')'); - $('#tels_' + telid).find('select').attr('name', telpref + '[type]'); - $('#tels_' + telid).find("[name='" + telprefOld + "[tel]']").attr('name', telpref + '[tel]'); - $('#tels_' + telid).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]'); - $('#tels_' + telid).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')'); - $('#tels_' + telid).find('#' + idOld + '_addComment').attr('id', id + '_addComment'); - $('#tels_' + telid).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')'); - $('#tels_' + telid).find('#' + idOld + '_comment').attr('id', id + '_comment'); - $('#tels_' + telid).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]'); + var telprefOld = prefname + '[' + i + ']'; + var telpref = prefname + '[' + telid + ']'; + var idOld = prefid + '_' + i; + var id = prefid + '_' + telid; + + $('#' + 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 @@ -566,6 +570,125 @@ function addEntreprise(id) $('.entreprise_' + id).toggle(); } +/** + * Adds a job term in job profile page + * @param jobid id of profile's job among his different jobs + * @param jtid id of job term to add + * @param full_name full text of job term + * @return false if the term already exist for this job, true otherwise + */ +function addJobTerm(jobid, jtid, full_name) +{ + var termid = 0; + var parentpath; + var formvarname; + if (jobid < 0) { + parentpath = ''; + jobid = ''; + formvarname = 'terms'; + } else { + parentpath = '#job_'+jobid+' '; + formvarname = 'jobs['+jobid+'][terms]'; + } + var lastJobTerm = $(parentpath + '.job_term:last'); + if (lastJobTerm.length != 0) { + termid = parseInt(lastJobTerm.children('input').attr('name').replace(/^(jobs\[[0-9]+\]\[terms\]|terms)\[([0-9]+)\]\[jtid\]/, '$2')) + 1; + if ($('#job'+jobid+'_term'+jtid).length > 0) { + return false; + } + } + var newdiv = '