1 /***************************************************************************
2 * Copyright (C) 2003-2009 Polytechnique.org *
3 * http://opensource.polytechnique.org/ *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
21 // Page initialization {{{1
23 function wizPage_onLoad(id
)
29 while ($('.' + prefix
+ i
).length
!= 0) {
33 for (var j
= 0; j
< i
; j
++) {
38 checkCurrentAddress();
41 updateGroupSubLink(document
.forms
.prof_annu
.groupesx_sub
);
44 for (var i
in names
) {
45 if (typeof names
[i
] != 'function') {
46 if (document
.getElementById("medal_" + i
) != null) {
48 buildGrade(i
, document
.forms
.prof_annu
["medal_" + i
+ "_grade"].value
);
54 for (var i
= 0 ; document
.getElementById('job_' + i
) != null ; ++i
) {
55 updateJobSecteur(i
, 'job_' + i
, 'jobs[' + i
+ ']',
56 document
.forms
.prof_annu
["jobs[" + i
+ "][ss_secteur]"].value
);
57 updateJobSousSecteur(i
, 'job_' + i
, 'jobs[' + i
+ ']',
58 document
.forms
.prof_annu
["jobs[" + i
+ "][sss_secteur]"].value
);
60 setTimeout('registerEnterpriseAutocomplete(-1)', 100);
66 var educationDegreeAll
;
67 var educationDegreeName
;
73 function fillType(selectCtrl
, edu
, fill
)
78 for (i
= selectCtrl
.options
.length
; i
>= 0; i
--) {
79 selectCtrl
.options
[i
] = null;
82 if (fill
|| edu
< 0) {
83 selectCtrl
.options
[0] = new Option(' ');
87 for (i
= 0; i
< educationDegree
[edu
].length
; i
++) {
88 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegree
[edu
][i
] - 1], educationDegree
[edu
][i
]);
91 for (i
= 0; i
< educationDegreeAll
.length
; i
++) {
92 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegreeAll
[i
] - 1], educationDegreeAll
[i
]);
98 function selectType(selectCtrl
, type
)
100 for (i
= 0; i
< selectCtrl
.options
.length
; i
++) {
101 if (selectCtrl
.options
[i
].value
== type
) {
102 selectCtrl
.selectedIndex
= i
;
107 function prepareType(i
)
109 fillType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edus[" + i
+ "][eduid]"].selectedIndex
- 1);
110 selectType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edu_" + i
+ "_tmp"].value
);
120 while (!$('#edu_add').hasClass(prefix
+ i
)) {
121 if ($('.' + prefix
+ i
).length
!= 0) {
127 class_parity
= 'pair';
129 class_parity
= 'impair';
131 $('#edu_add').removeClass(prefix
+ i
);
133 $('#edu_add').addClass(prefix
+ i
);
135 $.get(platal_baseurl
+ 'profile/ajax/edu/' + i + '/' + class_parity
,
137 $('#edu_add').before(data
);
142 function removeEdu(i
)
145 $('.' + prefix
+ i
).remove();
146 while (!$('#edu_add').hasClass(prefix
+ i
)) {
147 $('.' + prefix
+ i
).toggleClass('pair');
148 $('.' + prefix
+ i
).toggleClass('impair');
155 function toggleNamesAdvanced()
157 $('.names_advanced').toggle();
160 function addSearchName()
163 while ($('#search_name_' + i
).length
!= 0) {
166 Ajax
.update_html('search_name_' + i
, 'profile/ajax/searchname/' + i
, function(data
){
167 $('#searchname').before(data
);
172 function removeSearchName(i
)
174 $('#search_name_' + i
).remove();
178 function changeNameFlag(i
)
180 $('#flag_' + i
).remove();
181 var typeid
= $('#search_name_' + i
).find('select').val();
182 var type
= $('#search_name_' + i
).find('select :selected').text();
183 if ($('[@name=sn_type_' + typeid
+ '_' + i
+ ']').val() > 0) {
184 $('#flag_cb_' + i
).after('<span id="flag_' + i
+ '"> ' +
185 '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
186 '<input type="hidden" name="search_names[' + i
+ '][pub]" value="1"/>' +
187 '<input type="hidden" name="search_names[' + i
+ '][typeid]" value="' + typeid
+ '"/>' +
188 '<input type="hidden" name="search_names[' + i
+ '][type]" value="' + type
+ '"/></span>');
190 $('#flag_cb_' + i
).after('<span id="flag_' + i
+ '"> ' +
191 '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
192 '<input type="hidden" name="search_names[' + i
+ '][typeid]" value="' + typeid
+ '"/>' +
193 '<input type="hidden" name="search_names[' + i
+ '][type]" value="' + type
+ '"/></span>');
197 function updateNameDisplay()
199 var searchnames
= '';
200 for (var i
= 0; i
< 10; i
++) {
201 if ($('#search_name_' + i
).find(':text').val()) {
202 searchnames
+= $('#search_name_' + i
).find('[name*=typeid]').val() + ';';
203 searchnames
+= $('#search_name_' + i
).find(':text').val() + ';;';
206 Ajax
.update_html(null, 'profile/ajax/buildnames/' + searchnames
, function(data
){
207 var name
= data
.split(';');
208 $('#public_name').html(name
[0]);
209 $('#private_name').html(name
[0] + name
[1]);
213 // Nationalities {{{1
215 function delNationality(i
)
217 $('#nationalite' + i
).hide().find('select').val('');
220 function addNationality()
223 if ($('#nationalite2').find('select').val() == "") {
225 } else if ($('#nationalite3').find('select').val() == "") {
228 if ((i
== 2) || (i
== 3)) {
229 $('#nationalite' + i
).show();
235 function addNetworking()
238 var nws
= 'networking_';
239 while (document
.getElementById(nws
+ i
) != null) {
243 var html
= '<tr id="networking_' + i
+ '">'
244 + ' <td colspan="2">'
245 + ' <div style="float: left; width: 200px;">'
246 + ' <span class="flags">'
247 + ' <input type="checkbox" name="networking[' + i
+ '][pub]"/>'
248 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
250 + ' <select id="networking_type_' + i
+ '" name="networking[' + i
+ '][type]" onchange="javascript:updateNetworking(' + i
+ ');">';
251 for (nw
in nw_list
) {
252 if (namefirst
== '') {
255 html
+= ' <option value="' + nw_list
[nw
] + '">' + nw
+ '</option>';
258 + ' <input type="hidden" id="networking_name_' + i
+ '" name="networking[' + i
+ '][name]" value="' + namefirst
+ '"/>'
260 + ' <div style="float: left">'
261 + ' <input type="text" name="networking[' + i
+ '][address]" value="" size="30"/>'
262 + ' <a href="javascript:removeNetworking(' + i
+ ')">'
263 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
269 $('#networking').before(html
);
272 function removeNetworking(id
)
274 $('#networking_' + id
).remove();
277 function updateNetworking(i
)
279 var name
= document
.getElementById('networking_name_' + i
);
280 var type
= document
.getElementById('networking_type_' + i
);
281 if (type
!= null && name
!= null) {
282 name
.value
= type
.options
[type
.selectedIndex
].text
;
289 function toggleAddress(id
, val
)
291 $('#addresses_' + id
+ '_grayed').toggle();
292 $('#addresses_' + id
).toggle();
293 $('#addresses_' + id
+ '_cont').find('[name*=removed]').val(val
);
294 checkCurrentAddress();
297 function checkCurrentAddress(id
)
299 var hasCurrentAddress
= id
? true : false;
301 while ($('#addresses_' + i
+ '_cont').length
!= 0) {
302 if ($('#addresses_' + i
+ '_cont').find('[name*=removed]').val() == 1) {
303 $('#addresses_' + i
+ '_cont').find('[name*=current]').attr('checked', false);
305 if (!hasCurrentAddress
&& $('#addresses_' + i
+ '_cont').find('[name*=current]:checked').length
!= 0) {
306 hasCurrentAddress
= true;
308 $('#addresses_' + i
+ '_cont').find('[name*=current]').attr('checked', false);
312 if (!hasCurrentAddress
) {
314 while ($('#addresses_' + i
+ '_cont').length
!= 0) {
315 if ($('#addresses_' + i
+ '_cont').find('[name*=removed]').val() == 0) {
316 $('#addresses_' + i
+ '_cont').find('[name*=current]').attr('checked', 'checked');
323 $('#addresses_' + id
+ '_cont').find('[name*=current]').attr('checked', 'checked');
327 function addAddress()
330 while ($('#addresses_' + i
+ '_cont').length
!= 0) {
333 $('#add_address').before('<div id="addresses_' + i
+ '_cont"></div>');
334 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress());
337 function addressChanged(id
)
339 $('#addresses_' + id
+ '_cont').find('[name*=changed]').val("1");
342 function validGeoloc(id
, geoloc
)
345 $('#addresses_' + id
+ '_cont').find('[name*=text]').val($('#addresses_' + id
+ '_cont').find('[name*=geoloc]').val());
347 $('#addresses_' + id
+ '_cont').find('[name*=text]').removeClass('error');
348 $('#addresses_' + id
+ '_cont').find('[name*=geoloc_choice]').val(geoloc
);
349 $('.addresses_' + id
+ '_geoloc').remove();
354 function addTel(prefid
, prefname
)
357 var prefix
= prefid
+ '_';
358 while (document
.getElementById(prefix
+ i
) != null) {
361 $('#' + prefix
+ 'add').before('<div id="' + prefix
+ i
+ '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
362 Ajax
.update_html(prefix
+ i
, 'profile/ajax/tel/' + prefid + '/' + prefname
+ '/' + i
);
365 function removeTel(id
)
367 $('#' + id
).remove();
370 function addPhoneComment(id
, pref
)
372 document
.getElementById(id
+'_comment').style
.display
= '';
373 document
.getElementById(id
+'_addComment').style
.display
= 'none';
376 function removePhoneComment(id
, pref
)
378 document
.getElementById(id
+'_comment').style
.display
= 'none';
379 document
.forms
.prof_annu
[pref
+ '[comment]'].value
= '';
380 document
.getElementById(id
+'_addComment').style
.display
= '';
385 function updateGroup(type
)
387 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
388 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
389 document
.getElementById(type
+ '_add').style
.display
= 'none';
391 document
.getElementById(type
+ '_add').style
.display
= '';
395 function removeGroup(cat
, id
)
397 $('#' + cat
+ '_' + id
).remove();
401 function addGroup(cat
)
403 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
405 var text
= cb
.options
[cb
.selectedIndex
].text
;
406 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
408 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
411 + ' <div style="float: left; width: 70%">'
414 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
415 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
419 $('#' + cat
).after(html
);
423 function updateGroupSubLink(cb
)
425 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
426 document
.getElementById("groupesx_sub").href
= href
;
431 function updateMedal()
433 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
434 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
435 document
.getElementById('medal_add').style
.display
= 'none';
437 document
.getElementById('medal_add').style
.display
= '';
441 function getMedalName(id
)
443 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
446 function buildGrade(id
, current
)
449 var subg
= subgrades
[id
];
450 var obj
= $('#medal_grade_' + id
);
452 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
454 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
455 html
+= '<option value="0">Non précisée</option>';
456 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
457 html
+= '<option value="' + subg
[grade
][0] + '"';
458 if (subg
[grade
][0] == current
) {
459 html
+= ' selected="selected"';
461 html
+= '>' + subg
[grade
][1] + '</option>';
469 function makeAddProcess(id
)
471 return function(data
)
473 $('#medals').after(data
);
482 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
483 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
486 function removeMedal(id
)
488 $("#medal_" + id
).remove();
494 function removeJob(id
, pref
)
496 document
.getElementById(id
+ '_cont').style
.display
= 'none';
497 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
498 document
.getElementById(id
+ '_grayed').style
.display
= '';
499 document
.getElementById(id
+ '_grayed_name').innerHTML
=
500 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
502 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
505 function restoreJob(id
, pref
)
507 document
.getElementById(id
+ '_cont').style
.display
= '';
508 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
509 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
512 function updateJobSecteur(nb
, id
, pref
, sel
)
514 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
518 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id
+ '/' + pref + '/' + secteur
+ '/' + sel
);
521 function updateJobSousSecteur(nb
, id
, pref
, sel
)
523 var ssecteur
= document
.forms
.prof_annu
[pref
+ '[ss_secteur]'].value
;
524 if (ssecteur
== '') {
527 Ajax
.update_html(id
+ '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur
+ '/' + sel
);
530 function displayAllSector(id
)
532 $('.sector_text_' + id
).remove();
533 $('.sector_' + id
).show();
536 function makeAddJob(id
)
538 return function(data
)
540 $('#add_job').before(data
);
541 registerEnterpriseAutocomplete(id
);
542 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
549 while (document
.getElementById('job_' + i
) != null) {
552 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
555 function addEntreprise(id
)
557 $('.entreprise_' + id
).toggle();
562 function updateSkill(cat
)
564 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
569 if (document
.getElementById(cat
+ '_' + val
) != null) {
572 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
575 function addSkill(cat
)
577 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
579 var text
= sel
.options
[sel
.selectedIndex
].text
;
580 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
582 $('#' + cat
).append(data
);
583 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
588 function removeSkill(cat
, id
)
590 $('#' + cat
+ '_' + id
).remove();
596 function updateCountry()
598 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
600 if (val
== '' || val
== '00') {
603 if (document
.getElementById('countries_' + val
) != null) {
606 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
609 function addCountry()
611 var cb
= document
.forms
.prof_annu
.countries_sel
;
613 var text
= cb
.options
[cb
.selectedIndex
].text
;
614 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
615 + ' <a href="javascript:removeCountry(\'' + val
+ '\')" style="display: block; float:right">'
616 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
618 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
619 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
621 $('#countries').append(html
);
625 function removeCountry(id
)
627 $('#countries_' + id
).remove();
630 function updateSSecteur()
632 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
633 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
635 if (s
== '' || ss
== '') {
638 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
641 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
644 function updateSecteur()
646 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
649 document
.getElementById('ss_secteur_sel').innerHTML
= '';
652 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/0/0/' + secteur
,
654 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
655 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
657 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
658 $(document
.forms
.prof_annu
['jobs[-1][ss_secteur]']).change(updateSSecteur
);
662 function addSecteur()
664 var scb
= document
.forms
.prof_annu
.secteur_sel
;
666 var st
= scb
.options
[scb
.selectedIndex
].text
;
668 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
670 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
672 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
673 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
674 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
676 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
679 $('#secteurs').append(html
);
683 function removeSecteur(s
, ss
)
685 $('#secteurs_' + s
+ '_' + ss
).remove();
689 function registerEnterpriseAutocomplete(id
)
691 $(".enterprise_name").each(
693 if (id
== -1 || this.name
== "jobs[" + id
+ "][name]") {
694 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/entreprise",
699 width
:$(this).width()
705 $(".sector_name").each(
707 if (id
== -1 || this.name
== "jobs[" + id
+ "][sss_secteur_name]") {
708 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/sss_secteur",
713 width
:$(this).width()
720 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: