dafdeae3ba7234fc63a1789e956fe5594d205919
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
)
27 fillType(document
.forms
.prof_annu
['appli1[type]'], document
.forms
.prof_annu
['appli1[id]'].selectedIndex
-1);
28 selectType(document
.forms
.prof_annu
['appli1[type]'], document
.forms
.prof_annu
['appli1_tmp'].value
);
29 fillType(document
.forms
.prof_annu
['appli2[type]'], document
.forms
.prof_annu
['appli2[id]'].selectedIndex
-1);
30 selectType(document
.forms
.prof_annu
['appli2[type]'], document
.forms
.prof_annu
['appli2_tmp'].value
);
33 updateGroupSubLink(document
.forms
.prof_annu
.groupesx_sub
);
36 for (var i
in names
) {
37 if (typeof names
[i
] != 'function') {
38 if (document
.getElementById("medal_" + i
) != null) {
40 buildGrade(i
, document
.forms
.prof_annu
["medal_" + i
+ "_grade"].value
);
46 for (var i
= 0 ; document
.getElementById('job_' + i
) != null ; ++i
) {
47 updateJobSecteur(i
, 'job_' + i
, 'jobs[' + i
+ ']',
48 document
.forms
.prof_annu
["jobs[" + i
+ "][ss_secteur]"].value
);
50 registerEnterpriseAutocomplete(-1);
62 function fillType(selectCtrl
, appli
, fill
)
67 for (i
= selectCtrl
.options
.length
; i
>=0; i
--) {
68 selectCtrl
.options
[i
] = null;
71 if (fill
|| appli
<0) {
72 selectCtrl
.options
[0] = new Option(' ');
76 for (i
=0; i
< applisType
[appli
].length
; i
++)
77 selectCtrl
.options
[i0
+i
] = new Option(applisType
[appli
][i
]);
79 for (i
=0; i
< applisTypeAll
.length
; i
++)
80 selectCtrl
.options
[i0
+i
] = new Option(applisTypeAll
[i
]);
84 function selectType(selectCtrl
, type
)
86 for (i
= 0; i
< selectCtrl
.options
.length
; i
++) {
87 if (selectCtrl
.options
[i
].text
== type
)
88 selectCtrl
.selectedIndex
=i
;
92 function addSearchName()
95 while (document
.getElementById('search_name_' + i
) != null) {
98 $('#add_search_name').before('<div id="search_name_' + i
+ '" style="padding:2px" class="center"></div>');
99 Ajax
.update_html('search_name_' + i
, 'profile/ajax/searchname/' + i
,function(){
100 $('#search_name_'+i
+' input')[1].focus();
104 function removeSearchName(i
)
106 if (document
.getElementById('search_name_'+i
+'_new') != null) {
107 $('#search_name_'+i
).remove();
109 removeObject('search_name_'+i
, 'search_name['+i
+']');
113 function delNationality(i
)
115 $('#nationalite' + i
).hide().find('select').val('');
118 function addNationality()
121 if ($('#nationalite2').find('select').val() == "") {
123 } else if ($('#nationalite3').find('select').val() == "") {
126 if ((i
== 2) || (i
== 3)) {
127 $('#nationalite' + i
).show();
131 function addNetworking()
134 var nws
= 'networking_';
135 while (document
.getElementById(nws
+ i
) != null) {
139 var html
= '<tr id="networking_' + i
+ '">'
140 + ' <td colspan="2">'
141 + ' <div style="float: left; width: 200px;">'
142 + ' <span class="flags">'
143 + ' <input type="checkbox" name="networking[' + i
+ '][pub]"/>'
144 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
146 + ' <select id="networking_type_' + i
+ '" name="networking[' + i
+ '][type]" onchange="javascript:updateNetworking(' + i
+ ');">';
147 for (nw
in nw_list
) {
148 if (namefirst
== '') {
151 html
+= ' <option value="' + nw_list
[nw
] + '">' + nw
+ '</option>';
154 + ' <input type="hidden" id="networking_name_' + i
+ '" name="networking[' + i
+ '][name]" value="' + namefirst
+ '"/>'
156 + ' <div style="float: left">'
157 + ' <input type="text" name="networking[' + i
+ '][address]" value="" size="30"/>'
158 + ' <a href="javascript:removeNetworking(' + i
+ ')">'
159 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
165 $('#networking').before(html
);
168 function removeNetworking(id
)
170 $('#networking_' + id
).remove();
173 function updateNetworking(i
)
175 var name
= document
.getElementById('networking_name_' + i
);
176 var type
= document
.getElementById('networking_type_' + i
);
177 if (type
!= null && name
!= null) {
178 name
.value
= type
.options
[type
.selectedIndex
].text
;
185 function removeObject(id
, pref
)
187 document
.getElementById(id
).style
.display
= "none";
188 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
191 function restoreObject(id
, pref
)
193 document
.getElementById(id
).style
.display
= '';
194 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
197 function getAddressElement(adrid
, adelement
)
199 return document
.forms
.prof_annu
["addresses[" + adrid
+ "][" + adelement
+ "]"];
202 function checkCurrentAddress(newCurrent
)
204 var hasCurrent
= false;
206 while (getAddressElement(i
, 'pub') != null) {
207 var radio
= getAddressElement(i
, 'current');
208 var removed
= getAddressElement(i
, 'removed');
209 if (removed
.value
== "1" && radio
.checked
) {
210 radio
.checked
= false;
211 } else if (radio
.checked
&& radio
!= newCurrent
) {
212 radio
.checked
= false;
213 } else if (radio
.checked
) {
220 while (getAddressElement(i
, 'pub') != null) {
221 var radio
= getAddressElement(i
, 'current');
222 var removed
= getAddressElement(i
, 'removed');
223 if (removed
.value
!= "1") {
232 function removeAddress(id
, pref
)
234 removeObject(id
, pref
);
235 checkCurrentAddress(null);
236 if (document
.forms
.prof_annu
[pref
+ '[datemaj]'].value
!= '') {
237 document
.getElementById(id
+ '_grayed').style
.display
= '';
241 function restoreAddress(id
, pref
)
243 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
244 checkCurrentAddress(null);
245 restoreObject(id
, pref
);
248 function addAddress()
251 while (getAddressElement(i
, 'pub') != null) {
254 $("#add_adr").before('<div id="addresses_' + i
+ '_cont"></div>');
255 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress
);
258 function addTel(prefid
, prefname
)
261 var prefix
= prefid
+ '_';
262 while (document
.getElementById(prefix
+ i
) != null) {
265 $('#' + prefix
+ 'add').before('<div id="' + prefix
+ i
+ '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
266 Ajax
.update_html(prefix
+ i
, 'profile/ajax/tel/' + prefid + '/' + prefname
+ '/' + i
);
269 function removeTel(id
)
271 $('#' + id
).remove();
274 function addPhoneComment(id
, pref
)
276 document
.getElementById(id
+'_comment').style
.display
= '';
277 document
.getElementById(id
+'_addComment').style
.display
= 'none';
280 function removePhoneComment(id
, pref
)
282 document
.getElementById(id
+'_comment').style
.display
= 'none';
283 document
.forms
.prof_annu
[pref
+ '[comment]'].value
= '';
284 document
.getElementById(id
+'_addComment').style
.display
= '';
289 function validGeoloc(id
, pref
)
291 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
292 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
293 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
294 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
295 document
.forms
.prof_annu
[pref
+ "[text]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc]"].value
;
296 document
.forms
.prof_annu
[pref
+ "[cityid]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc_cityid]"].value
;
297 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
298 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
299 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
302 function validAddress(id
, pref
)
304 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
305 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
306 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
307 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
308 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
309 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
310 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
316 function updateGroup(type
)
318 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
319 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
320 document
.getElementById(type
+ '_add').style
.display
= 'none';
322 document
.getElementById(type
+ '_add').style
.display
= '';
326 function removeGroup(cat
, id
)
328 $('#' + cat
+ '_' + id
).remove();
332 function addGroup(cat
)
334 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
336 var text
= cb
.options
[cb
.selectedIndex
].text
;
337 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
339 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
342 + ' <div style="float: left; width: 70%">'
345 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
346 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
350 $('#' + cat
).after(html
);
354 function updateGroupSubLink(cb
)
356 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
357 document
.getElementById("groupesx_sub").href
= href
;
363 function updateMedal()
365 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
366 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
367 document
.getElementById('medal_add').style
.display
= 'none';
369 document
.getElementById('medal_add').style
.display
= '';
373 function getMedalName(id
)
375 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
378 function buildGrade(id
, current
)
381 var subg
= subgrades
[id
];
382 var obj
= $('#medal_grade_' + id
);
384 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
386 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
387 html
+= '<option value="0">Non précisée</option>';
388 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
389 html
+= '<option value="' + subg
[grade
][0] + '"';
390 if (subg
[grade
][0] == current
) {
391 html
+= ' selected="selected"';
393 html
+= '>' + subg
[grade
][1] + '</option>';
401 function makeAddProcess(id
)
403 return function(data
)
405 $('#medals').after(data
);
414 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
415 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
418 function removeMedal(id
)
420 $("#medal_" + id
).remove();
427 function removeJob(id
, pref
)
429 document
.getElementById(id
+ '_cont').style
.display
= 'none';
430 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
431 document
.getElementById(id
+ '_grayed').style
.display
= '';
432 document
.getElementById(id
+ '_grayed_name').innerHTML
=
433 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
435 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
438 function restoreJob(id
, pref
)
440 document
.getElementById(id
+ '_cont').style
.display
= '';
441 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
442 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
445 function updateJobSecteur(nb
, id
, pref
, sel
)
447 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
451 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur
+ '/' + sel
);
454 function makeAddJob(id
)
456 return function(data
)
458 $('#add_job').before(data
);
459 registerEnterpriseAutocomplete(id
);
460 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
467 while (document
.getElementById('job_' + i
) != null) {
470 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
476 function updateSkill(cat
)
478 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
483 if (document
.getElementById(cat
+ '_' + val
) != null) {
486 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
489 function addSkill(cat
)
491 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
493 var text
= sel
.options
[sel
.selectedIndex
].text
;
494 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
496 $('#' + cat
).append(data
);
497 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
502 function removeSkill(cat
, id
)
504 $('#' + cat
+ '_' + id
).remove();
511 function updateCountry()
513 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
515 if (val
== '' || val
== '00') {
518 if (document
.getElementById('countries_' + val
) != null) {
521 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
524 function addCountry()
526 var cb
= document
.forms
.prof_annu
.countries_sel
;
528 var text
= cb
.options
[cb
.selectedIndex
].text
;
529 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
530 + ' <a href="javascript:removeCountry(\'' + val
+ '\')" style="display: block; float:right">'
531 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
533 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
534 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
536 $('#countries').append(html
);
540 function removeCountry(id
)
542 $('#countries_' + id
).remove();
545 function updateSSecteur()
547 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
548 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
550 if (s
== '' || ss
== '') {
553 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
556 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
559 function updateSecteur()
561 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
564 document
.getElementById('ss_secteur_sel').innerHTML
= '';
567 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/' + secteur
,
569 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
570 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
572 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
573 attachEvent(document
.forms
.prof_annu
['jobs[-1][ss_secteur]'], 'change', updateSSecteur
);
577 function addSecteur()
579 var scb
= document
.forms
.prof_annu
.secteur_sel
;
581 var st
= scb
.options
[scb
.selectedIndex
].text
;
583 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
585 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
587 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
588 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
589 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
591 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
594 $('#secteurs').append(html
);
598 function removeSecteur(s
, ss
)
600 $('#secteurs_' + s
+ '_' + ss
).remove();
604 function registerEnterpriseAutocomplete(id
)
606 $(".enterprise_name").each(
608 if (id
== -1 || this.name
== "jobs[" + id
+ "][name]") {
609 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/entreprise",
614 width
:$(this).width()
621 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: