1 /***************************************************************************
2 * Copyright (C) 2003-2008 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
23 function wizPage_onLoad(id
)
29 while ($('.' + prefix
+ i
).length
!= 0) {
32 for (var j
= 0; j
< i
; j
++) {
37 updateGroupSubLink(document
.forms
.prof_annu
.groupesx_sub
);
40 for (var i
in names
) {
41 if (typeof names
[i
] != 'function') {
42 if (document
.getElementById("medal_" + i
) != null) {
44 buildGrade(i
, document
.forms
.prof_annu
["medal_" + i
+ "_grade"].value
);
50 for (var i
= 0 ; document
.getElementById('job_' + i
) != null ; ++i
) {
51 updateJobSecteur(i
, 'job_' + i
, 'jobs[' + i
+ ']',
52 document
.forms
.prof_annu
["jobs[" + i
+ "][ss_secteur]"].value
);
53 updateJobSousSecteur(i
, 'job_' + i
, 'jobs[' + i
+ ']',
54 document
.forms
.prof_annu
["jobs[" + i
+ "][sss_secteur]"].value
);
56 setTimeout('registerEnterpriseAutocomplete(-1)', 100);
62 var educationDegreeAll
;
63 var educationDegreeName
;
69 function fillType(selectCtrl
, edu
, fill
)
74 for (i
= selectCtrl
.options
.length
; i
>= 0; i
--) {
75 selectCtrl
.options
[i
] = null;
78 if (fill
|| edu
< 0) {
79 selectCtrl
.options
[0] = new Option(' ');
83 for (i
= 0; i
< educationDegree
[edu
].length
; i
++) {
84 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegree
[edu
][i
] - 1], educationDegree
[edu
][i
]);
87 for (i
= 0; i
< educationDegreeAll
.length
; i
++) {
88 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegreeAll
[i
] - 1], educationDegreeAll
[i
]);
94 function selectType(selectCtrl
, type
)
96 for (i
= 0; i
< selectCtrl
.options
.length
; i
++) {
97 if (selectCtrl
.options
[i
].value
== type
) {
98 selectCtrl
.selectedIndex
= i
;
103 function prepareType(i
)
105 fillType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edus[" + i
+ "][eduid]"].selectedIndex
- 1);
106 selectType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edu_" + i
+ "_tmp"].value
);
109 function addSearchName()
112 while (document
.getElementById('search_name_' + i
) != null) {
115 $('#add_search_name').before('<div id="search_name_' + i
+ '" style="padding:2px" class="center"></div>');
116 Ajax
.update_html('search_name_' + i
, 'profile/ajax/searchname/' + i
,function(){
117 $('#search_name_'+i
+' input')[1].focus();
121 function removeSearchName(i
)
123 if (document
.getElementById('search_name_'+i
+'_new') != null) {
124 $('#search_name_'+i
).remove();
126 removeObject('search_name_'+i
, 'search_name['+i
+']');
130 function delNationality(i
)
132 $('#nationalite' + i
).hide().find('select').val('');
135 function addNationality()
138 if ($('#nationalite2').find('select').val() == "") {
140 } else if ($('#nationalite3').find('select').val() == "") {
143 if ((i
== 2) || (i
== 3)) {
144 $('#nationalite' + i
).show();
148 function addNetworking()
151 var nws
= 'networking_';
152 while (document
.getElementById(nws
+ i
) != null) {
156 var html
= '<tr id="networking_' + i
+ '">'
157 + ' <td colspan="2">'
158 + ' <div style="float: left; width: 200px;">'
159 + ' <span class="flags">'
160 + ' <input type="checkbox" name="networking[' + i
+ '][pub]"/>'
161 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
163 + ' <select id="networking_type_' + i
+ '" name="networking[' + i
+ '][type]" onchange="javascript:updateNetworking(' + i
+ ');">';
164 for (nw
in nw_list
) {
165 if (namefirst
== '') {
168 html
+= ' <option value="' + nw_list
[nw
] + '">' + nw
+ '</option>';
171 + ' <input type="hidden" id="networking_name_' + i
+ '" name="networking[' + i
+ '][name]" value="' + namefirst
+ '"/>'
173 + ' <div style="float: left">'
174 + ' <input type="text" name="networking[' + i
+ '][address]" value="" size="30"/>'
175 + ' <a href="javascript:removeNetworking(' + i
+ ')">'
176 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
182 $('#networking').before(html
);
185 function removeNetworking(id
)
187 $('#networking_' + id
).remove();
190 function updateNetworking(i
)
192 var name
= document
.getElementById('networking_name_' + i
);
193 var type
= document
.getElementById('networking_type_' + i
);
194 if (type
!= null && name
!= null) {
195 name
.value
= type
.options
[type
.selectedIndex
].text
;
202 function removeObject(id
, pref
)
204 document
.getElementById(id
).style
.display
= "none";
205 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
208 function restoreObject(id
, pref
)
210 document
.getElementById(id
).style
.display
= '';
211 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
214 function getAddressElement(adrid
, adelement
)
216 return document
.forms
.prof_annu
["addresses[" + adrid
+ "][" + adelement
+ "]"];
219 function checkCurrentAddress(newCurrent
)
221 var hasCurrent
= false;
223 while (getAddressElement(i
, 'pub') != null) {
224 var radio
= getAddressElement(i
, 'current');
225 var removed
= getAddressElement(i
, 'removed');
226 if (removed
.value
== "1" && radio
.checked
) {
227 radio
.checked
= false;
228 } else if (radio
.checked
&& radio
!= newCurrent
) {
229 radio
.checked
= false;
230 } else if (radio
.checked
) {
237 while (getAddressElement(i
, 'pub') != null) {
238 var radio
= getAddressElement(i
, 'current');
239 var removed
= getAddressElement(i
, 'removed');
240 if (removed
.value
!= "1") {
249 function removeAddress(id
, pref
)
251 removeObject(id
, pref
);
252 checkCurrentAddress(null);
253 if (document
.forms
.prof_annu
[pref
+ '[datemaj]'].value
!= '') {
254 document
.getElementById(id
+ '_grayed').style
.display
= '';
258 function restoreAddress(id
, pref
)
260 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
261 checkCurrentAddress(null);
262 restoreObject(id
, pref
);
265 function addAddress()
268 while (getAddressElement(i
, 'pub') != null) {
271 $("#add_adr").before('<div id="addresses_' + i
+ '_cont"></div>');
272 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress
);
282 while (!$('#edu_add').hasClass(prefix
+ i
)) {
283 if ($('.' + prefix
+ i
).length
!= 0) {
289 class_parity
= 'pair';
291 class_parity
= 'impair';
293 $('#edu_add').removeClass(prefix
+ i
);
295 $('#edu_add').addClass(prefix
+ i
);
297 $.get(platal_baseurl
+ 'profile/ajax/edu/' + i + '/' + class_parity
,
299 $('#edu_add').before(data
);
304 function removeEdu(i
)
307 $('.' + prefix
+ i
).remove();
308 while (!$('#edu_add').hasClass(prefix
+ i
)) {
309 $('.' + prefix
+ i
).toggleClass('pair');
310 $('.' + prefix
+ i
).toggleClass('impair');
315 function addTel(prefid
, prefname
)
318 var prefix
= prefid
+ '_';
319 while (document
.getElementById(prefix
+ i
) != null) {
322 $('#' + prefix
+ 'add').before('<div id="' + prefix
+ i
+ '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
323 Ajax
.update_html(prefix
+ i
, 'profile/ajax/tel/' + prefid + '/' + prefname
+ '/' + i
);
326 function removeTel(id
)
328 $('#' + id
).remove();
331 function addPhoneComment(id
, pref
)
333 document
.getElementById(id
+'_comment').style
.display
= '';
334 document
.getElementById(id
+'_addComment').style
.display
= 'none';
337 function removePhoneComment(id
, pref
)
339 document
.getElementById(id
+'_comment').style
.display
= 'none';
340 document
.forms
.prof_annu
[pref
+ '[comment]'].value
= '';
341 document
.getElementById(id
+'_addComment').style
.display
= '';
346 function validGeoloc(id
, pref
)
348 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
349 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
350 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
351 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
352 document
.forms
.prof_annu
[pref
+ "[text]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc]"].value
;
353 document
.forms
.prof_annu
[pref
+ "[cityid]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc_cityid]"].value
;
354 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
355 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
356 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
359 function validAddress(id
, pref
)
361 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
362 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
363 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
364 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
365 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
366 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
367 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
373 function updateGroup(type
)
375 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
376 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
377 document
.getElementById(type
+ '_add').style
.display
= 'none';
379 document
.getElementById(type
+ '_add').style
.display
= '';
383 function removeGroup(cat
, id
)
385 $('#' + cat
+ '_' + id
).remove();
389 function addGroup(cat
)
391 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
393 var text
= cb
.options
[cb
.selectedIndex
].text
;
394 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
396 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
399 + ' <div style="float: left; width: 70%">'
402 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
403 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
407 $('#' + cat
).after(html
);
411 function updateGroupSubLink(cb
)
413 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
414 document
.getElementById("groupesx_sub").href
= href
;
420 function updateMedal()
422 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
423 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
424 document
.getElementById('medal_add').style
.display
= 'none';
426 document
.getElementById('medal_add').style
.display
= '';
430 function getMedalName(id
)
432 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
435 function buildGrade(id
, current
)
438 var subg
= subgrades
[id
];
439 var obj
= $('#medal_grade_' + id
);
441 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
443 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
444 html
+= '<option value="0">Non précisée</option>';
445 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
446 html
+= '<option value="' + subg
[grade
][0] + '"';
447 if (subg
[grade
][0] == current
) {
448 html
+= ' selected="selected"';
450 html
+= '>' + subg
[grade
][1] + '</option>';
458 function makeAddProcess(id
)
460 return function(data
)
462 $('#medals').after(data
);
471 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
472 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
475 function removeMedal(id
)
477 $("#medal_" + id
).remove();
484 function removeJob(id
, pref
)
486 document
.getElementById(id
+ '_cont').style
.display
= 'none';
487 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
488 document
.getElementById(id
+ '_grayed').style
.display
= '';
489 document
.getElementById(id
+ '_grayed_name').innerHTML
=
490 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
492 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
495 function restoreJob(id
, pref
)
497 document
.getElementById(id
+ '_cont').style
.display
= '';
498 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
499 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
502 function updateJobSecteur(nb
, id
, pref
, sel
)
504 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
508 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id
+ '/' + pref + '/' + secteur
+ '/' + sel
);
511 function updateJobSousSecteur(nb
, id
, pref
, sel
)
513 var ssecteur
= document
.forms
.prof_annu
[pref
+ '[ss_secteur]'].value
;
514 if (ssecteur
== '') {
517 Ajax
.update_html(id
+ '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur
+ '/' + sel
);
520 function displayAllSector(id
)
522 $('.sector_text_' + id
).remove();
523 $('.sector_' + id
).show();
526 function makeAddJob(id
)
528 return function(data
)
530 $('#add_job').before(data
);
531 registerEnterpriseAutocomplete(id
);
532 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
539 while (document
.getElementById('job_' + i
) != null) {
542 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
545 function addEntreprise(id
)
547 $('.entreprise_' + id
).toggle();
552 function updateSkill(cat
)
554 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
559 if (document
.getElementById(cat
+ '_' + val
) != null) {
562 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
565 function addSkill(cat
)
567 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
569 var text
= sel
.options
[sel
.selectedIndex
].text
;
570 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
572 $('#' + cat
).append(data
);
573 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
578 function removeSkill(cat
, id
)
580 $('#' + cat
+ '_' + id
).remove();
587 function updateCountry()
589 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
591 if (val
== '' || val
== '00') {
594 if (document
.getElementById('countries_' + val
) != null) {
597 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
600 function addCountry()
602 var cb
= document
.forms
.prof_annu
.countries_sel
;
604 var text
= cb
.options
[cb
.selectedIndex
].text
;
605 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
606 + ' <a href="javascript:removeCountry(\'' + val
+ '\')" style="display: block; float:right">'
607 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
609 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
610 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
612 $('#countries').append(html
);
616 function removeCountry(id
)
618 $('#countries_' + id
).remove();
621 function updateSSecteur()
623 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
624 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
626 if (s
== '' || ss
== '') {
629 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
632 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
635 function updateSecteur()
637 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
640 document
.getElementById('ss_secteur_sel').innerHTML
= '';
643 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/0/0/' + secteur
,
645 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
646 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
648 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
649 $(document
.forms
.prof_annu
['jobs[-1][ss_secteur]']).change(updateSSecteur
);
653 function addSecteur()
655 var scb
= document
.forms
.prof_annu
.secteur_sel
;
657 var st
= scb
.options
[scb
.selectedIndex
].text
;
659 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
661 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
663 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
664 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
665 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
667 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
670 $('#secteurs').append(html
);
674 function removeSecteur(s
, ss
)
676 $('#secteurs_' + s
+ '_' + ss
).remove();
680 function registerEnterpriseAutocomplete(id
)
682 $(".enterprise_name").each(
684 if (id
== -1 || this.name
== "jobs[" + id
+ "][name]") {
685 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/entreprise",
690 width
:$(this).width()
696 $(".sector_name").each(
698 if (id
== -1 || this.name
== "jobs[" + id
+ "][sss_secteur_name]") {
699 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/sss_secteur",
704 width
:$(this).width()
711 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: