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 setTimeout('registerEnterpriseAutocomplete(-1)', 100);
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
;
96 function removeObject(id
, pref
)
98 document
.getElementById(id
).style
.display
= "none";
99 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
102 function restoreObject(id
, pref
)
104 document
.getElementById(id
).style
.display
= '';
105 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
108 function getAddressElement(adrid
, adelement
)
110 return document
.forms
.prof_annu
["addresses[" + adrid
+ "][" + adelement
+ "]"];
113 function checkCurrentAddress(newCurrent
)
115 var hasCurrent
= false;
117 while (getAddressElement(i
, 'pub') != null) {
118 var radio
= getAddressElement(i
, 'current');
119 var removed
= getAddressElement(i
, 'removed');
120 if (removed
.value
== "1" && radio
.checked
) {
121 radio
.checked
= false;
122 } else if (radio
.checked
&& radio
!= newCurrent
) {
123 radio
.checked
= false;
124 } else if (radio
.checked
) {
131 while (getAddressElement(i
, 'pub') != null) {
132 var radio
= getAddressElement(i
, 'current');
133 var removed
= getAddressElement(i
, 'removed');
134 if (removed
.value
!= "1") {
143 function removeAddress(id
, pref
)
145 removeObject(id
, pref
);
146 checkCurrentAddress(null);
147 if (document
.forms
.prof_annu
[pref
+ '[datemaj]'].value
!= '') {
148 document
.getElementById(id
+ '_grayed').style
.display
= '';
152 function restoreAddress(id
, pref
)
154 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
155 checkCurrentAddress(null);
156 restoreObject(id
, pref
);
159 function addAddress()
162 while (getAddressElement(i
, 'pub') != null) {
165 $("#add_adr").before('<div id="addresses_' + i
+ '_cont"></div>');
166 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress
);
172 var adid
= 'addresses_' + id
;
173 var tel
= adid
+ '_tel_';
174 while (document
.getElementById(tel
+ i
) != null) {
177 $('#' + adid
+ '_add_tel').before('<div id="' + tel
+ i
+ '" style="clear: both"></div>');
178 Ajax
.update_html(tel
+ i
, 'profile/ajax/tel/' + id + '/' + i
);
184 function validGeoloc(id
, pref
)
186 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
187 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
188 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
189 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
190 document
.forms
.prof_annu
[pref
+ "[text]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc]"].value
;
191 document
.forms
.prof_annu
[pref
+ "[cityid]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc_cityid]"].value
;
192 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
193 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
194 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
197 function validAddress(id
, pref
)
199 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
200 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
201 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
202 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
203 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
204 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
205 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
211 function updateGroup(type
)
213 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
214 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
215 document
.getElementById(type
+ '_add').style
.display
= 'none';
217 document
.getElementById(type
+ '_add').style
.display
= '';
221 function removeGroup(cat
, id
)
223 $('#' + cat
+ '_' + id
).remove();
227 function addGroup(cat
)
229 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
231 var text
= cb
.options
[cb
.selectedIndex
].text
;
232 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
234 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
237 + ' <div style="float: left; width: 70%">'
240 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
241 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
245 $('#' + cat
).after(html
);
249 function updateGroupSubLink(cb
)
251 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
252 document
.getElementById("groupesx_sub").href
= href
;
258 function updateMedal()
260 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
261 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
262 document
.getElementById('medal_add').style
.display
= 'none';
264 document
.getElementById('medal_add').style
.display
= '';
268 function getMedalName(id
)
270 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
273 function buildGrade(id
, current
)
276 var subg
= subgrades
[id
];
277 var obj
= $('#medal_grade_' + id
);
279 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
281 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
282 html
+= '<option value="0">Non précisée</option>';
283 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
284 html
+= '<option value="' + subg
[grade
][0] + '"';
285 if (subg
[grade
][0] == current
) {
286 html
+= ' selected="selected"';
288 html
+= '>' + subg
[grade
][1] + '</option>';
296 function makeAddProcess(id
)
298 return function(data
)
300 $('#medals').after(data
);
309 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
310 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
313 function removeMedal(id
)
315 $("#medal_" + id
).remove();
322 function removeJob(id
, pref
)
324 document
.getElementById(id
+ '_cont').style
.display
= 'none';
325 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
326 document
.getElementById(id
+ '_grayed').style
.display
= '';
327 document
.getElementById(id
+ '_grayed_name').innerHTML
=
328 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
330 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
333 function restoreJob(id
, pref
)
335 document
.getElementById(id
+ '_cont').style
.display
= '';
336 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
337 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
340 function updateJobSecteur(nb
, id
, pref
, sel
)
342 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
346 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur
+ '/' + sel
);
349 function makeAddJob(id
)
351 return function(data
)
353 $('#add_job').before(data
);
354 registerEnterpriseAutocomplete(id
);
355 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
362 while (document
.getElementById('job_' + i
) != null) {
365 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
371 function updateSkill(cat
)
373 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
378 if (document
.getElementById(cat
+ '_' + val
) != null) {
381 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
384 function addSkill(cat
)
386 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
388 var text
= sel
.options
[sel
.selectedIndex
].text
;
389 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
391 $('#' + cat
).append(data
);
392 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
397 function removeSkill(cat
, id
)
399 $('#' + cat
+ '_' + id
).remove();
406 function updateCountry()
408 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
410 if (val
== '' || val
== '00') {
413 if (document
.getElementById('countries_' + val
) != null) {
416 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
419 function addCountry()
421 var cb
= document
.forms
.prof_annu
.countries_sel
;
423 var text
= cb
.options
[cb
.selectedIndex
].text
;
424 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
425 + ' <a href="javascript:removeCountry(\'' + val
+ '\')" style="display: block; float:right">'
426 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
428 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
429 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
431 $('#countries').append(html
);
435 function removeCountry(id
)
437 $('#countries_' + id
).remove();
440 function updateSSecteur()
442 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
443 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
445 if (s
== '' || ss
== '') {
448 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
451 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
454 function updateSecteur()
456 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
459 document
.getElementById('ss_secteur_sel').innerHTML
= '';
462 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/' + secteur
,
464 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
465 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
467 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
468 attachEvent(document
.forms
.prof_annu
['jobs[-1][ss_secteur]'], 'change', updateSSecteur
);
472 function addSecteur()
474 var scb
= document
.forms
.prof_annu
.secteur_sel
;
476 var st
= scb
.options
[scb
.selectedIndex
].text
;
478 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
480 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
482 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
483 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
484 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
486 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
489 $('#secteurs').append(html
);
493 function removeSecteur(s
, ss
)
495 $('#secteurs_' + s
+ '_' + ss
).remove();
499 function registerEnterpriseAutocomplete(id
)
501 $(".enterprise_name").each(
503 if (id
== -1 || this.name
== "jobs[" + id
+ "][name]") {
504 $(this).autocomplete(platal_baseurl
+ "search/autocomplete/entreprise",
509 width
:$(this).width()
516 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: