1 /***************************************************************************
2 * Copyright (C) 2003-2007 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
);
61 function fillType(selectCtrl
, appli
, fill
)
66 for (i
= selectCtrl
.options
.length
; i
>=0; i
--) {
67 selectCtrl
.options
[i
] = null;
70 if (fill
|| appli
<0) {
71 selectCtrl
.options
[0] = new Option(' ');
75 for (i
=0; i
< applisType
[appli
].length
; i
++)
76 selectCtrl
.options
[i0
+i
] = new Option(applisType
[appli
][i
]);
78 for (i
=0; i
< applisTypeAll
.length
; i
++)
79 selectCtrl
.options
[i0
+i
] = new Option(applisTypeAll
[i
]);
83 function selectType(selectCtrl
, type
)
85 for (i
= 0; i
< selectCtrl
.options
.length
; i
++) {
86 if (selectCtrl
.options
[i
].text
== type
)
87 selectCtrl
.selectedIndex
=i
;
91 function addSearchName()
94 while (document
.getElementById('search_name_' + i
) != null) {
97 $('#add_search_name').before('<div id="search_name_' + i
+ '" style="padding:2px" class="center"></div>');
98 Ajax
.update_html('search_name_' + i
, 'profile/ajax/searchname/' + i
,function(){
99 $('#search_name_'+i
+' input')[1].focus();
103 function removeSearchName(i
)
105 if (document
.getElementById('search_name_'+i
+'_new') != null) {
106 $('#search_name_'+i
).remove();
108 removeObject('search_name_'+i
, 'search_name['+i
+']');
114 function removeObject(id
, pref
)
116 document
.getElementById(id
).style
.display
= "none";
117 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
120 function restoreObject(id
, pref
)
122 document
.getElementById(id
).style
.display
= '';
123 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
126 function getAddressElement(adrid
, adelement
)
128 return document
.forms
.prof_annu
["addresses[" + adrid
+ "][" + adelement
+ "]"];
131 function checkCurrentAddress(newCurrent
)
133 var hasCurrent
= false;
135 while (getAddressElement(i
, 'pub') != null) {
136 var radio
= getAddressElement(i
, 'current');
137 var removed
= getAddressElement(i
, 'removed');
138 if (removed
.value
== "1" && radio
.checked
) {
139 radio
.checked
= false;
140 } else if (radio
.checked
&& radio
!= newCurrent
) {
141 radio
.checked
= false;
142 } else if (radio
.checked
) {
149 while (getAddressElement(i
, 'pub') != null) {
150 var radio
= getAddressElement(i
, 'current');
151 var removed
= getAddressElement(i
, 'removed');
152 if (removed
.value
!= "1") {
161 function removeAddress(id
, pref
)
163 removeObject(id
, pref
);
164 checkCurrentAddress(null);
165 if (document
.forms
.prof_annu
[pref
+ '[datemaj]'].value
!= '') {
166 document
.getElementById(id
+ '_grayed').style
.display
= '';
170 function restoreAddress(id
, pref
)
172 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
173 checkCurrentAddress(null);
174 restoreObject(id
, pref
);
177 function addAddress()
180 while (getAddressElement(i
, 'pub') != null) {
183 $("#add_adr").before('<div id="addresses_' + i
+ '_cont"></div>');
184 Ajax
.update_html('addresses_' + i
+ '_cont', 'profile/ajax/address/' + i
, checkCurrentAddress
);
190 var adid
= 'addresses_' + id
;
191 var tel
= adid
+ '_tel_';
192 while (document
.getElementById(tel
+ i
) != null) {
195 $('#' + adid
+ '_add_tel').before('<div id="' + tel
+ i
+ '" style="clear: both"></div>');
196 Ajax
.update_html(tel
+ i
, 'profile/ajax/tel/' + id + '/' + i
);
202 function validGeoloc(id
, pref
)
204 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
205 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
206 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
207 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
208 document
.forms
.prof_annu
[pref
+ "[text]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc]"].value
;
209 document
.forms
.prof_annu
[pref
+ "[cityid]"].value
= document
.forms
.prof_annu
[pref
+ "[geoloc_cityid]"].value
;
210 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
211 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
212 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
215 function validAddress(id
, pref
)
217 document
.getElementById(id
+ '_geoloc').style
.display
= 'none';
218 document
.getElementById(id
+ '_geoloc_error').style
.display
= 'none';
219 document
.getElementById(id
+ '_geoloc_valid').style
.display
= 'none';
220 document
.forms
.prof_annu
[pref
+ "[parsevalid]"].value
= "1";
221 attachEvent(document
.forms
.prof_annu
[pref
+ "[text]"], "click",
222 function() { document
.forms
.prof_annu
[pref
+ "[text]"].blur(); });
223 document
.forms
.prof_annu
[pref
+ "[text]"].className
= '';
229 function updateGroup(type
)
231 var val
= document
.forms
.prof_annu
[type
+ '_sel'].value
;
232 if (val
== '0' || document
.getElementById(type
+ '_' + val
) != null) {
233 document
.getElementById(type
+ '_add').style
.display
= 'none';
235 document
.getElementById(type
+ '_add').style
.display
= '';
239 function removeGroup(cat
, id
)
241 $('#' + cat
+ '_' + id
).remove();
245 function addGroup(cat
)
247 var cb
= document
.forms
.prof_annu
[cat
+ '_sel'];
249 var text
= cb
.options
[cb
.selectedIndex
].text
;
250 var html
= '<tr id="' + cat
+ '_' + id
+ '">'
252 + ' <input type="hidden" name="' + cat
+ '[' + id
+ ']" value="' + text
+ '" />'
255 + ' <div style="float: left; width: 70%">'
258 + ' <a href="javascript:removeGroup(\'' + cat
+ '\', ' + id
+ ')">'
259 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
263 $('#' + cat
).after(html
);
267 function updateGroupSubLink(cb
)
269 var href
= cb
.value
? cb
.value
: "http://www.polytechnique.net";
270 document
.getElementById("groupesx_sub").href
= href
;
276 function updateMedal()
278 var val
= document
.forms
.prof_annu
['medal_sel'].value
;
279 if (val
== '' || document
.getElementById('medal_' + val
) != null) {
280 document
.getElementById('medal_add').style
.display
= 'none';
282 document
.getElementById('medal_add').style
.display
= '';
286 function getMedalName(id
)
288 document
.getElementById('medal_name_' + id
).innerHTML
= names
[id
];
291 function buildGrade(id
, current
)
294 var subg
= subgrades
[id
];
295 var obj
= $('#medal_grade_' + id
);
297 obj
.prepend('<input type="hidden" name="medals[' + id
+ '][grade]" value="0" />');
299 var html
= 'Agrafe : <select name="medals[' + id
+ '][grade]">';
300 html
+= '<option value="0">Non précisée</option>';
301 for (grade
= 0 ; grade
< subg
.length
; grade
++) {
302 html
+= '<option value="' + subg
[grade
][0] + '"';
303 if (subg
[grade
][0] == current
) {
304 html
+= ' selected="selected"';
306 html
+= '>' + subg
[grade
][1] + '</option>';
314 function makeAddProcess(id
)
316 return function(data
)
318 $('#medals').after(data
);
327 var id
= document
.forms
.prof_annu
['medal_sel'].value
;
328 $.get(platal_baseurl
+ 'profile/ajax/medal/' + id
, makeAddProcess(id
));
331 function removeMedal(id
)
333 $("#medal_" + id
).remove();
340 function removeJob(id
, pref
)
342 document
.getElementById(id
+ '_cont').style
.display
= 'none';
343 if (document
.forms
.prof_annu
[pref
+ '[new]'].value
== '0') {
344 document
.getElementById(id
+ '_grayed').style
.display
= '';
345 document
.getElementById(id
+ '_grayed_name').innerHTML
=
346 document
.forms
.prof_annu
[pref
+ "[name]"].value
.replace('<', '<');
348 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "1";
351 function restoreJob(id
, pref
)
353 document
.getElementById(id
+ '_cont').style
.display
= '';
354 document
.getElementById(id
+ '_grayed').style
.display
= 'none';
355 document
.forms
.prof_annu
[pref
+ "[removed]"].value
= "0";
358 function updateJobSecteur(nb
, id
, pref
, sel
)
360 var secteur
= document
.forms
.prof_annu
[pref
+ '[secteur]'].value
;
364 Ajax
.update_html(id
+ '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur
+ '/' + sel
);
367 function makeAddJob(id
)
369 return function(data
)
371 $('#add_job').before(data
);
372 updateSecteur('job_' + id
, 'jobs[' + id
+ ']', '');
379 while (document
.getElementById('job_' + i
) != null) {
382 $.get(platal_baseurl
+ 'profile/ajax/job/' + i
, makeAddJob(i
));
388 function updateSkill(cat
)
390 var val
= document
.forms
.prof_annu
[cat
+ '_sel'].value
;
395 if (document
.getElementById(cat
+ '_' + val
) != null) {
398 document
.getElementById(cat
+ '_add').style
.display
= show
? '' : 'none';
401 function addSkill(cat
)
403 var sel
= document
.forms
.prof_annu
[cat
+ '_sel'];
405 var text
= sel
.options
[sel
.selectedIndex
].text
;
406 $.get(platal_baseurl
+ 'profile/ajax/skill/' + cat + '/' + val
,
408 $('#' + cat
).append(data
);
409 document
.getElementById(cat
+ '_' + val
+ '_title').innerHTML
= text
;
414 function removeSkill(cat
, id
)
416 $('#' + cat
+ '_' + id
).remove();
423 function updateCountry()
425 var val
= document
.forms
.prof_annu
.countries_sel
.value
;
430 if (document
.getElementById('countries_' + val
) != null) {
433 document
.getElementById('countries_add').style
.display
= show
? '' : 'none';
436 function addCountry()
438 var cb
= document
.forms
.prof_annu
.countries_sel
;
440 var text
= cb
.options
[cb
.selectedIndex
].text
;
441 var html
= '<div id="countries_' + val
+ '" style="clear: both; margin-bottom: 0.7em">'
442 + ' <div style="float: left; width: 50%">' + text
+ '</div>'
443 + ' <input type="hidden" name="countries[' + val
+ ']" value="' + text
+ '" />'
444 + ' <a href="javascript:removeCountry(\'' + val
+ '\')">'
445 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
448 $('#countries').append(html
);
452 function removeCountry(id
)
454 $('#countries_' + id
).remove();
457 function updateSSecteur()
459 var s
= document
.forms
.prof_annu
.secteur_sel
.value
;
460 var ss
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'].value
;
462 if (s
== '' || ss
== '') {
465 if (document
.getElementById('secteurs_' + s
+ '_' + ss
) != null) {
468 document
.getElementById('secteurs_add').style
.display
= show
? 'block' : 'none';
471 function updateSecteur()
473 var secteur
= document
.forms
.prof_annu
.secteur_sel
.value
;
477 $.get(platal_baseurl
+ 'profile/ajax/secteur/-1/' + secteur
,
479 data
= '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
480 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
482 document
.getElementById('ss_secteur_sel').innerHTML
= data
;
483 attachEvent(document
.forms
.prof_annu
['jobs[-1][ss_secteur]'], 'change', updateSSecteur
);
487 function addSecteur()
489 var scb
= document
.forms
.prof_annu
.secteur_sel
;
491 var st
= scb
.options
[scb
.selectedIndex
].text
;
493 var sscb
= document
.forms
.prof_annu
['jobs[-1][ss_secteur]'];
495 var sst
= sscb
.options
[sscb
.selectedIndex
].text
;
497 var html
= '<div id="secteurs_' + s
+ '_' + ss
+ '" style="clear: both; margin-top: 0.5em" class="titre">'
498 + ' <a href="javascript:removeSecteur(\'' + s
+ '\', \'' + ss
+ '\')" style="display: block; float: right">'
499 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
501 + ' <input type="hidden" name="secteurs[' + s
+ '][' + ss
+ ']" value="' + sst
+ '" />'
504 $('#secteurs').append(html
);
508 function removeSecteur(s
, ss
)
510 $('#secteurs_' + s
+ '_' + ss
).remove();
514 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: