X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=690c1bac4eeed9a12a96392458e71a858d095c59;hb=425684231dd5c496b78399ee07c6d2123b836eeb;hp=108ce44bcb35932aec87cbca80bf62b7f6bcae3a;hpb=805f3d1679a53bb04fff34619c171a1381068612;p=platal.git
diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js
index 108ce44..690c1ba 100644
--- a/htdocs/javascript/profile.js
+++ b/htdocs/javascript/profile.js
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -18,256 +18,374 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-// Page initialization
+// Page initialization {{{1
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 = 1;
+ while ($('.edu_' + i).length != 0) {
+ prepareType(i - 1);
+ ++i;
+ }
+ break;
+ case 'adresses':
+ checkCurrentAddress();
break;
case 'poly':
- updateGroupSubLink(document.forms.prof_annu.groupesx_sub);
+ updateGroupSubLink();
break;
case 'deco':
for (var i in names) {
- if (typeof names[i] != 'function') {
- if (document.getElementById("medal_" + i) != null) {
- getMedalName(i);
- buildGrade(i, document.forms.prof_annu["medal_" + i + "_grade"].value);
- }
+ if ($('#medal_' + i).length != 0) {
+ getMedalName(i);
+ buildGrade(i, $('#medal_' + i).find('[name*=medal_' + i + '_grade]').val());
}
}
break;
case 'emploi':
- for (var i = 0 ; document.getElementById('job_' + i) != null ; ++i) {
- updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
- document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
+ for (var i = 0 ; $('#job_' + i).length != 0; ++i) {
+ updateJobSector(i, $('#job_' + i).find("[name*='[ss_secteur]']").val());
+ updateJobSubSector(i, $('#job_' + i).find("[name*='[sss_secteur]']").val());
}
- setTimeout('registerEnterpriseAutocomplete(-1)', 100);
break;
}
}
-var applisType;
-var applisTypeAll;
-
-// General
-
+var educationDegree;
+var educationDegreeAll;
+var educationDegreeName;
var subgrades;
var names;
-function fillType(selectCtrl, appli, fill)
+
+// Names {{{1
+
+function toggleNamesAdvanced()
{
- var i;
- var i0=0;
+ $('.names_advanced').toggle();
+}
- for (i = selectCtrl.options.length; i >=0; i--) {
- selectCtrl.options[i] = null;
+function addSearchName()
+{
+ var i = 0;
+ while ($('#search_name_' + i).length != 0) {
+ i++;
}
+ Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){
+ $('#searchname').before(data);
+ changeNameFlag(i);
+ });
+}
- if (fill || appli <0) {
- selectCtrl.options[0] = new Option(' ');
- i0=1;
- }
- 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 removeSearchName(i)
+{
+ $('#search_name_' + i).remove();
+ updateNameDisplay();
}
+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(' ' +
+ '' +
+ '' +
+ '' +
+ '');
+ } else {
+ $('#flag_cb_' + i).after(' ' +
+ '' +
+ '' +
+ '');
+ }
+}
-function selectType(selectCtrl, type)
+function updateNameDisplay()
{
- for (i = 0; i < selectCtrl.options.length; i++) {
- if (selectCtrl.options[i].text == type)
- selectCtrl.selectedIndex=i;
+ var searchnames = '';
+ 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() + ';;';
+ }
}
+ Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){
+ var name = data.split(';');
+ $('#public_name').html(name[0]);
+ $('#private_name').html(name[0] + name[1]);
+ });
}
+// Nationalities {{{1
+
+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();
+ }
+}
-// Addresses
+// Education {{{1
-function removeObject(id, pref)
+function prepareType(id)
{
- document.getElementById(id).style.display = "none";
- document.forms.prof_annu[pref + "[removed]"].value = "1";
+ var edu = $('.edu_' + id).find("[name='edus[" + id + "][eduid]']").val() - 1;
+ var sel = $('.edu_' + id).find('[name=edu_' + id + '_tmp]').val();
+ var html = '';
+ var length = educationDegree[edu].length;
+ for (i = 0; i < length; ++i) {
+ html += '';
+ }
+ $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html);
}
-function restoreObject(id, pref)
+function addEdu()
{
- document.getElementById(id).style.display = '';
- document.forms.prof_annu[pref + "[removed]"].value = "0";
+ var i = 0;
+ var j = 0;
+ var prefix = 'edu_';
+ var class_parity;
+
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ if ($('.' + prefix + i).length != 0) {
+ j++;
+ }
+ i++;
+ }
+ if (j % 2) {
+ class_parity = 'pair';
+ } else {
+ class_parity = 'impair';
+ }
+ $('#edu_add').removeClass(prefix + i);
+ i++;
+ $('#edu_add').addClass(prefix + i);
+ i--;
+ $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
+ function(data) {
+ $('#edu_add').before(data);
+ prepareType(i);
+ });
}
-function getAddressElement(adrid, adelement)
+function removeEdu(i)
{
- return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
+ var prefix = 'edu_';
+ $('.' + prefix + i).remove();
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ $('.' + prefix + i).toggleClass('pair');
+ $('.' + prefix + i).toggleClass('impair');
+ i++;
+ }
}
-function checkCurrentAddress(newCurrent)
+// Networking {{{1
+
+function addNetworking()
{
- var hasCurrent = 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 ($('#networking_' + i).length != 0) {
i++;
}
- if (!hasCurrent) {
- 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++;
+ var namefirst = '';
+ var html = '
'
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' | '
+ + '
';
+
+ $('#networking').before(html);
}
-function removeAddress(id, pref)
+function removeNetworking(id)
{
- removeObject(id, pref);
- checkCurrentAddress(null);
- if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
- document.getElementById(id + '_grayed').style.display = '';
- }
+ $('#networking_' + id).remove();
}
-function restoreAddress(id, pref)
+function updateNetworking(i)
{
- document.getElementById(id + '_grayed').style.display = 'none';
- checkCurrentAddress(null);
- restoreObject(id, pref);
+ $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
}
-function addAddress()
+// Addresses {{{1
+
+function toggleAddress(id, val)
+{
+ $('#addresses_' + id + '_grayed').toggle();
+ $('#addresses_' + id).toggle();
+ $('#addresses_' + id + '_cont').find('[name*=removed]').val(val);
+ checkCurrentAddress();
+}
+
+function checkCurrentAddress(id)
{
+ var hasCurrentAddress = id ? true : false;
var i = 0;
- while (getAddressElement(i, 'pub') != null) {
+ 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++;
}
- $("#add_adr").before('');
- Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
+ if (!hasCurrentAddress) {
+ i = 0;
+ 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++;
+ }
+ }
+ if (id) {
+ $('#addresses_' + id + '_cont').find('[name*=current]').attr('checked', 'checked');
+ }
}
-function addTel(id)
+function addAddress()
{
var i = 0;
- var adid = 'addresses_' + id;
- var tel = adid + '_tel_';
- while (document.getElementById(tel + i) != null) {
+ while ($('#addresses_' + i + '_cont').length != 0) {
i++;
}
- $('#' + adid + '_add_tel').before('');
- Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
+ $('#add_address').before('');
+ Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
}
-
-// Geoloc
-
-function validGeoloc(id, pref)
+function addressChanged(id)
{
- 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 = '';
+ $('#addresses_' + id + '_cont').find('[name*=changed]').val("1");
}
-function validAddress(id, pref)
+function validGeoloc(id, geoloc)
{
- 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 = '';
+ 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());
+ }
+ $('#addresses_' + id + '_cont').find('[name*=text]').removeClass('error');
+ $('#addresses_' + id + '_cont').find('[name*=geoloc_choice]').val(geoloc);
+ $('.addresses_' + id + '_geoloc').remove();
}
+// {{{1 Phones
-// Groups
-
-function updateGroup(type)
+function addTel(prefid, prefname)
{
- 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 i = 0;
+ var prefix = prefid + '_';
+ while ($('#' + prefix + i).length != 0) {
+ i++;
}
+ $('#' + prefix + 'add').before('');
+ Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
}
-function removeGroup(cat, id)
+function removeTel(id)
{
- $('#' + cat + '_' + id).remove();
- updateGroup(cat);
+ $('#' + id).remove();
}
-function addGroup(cat)
+function addPhoneComment(id)
{
- 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);
+ $(id + '_comment').show();
+ $(id + '_addComment').hide();
}
-function updateGroupSubLink(cb)
+function removePhoneComment(id, pref)
{
- var href = cb.value ? cb.value : "http://www.polytechnique.net";
- document.getElementById("groupesx_sub").href = href;
+ $(id + '_comment').hide();
+ $(id + '_comment').find("[name='" + pref + "[comment]']").val('');
+ $(id + '_addComment').show();
}
+// {{{1 Groups
-// Medals
+function addBinet()
+{
+ 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()
+{
+ var href = $('[name*=groupesx_sub]').val() ? $('[name*=groupesx_sub]').val() : 'http://www.polytechnique.net';
+ $('#groupesx_sub').attr('href', href);
+}
+
+// {{{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)
@@ -306,7 +424,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));
}
@@ -316,34 +434,47 @@ function removeMedal(id)
updateMedal();
}
-
-// Jobs
+// Jobs {{{1
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='" + id + "[new]']").val() == '0') {
+ $('#' + id + '_grayed').show();
+ $('#' + id + '_grayed_name').html($('#' + id).find("[name='" + id + "[name]']").val());
}
- document.forms.prof_annu[pref + "[removed]"].value = "1";
+ $('#' + id).find("[name='" + id + "[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='" + id + "[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*='[secteur]']").val();
+ if (sector == '') {
+ sector = '-1';
}
- Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel);
+ Ajax.update_html('job_' + id + '_ss_secteur', 'profile/ajax/secteur/' + id + '/job_' + id + '/jobs[' + id + ']/' + sector + '/' + sel);
+}
+
+function updateJobSubSector(id, sel)
+{
+ var subSector = $('#job_' + id).find("[name*='[ss_secteur]']").val();
+ if (subSector == '') {
+ subSector = '-1';
+ }
+ Ajax.update_html('job_' + id + '_sss_secteur', 'profile/ajax/ssecteur/' + id + '/' + subSector + '/' + sel);
+}
+
+function displayAllSector(id)
+{
+ $('.sector_text_' + id).remove();
+ $('.sector_' + id).show();
}
function makeAddJob(id)
@@ -352,148 +483,105 @@ function makeAddJob(id)
{
$('#add_job').before(data);
registerEnterpriseAutocomplete(id);
- updateSecteur('job_' + id, 'jobs[' + id + ']', '');
+ updateSector('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));
}
-
-// Skills
-
-function updateSkill(cat)
+function addEntreprise(id)
{
- 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';
+ $('.entreprise_' + id).toggle();
}
+// {{{1 Skills
+
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
-
-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 = $('#secteur_sel').find('[name=secteur_sel]').val();
+ var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val();
+ if ((s == '' || ss == '') || $('#secteurs_' + s + '_' + ss).length != 0) {
+ $('#secteurs_add').hide();
+ } else {
+ $('#secteurs_add').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';
+ $('#secteurs_' + s + '_' + ss).remove();
+ updateSubSector();
}
-function updateSecteur()
+function updateSector()
{
- var secteur = document.forms.prof_annu.secteur_sel.value;
+ var secteur = $('#secteur_sel').find('[name=secteur_sel]').val();
if (secteur == '') {
secteur = '-1';
- document.getElementById('ss_secteur_sel').innerHTML = '';
+ $('#ss_secteur_sel').html('');
return;
}
- $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur,
+ $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur,
function(data) {
- data = ''
- + ' '
- + '' + data;
- document.getElementById('ss_secteur_sel').innerHTML = data;
- attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur);
+ data = ''
+ + ' '
+ + '' + data;
+ $('#ss_secteur_sel').html(data);
+ $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").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 s = $('#secteur_sel').find('[name=secteur_sel]').val();
+ var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val();
+ var sst = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]'] :selected").text();
var html = '';
+ + ' '
+ + ' '
+ + ' '
+ + ' '
+ + ' ' + sst
+ + '';
$('#secteurs').append(html);
- updateSSecteur();
-}
-
-function removeSecteur(s, ss)
-{
- $('#secteurs_' + s + '_' + ss).remove();
- updateSSecteur();
+ updateSubSector();
}
function registerEnterpriseAutocomplete(id)
@@ -503,14 +591,44 @@ function registerEnterpriseAutocomplete(id)
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(
+ function() {
+ if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") {
+ $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur",
+ {
+ 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: