4b3c4700c67f836cf8bf2bfcab0ad18f3065bb86
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
);
54 registerEnterpriseAutocomplete(-1);
60 var educationDegreeAll
;
61 var educationDegreeName
;
67 function fillType(selectCtrl
, edu
, fill
)
72 for (i
= selectCtrl
.options
.length
; i
>= 0; i
--) {
73 selectCtrl
.options
[i
] = null;
76 if (fill
|| edu
< 0) {
77 selectCtrl
.options
[0] = new Option(' ');
81 for (i
= 0; i
< educationDegree
[edu
].length
; i
++) {
82 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegree
[edu
][i
] - 1], educationDegree
[edu
][i
]);
85 for (i
= 0; i
< educationDegreeAll
.length
; i
++) {
86 selectCtrl
.options
[i0
+ i
] = new Option(educationDegreeName
[educationDegreeAll
[i
] - 1], educationDegreeAll
[i
]);
92 function selectType(selectCtrl
, type
)
94 for (i
= 0; i
< selectCtrl
.options
.length
; i
++) {
95 if (selectCtrl
.options
[i
].value
== type
) {
96 selectCtrl
.selectedIndex
= i
;
101 function prepareType(i
)
103 fillType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edus[" + i
+ "][eduid]"].selectedIndex
- 1);
104 selectType(document
.forms
.prof_annu
["edus[" + i
+ "][degreeid]"], document
.forms
.prof_annu
["edu_" + i
+ "_tmp"].value
);
107 function addSearchName()
110 while (document
.getElementById('search_name_' + i
) != null) {
113 $('#add_search_name').before('<div id="search_name_' + i
+ '" style="padding:2px" class="center"></div>');
114 Ajax
.update_html('search_name_' + i
, 'profile/ajax/searchname/' + i
,function(){
115 $('#search_name_'+i
+' input')[1].focus();
119 function removeSearchName(i
)
121 if (document
.getElementById('search_name_'+i
+'_new') != null) {
122 $('#search_name_'+i
).remove();
124 removeObject('search_name_'+i
, 'search_name['+i
+']');
128 function delNationality(i
)
130 $('#nationalite' + i
).hide().find('select').val('');
133 function addNationality()
136 if ($('#nationalite2').find('select').val() == "") {
138 } else if ($('#nationalite3').find('select').val() == "") {
141 if ((i
== 2) || (i
== 3)) {
142 $('#nationalite' + i
).show();
146 function addNetworking()
149 var nws
= 'networking_';
150 while (document
.getElementById(nws
+ i
) != null) {
154 var html
= '<tr id="networking_' + i
+ '">'
155 + ' <td colspan="2">'
156 + ' <div style="float: left; width: 200px;">'
157 + ' <span class="flags">'
158 + ' <input type="checkbox" name="networking[' + i
+ '][pub]"/>'
159 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
161 + ' <select id="networking_type_' + i
+ '" name="networking[' + i
+ '][type]" onchange="javascript:updateNetworking(' + i
+ ');">';
162 for (nw
in nw_list
) {
163 if (namefirst
== '') {
166 html
+= ' <option value="' + nw_list
[nw
] + '">' + nw
+ '</option>';
169 + ' <input type="hidden" id="networking_name_' + i
+ '" name="networking[' + i
+ '][name]" value="' + namefirst
+ '"/>'
171 + ' <div style="float: left">'
172 + ' <input type="text" name="networking[' + i
+ '][address]" value="" size="30"/>'
173 + ' <a href="javascript:removeNetworking(' + i
+ ')">'
174 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
180 $('#networking').before(html
);
183 function removeNetworking(id
)
185 $('#networking_' + id
).remove();
188 function updateNetworking(i
)
190 var name
= document
.getElementById('networking_name_' + i
);
191 var type
= document
.getElementById('networking_type_' + i
);
192 if (type
!= null && name
!= null) {
193 name
.value
= type
.options
[type
.selectedIndex
].text
;
200 function removeObject(id
, pref
)
202 document
.getElementById(id
).style
.display
= "none";
203 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
206 function restoreObject(id
, pref
)
208 document
.getElementById(id
).style
.display
= '';
209 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
212 function getAddressElement(adrid
, adelement
)
214 return document
.forms
.prof_annu
["addresses[" + adrid
+ "][" + adelement
+ "]"];
217 function checkCurrentAddress(newCurrent
)
219 var hasCurrent
= false;
221 while (getAddressElement(i
, 'pub') != null) {
222 var radio
= getAddressElement(i
, 'current');
223 var removed
= getAddressElement(i
, 'removed');
224 if (removed
.value
== "1" && radio
.checked
) {
225 radio
.checked
= false;
226 } else if (radio
.checked
&& radio
!= newCurrent
) {
227 radio
.checked
= false;
228 } else if (radio
.checked
) {
235 while (getAddressElement(i
, 'pub') != null) {
236 var radio
= getAddressElement(i
, 'current');
237 var removed
= getAddressElement(i
, 'removed');
238 if (removed
.value
!= "1") {
247 function removeAddress(id
, pref
)
249 removeObject(id
, pref
);
250 checkCurrentAddress(null);
251 if (document
.forms
.prof_annu
[pref
+ '[datemaj]'].value
!= '') {
252 document
.getElementById(id
+ '_grayed').style
.display
= '';
256 function restoreAddress(id
, pref
)
258 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
259 checkCurrentAddress(null);
260 restoreObject(id
, pref
);
263 function addAddress()
266 while (getAddressElement(i
, 'pub') != null) {
269 $("#add_adr").before('<div id="addresses_' + i
+ '_cont"></div>');
270 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress
);
279 while ($('.' + prefix
+ i
).length
!= 0) {
283 class_parity
= 'pair';
285 class_parity
= 'impair';
287 $.get(platal_baseurl
+ 'profile/ajax/edu/' + i + '/' + class_parity
,
289 $('#edu_add').before(data
);
294 function removeEdu(id
)
296 $('.' + id
).remove();
299 function addTel(prefid
, prefname
)
302 var prefix
= prefid
+ '_';
303 while (document
.getElementById(prefix
+ i
) != null) {
306 $('#' + prefix
+ 'add').before('<div id="' + prefix
+ i
+ '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
307 Ajax
.update_html(prefix
+ i
, 'profile/ajax/tel/' + prefid + '/' + prefname
+ '/' + i
);
310 function removeTel(id
)
312 $('#' + id
).remove();
315 function addPhoneComment(id
, pref
)
317 document
.getElementById(id
+'_comment').style
.display
= '';
318 document
.getElementById(id
+'_addComment').style
.display
= 'none';
321 function removePhoneComment(id
, pref
)
323 document
.getElementById(id
+'_comment').style
.display
= 'none';
324 document
.forms
.prof_annu
[pref
+ '[comment]'].value
= '';
325 document
.getElementById(id
+'_addComment').style
.display
= '';
330 function validGeoloc(id
, pref
)
332 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
333 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
334 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
335 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
336 document
.forms
.prof_annu
[pref
+ "[text]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc]"].value
;
337 document
.forms
.prof_annu
[pref
+ "[cityid]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc_cityid]"].value
;
338 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
339 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
340 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
343 function validAddress(id
, pref
)
345 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
346 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
347 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
348 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
349 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
350 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
351 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
357 function updateGroup(type
)
359 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
360 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
361 document
.getElementById(type
+ '_add').style
.display
= 'none';
363 document
.getElementById(type
+ '_add').style
.display
= '';
367 function removeGroup(cat
, id
)
369 $('#' + cat
+ '_' + id
).remove();
373 function addGroup(cat
)
375 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
377 var text
= cb
.options
[cb
.selectedIndex
].text
;
378 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
380 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
383 + ' <div style="float: left; width: 70%">'
386 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
387 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
391 $('#' + cat
).after(html
);
395 function updateGroupSubLink(cb
)
397 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
398 document
.getElementById("groupesx_sub").href
= href
;
404 function updateMedal()
406 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
407 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
408 document
.getElementById('medal_add').style
.display
= 'none';
410 document
.getElementById('medal_add').style
.display
= '';
414 function getMedalName(id
)
416 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
419 function buildGrade(id
, current
)
422 var subg
= subgrades
[id
];
423 var obj
= $('#medal_grade_' + id
);
425 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
427 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
428 html
+= '<option value="0">Non précisée</option>';
429 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
430 html
+= '<option value="' + subg
[grade
][0] + '"';
431 if (subg
[grade
][0] == current
) {
432 html
+= ' selected="selected"';
434 html
+= '>' + subg
[grade
][1] + '</option>';
442 function makeAddProcess(id
)
444 return function(data
)
446 $('#medals').after(data
);
455 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
456 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
459 function removeMedal(id
)
461 $("#medal_" + id
).remove();
468 function removeJob(id
, pref
)
470 document
.getElementById(id
+ '_cont').style
.display
= 'none';
471 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
472 document
.getElementById(id
+ '_grayed').style
.display
= '';
473 document
.getElementById(id
+ '_grayed_name').innerHTML
=
474 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
476 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
479 function restoreJob(id
, pref
)
481 document
.getElementById(id
+ '_cont').style
.display
= '';
482 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
483 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
486 function updateJobSecteur(nb
, id
, pref
, sel
)
488 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
492 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur
+ '/' + sel
);
495 function makeAddJob(id
)
497 return function(data
)
499 $('#add_job').before(data
);
500 registerEnterpriseAutocomplete(id
);
501 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
508 while (document
.getElementById('job_' + i
) != null) {
511 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
517 function updateSkill(cat
)
519 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
524 if (document
.getElementById(cat
+ '_' + val
) != null) {
527 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
530 function addSkill(cat
)
532 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
534 var text
= sel
.options
[sel
.selectedIndex
].text
;
535 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
537 $('#' + cat
).append(data
);
538 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
543 function removeSkill(cat
, id
)
545 $('#' + cat
+ '_' + id
).remove();
552 function updateCountry()
554 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
556 if (val
== '' || val
== '00') {
559 if (document
.getElementById('countries_' + val
) != null) {
562 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
565 function addCountry()
567 var cb
= document
.forms
.prof_annu
.countries_sel
;
569 var text
= cb
.options
[cb
.selectedIndex
].text
;
570 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
571 + ' <a href="javascript:removeCountry(\'' + val
+ '\')" style="display: block; float:right">'
572 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
574 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
575 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
577 $('#countries').append(html
);
581 function removeCountry(id
)
583 $('#countries_' + id
).remove();
586 function updateSSecteur()
588 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
589 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
591 if (s
== '' || ss
== '') {
594 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
597 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
600 function updateSecteur()
602 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
605 document
.getElementById('ss_secteur_sel').innerHTML
= '';
608 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/' + secteur
,
610 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
611 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
613 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
614 attachEvent(document
.forms
.prof_annu
['jobs[-1][ss_secteur]'], 'change', updateSSecteur
);
618 function addSecteur()
620 var scb
= document
.forms
.prof_annu
.secteur_sel
;
622 var st
= scb
.options
[scb
.selectedIndex
].text
;
624 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
626 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
628 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
629 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
630 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
632 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
635 $('#secteurs').append(html
);
639 function removeSecteur(s
, ss
)
641 $('#secteurs_' + s
+ '_' + ss
).remove();
645 function registerEnterpriseAutocomplete(id
)
647 $(".enterprise_name").each(
649 if (id
== -1 || this.name
== "jobs[" + id
+ "][name]") {
650 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/entreprise",
655 width
:$(this).width()
662 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: