Commit | Line | Data |
---|---|---|
46ae38a9 | 1 | /*************************************************************************** |
179afa7f | 2 | * Copyright (C) 2003-2008 Polytechnique.org * |
46ae38a9 FB |
3 | * http://opensource.polytechnique.org/ * |
4 | * * | |
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. * | |
9 | * * | |
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. * | |
14 | * * | |
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 * | |
17 | * Foundation, Inc., * | |
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
19 | ***************************************************************************/ | |
20 | ||
21 | // Page initialization | |
22 | ||
23 | function wizPage_onLoad(id) | |
24 | { | |
25 | switch (id) { | |
26 | case 'general': | |
043bbacf SJ |
27 | var i = 0; |
28 | var prefix = 'edu_'; | |
58acfe8b | 29 | while ($('.' + prefix + i).length != 0) { |
043bbacf SJ |
30 | i++; |
31 | } | |
32 | for (var j = 0; j < i; j++) { | |
33 | prepareType(j); | |
34 | } | |
46ae38a9 FB |
35 | break; |
36 | case 'poly': | |
37 | updateGroupSubLink(document.forms.prof_annu.groupesx_sub); | |
38 | break; | |
39 | case 'deco': | |
40 | for (var i in names) { | |
41 | if (typeof names[i] != 'function') { | |
42 | if (document.getElementById("medal_" + i) != null) { | |
43 | getMedalName(i); | |
44 | buildGrade(i, document.forms.prof_annu["medal_" + i + "_grade"].value); | |
45 | } | |
46 | } | |
47 | } | |
48 | break; | |
49 | case 'emploi': | |
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); | |
c7139c07 SJ |
53 | updateJobSousSecteur(i, 'job_' + i, 'jobs[' + i + ']', |
54 | document.forms.prof_annu["jobs[" + i + "][sss_secteur]"].value); | |
46ae38a9 | 55 | } |
933d9a4c | 56 | setTimeout('registerEnterpriseAutocomplete(-1)', 100); |
46ae38a9 FB |
57 | break; |
58 | } | |
59 | } | |
60 | ||
f711b03f SJ |
61 | var educationDegree; |
62 | var educationDegreeAll; | |
63 | var educationDegreeName; | |
46ae38a9 FB |
64 | |
65 | // General | |
66 | ||
67 | var subgrades; | |
68 | var names; | |
f711b03f | 69 | function fillType(selectCtrl, edu, fill) |
46ae38a9 FB |
70 | { |
71 | var i; | |
043bbacf | 72 | var i0 = 0; |
46ae38a9 | 73 | |
043bbacf | 74 | for (i = selectCtrl.options.length; i >= 0; i--) { |
46ae38a9 FB |
75 | selectCtrl.options[i] = null; |
76 | } | |
77 | ||
f711b03f | 78 | if (fill || edu < 0) { |
46ae38a9 | 79 | selectCtrl.options[0] = new Option(' '); |
043bbacf SJ |
80 | i0 = 1; |
81 | } | |
f711b03f SJ |
82 | if (edu >= 0) { |
83 | for (i = 0; i < educationDegree[edu].length; i++) { | |
84 | selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegree[edu][i] - 1], educationDegree[edu][i]); | |
043bbacf SJ |
85 | } |
86 | } else if (fill) { | |
f711b03f SJ |
87 | for (i = 0; i < educationDegreeAll.length; i++) { |
88 | selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegreeAll[i] - 1], educationDegreeAll[i]); | |
043bbacf | 89 | } |
46ae38a9 | 90 | } |
46ae38a9 FB |
91 | } |
92 | ||
93 | ||
94 | function selectType(selectCtrl, type) | |
95 | { | |
96 | for (i = 0; i < selectCtrl.options.length; i++) { | |
043bbacf SJ |
97 | if (selectCtrl.options[i].value == type) { |
98 | selectCtrl.selectedIndex = i; | |
99 | } | |
46ae38a9 FB |
100 | } |
101 | } | |
102 | ||
043bbacf SJ |
103 | function prepareType(i) |
104 | { | |
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); | |
107 | } | |
108 | ||
b04882ff PC |
109 | function addSearchName() |
110 | { | |
111 | var i = 0; | |
112 | while (document.getElementById('search_name_' + i) != null) { | |
113 | i++; | |
114 | } | |
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(); | |
118 | }); | |
119 | } | |
46ae38a9 | 120 | |
b04882ff PC |
121 | function removeSearchName(i) |
122 | { | |
123 | if (document.getElementById('search_name_'+i+'_new') != null) { | |
124 | $('#search_name_'+i).remove(); | |
125 | } else { | |
126 | removeObject('search_name_'+i, 'search_name['+i+']'); | |
127 | } | |
128 | } | |
46ae38a9 | 129 | |
8450c2aa SJ |
130 | function delNationality(i) |
131 | { | |
132 | $('#nationalite' + i).hide().find('select').val(''); | |
133 | } | |
134 | ||
135 | function addNationality() | |
136 | { | |
137 | var i = 0; | |
138 | if ($('#nationalite2').find('select').val() == "") { | |
139 | i = 2; | |
140 | } else if ($('#nationalite3').find('select').val() == "") { | |
141 | i = 3; | |
142 | } | |
143 | if ((i == 2) || (i == 3)) { | |
144 | $('#nationalite' + i).show(); | |
145 | } | |
146 | } | |
147 | ||
d1a2252a GB |
148 | function addNetworking() |
149 | { | |
150 | var i = 0; | |
92c3f9e5 GB |
151 | var nws = 'networking_'; |
152 | while (document.getElementById(nws + i) != null) { | |
d1a2252a GB |
153 | i++; |
154 | } | |
92c3f9e5 | 155 | var namefirst = ''; |
d1a2252a | 156 | var html = '<tr id="networking_' + i + '">' |
92c3f9e5 GB |
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">' | |
162 | + ' </span> ' | |
163 | + ' <select id="networking_type_' + i + '" name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">'; | |
164 | for (nw in nw_list) { | |
165 | if (namefirst == '') { | |
166 | namefirst = nw; | |
167 | } | |
168 | html += ' <option value="' + nw_list[nw] + '">' + nw + '</option>'; | |
169 | } | |
170 | html += '</select>' | |
171 | + ' <input type="hidden" id="networking_name_' + i + '" name="networking[' + i + '][name]" value="' + namefirst + '"/>' | |
172 | + ' </div>' | |
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"/>' | |
177 | + ' </a>' | |
178 | + ' </div>' | |
d1a2252a GB |
179 | + ' </td>' |
180 | + '</tr>'; | |
181 | ||
92c3f9e5 | 182 | $('#networking').before(html); |
d1a2252a GB |
183 | } |
184 | ||
185 | function removeNetworking(id) | |
186 | { | |
187 | $('#networking_' + id).remove(); | |
188 | } | |
189 | ||
92c3f9e5 | 190 | function updateNetworking(i) |
d1a2252a | 191 | { |
92c3f9e5 GB |
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; | |
d1a2252a | 196 | } |
92c3f9e5 | 197 | |
d1a2252a GB |
198 | } |
199 | ||
46ae38a9 FB |
200 | // Addresses |
201 | ||
202 | function removeObject(id, pref) | |
203 | { | |
204 | document.getElementById(id).style.display = "none"; | |
205 | document.forms.prof_annu[pref + "[removed]"].value = "1"; | |
206 | } | |
207 | ||
208 | function restoreObject(id, pref) | |
209 | { | |
210 | document.getElementById(id).style.display = ''; | |
211 | document.forms.prof_annu[pref + "[removed]"].value = "0"; | |
212 | } | |
213 | ||
214 | function getAddressElement(adrid, adelement) | |
215 | { | |
216 | return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"]; | |
217 | } | |
218 | ||
219 | function checkCurrentAddress(newCurrent) | |
220 | { | |
221 | var hasCurrent = false; | |
222 | var i = 0; | |
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) { | |
231 | hasCurrent = true; | |
232 | } | |
233 | i++; | |
234 | } | |
235 | if (!hasCurrent) { | |
236 | i = 0; | |
237 | while (getAddressElement(i, 'pub') != null) { | |
238 | var radio = getAddressElement(i, 'current'); | |
239 | var removed = getAddressElement(i, 'removed'); | |
240 | if (removed.value != "1") { | |
241 | radio.checked= true; | |
242 | return; | |
243 | } | |
244 | i++; | |
245 | } | |
246 | } | |
247 | } | |
248 | ||
249 | function removeAddress(id, pref) | |
250 | { | |
251 | removeObject(id, pref); | |
252 | checkCurrentAddress(null); | |
253 | if (document.forms.prof_annu[pref + '[datemaj]'].value != '') { | |
254 | document.getElementById(id + '_grayed').style.display = ''; | |
255 | } | |
256 | } | |
257 | ||
258 | function restoreAddress(id, pref) | |
259 | { | |
260 | document.getElementById(id + '_grayed').style.display = 'none'; | |
261 | checkCurrentAddress(null); | |
262 | restoreObject(id, pref); | |
263 | } | |
264 | ||
265 | function addAddress() | |
266 | { | |
267 | var i = 0; | |
268 | while (getAddressElement(i, 'pub') != null) { | |
269 | i++; | |
270 | } | |
271 | $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>'); | |
272 | Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); | |
273 | } | |
274 | ||
043bbacf SJ |
275 | function addEdu() |
276 | { | |
277 | var i = 0; | |
62dba58e | 278 | var j = 0; |
043bbacf | 279 | var prefix = 'edu_'; |
58acfe8b SJ |
280 | var class_parity; |
281 | ||
62dba58e SJ |
282 | while (!$('#edu_add').hasClass(prefix + i)) { |
283 | if ($('.' + prefix + i).length != 0) { | |
284 | j++; | |
285 | } | |
043bbacf SJ |
286 | i++; |
287 | } | |
62dba58e | 288 | if (j % 2) { |
58acfe8b SJ |
289 | class_parity = 'pair'; |
290 | } else { | |
291 | class_parity = 'impair'; | |
292 | } | |
62dba58e SJ |
293 | $('#edu_add').removeClass(prefix + i); |
294 | i++; | |
295 | $('#edu_add').addClass(prefix + i); | |
296 | i--; | |
58acfe8b | 297 | $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity, |
043bbacf | 298 | function(data) { |
58acfe8b | 299 | $('#edu_add').before(data); |
043bbacf SJ |
300 | prepareType(i); |
301 | }); | |
302 | } | |
303 | ||
62dba58e | 304 | function removeEdu(i) |
043bbacf | 305 | { |
62dba58e SJ |
306 | var prefix = 'edu_'; |
307 | $('.' + prefix + i).remove(); | |
308 | while (!$('#edu_add').hasClass(prefix + i)) { | |
309 | $('.' + prefix + i).toggleClass('pair'); | |
310 | $('.' + prefix + i).toggleClass('impair'); | |
311 | i++; | |
312 | } | |
043bbacf SJ |
313 | } |
314 | ||
bde2be3b | 315 | function addTel(prefid, prefname) |
46ae38a9 FB |
316 | { |
317 | var i = 0; | |
bde2be3b GB |
318 | var prefix = prefid + '_'; |
319 | while (document.getElementById(prefix + i) != null) { | |
46ae38a9 FB |
320 | i++; |
321 | } | |
bde2be3b GB |
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); | |
46ae38a9 FB |
324 | } |
325 | ||
bde2be3b GB |
326 | function removeTel(id) |
327 | { | |
328 | $('#' + id).remove(); | |
329 | } | |
330 | ||
331 | function addPhoneComment(id, pref) | |
332 | { | |
333 | document.getElementById(id+'_comment').style.display = ''; | |
334 | document.getElementById(id+'_addComment').style.display = 'none'; | |
335 | } | |
336 | ||
337 | function removePhoneComment(id, pref) | |
338 | { | |
339 | document.getElementById(id+'_comment').style.display = 'none'; | |
340 | document.forms.prof_annu[pref+ '[comment]'].value = ''; | |
341 | document.getElementById(id+'_addComment').style.display = ''; | |
342 | } | |
46ae38a9 FB |
343 | |
344 | // Geoloc | |
345 | ||
346 | function validGeoloc(id, pref) | |
347 | { | |
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; | |
af66b871 | 353 | document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value; |
46ae38a9 FB |
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 = ''; | |
357 | } | |
358 | ||
359 | function validAddress(id, pref) | |
360 | { | |
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'; | |
af66b871 | 364 | document.forms.prof_annu[pref + "[parsevalid]"].value = "1"; |
46ae38a9 FB |
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 = ''; | |
368 | } | |
369 | ||
370 | ||
371 | // Groups | |
372 | ||
373 | function updateGroup(type) | |
374 | { | |
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'; | |
378 | } else { | |
379 | document.getElementById(type + '_add').style.display = ''; | |
380 | } | |
381 | } | |
382 | ||
383 | function removeGroup(cat, id) | |
384 | { | |
385 | $('#' + cat + '_' + id).remove(); | |
386 | updateGroup(cat); | |
387 | } | |
388 | ||
389 | function addGroup(cat) | |
390 | { | |
391 | var cb = document.forms.prof_annu[cat + '_sel']; | |
392 | var id = cb.value; | |
393 | var text = cb.options[cb.selectedIndex].text; | |
394 | var html = '<tr id="' + cat + '_' + id + '">' | |
395 | + ' <td>' | |
396 | + ' <input type="hidden" name="' + cat + '[' + id + ']" value="' + text + '" />' | |
397 | + ' </td>' | |
398 | + ' <td>' | |
399 | + ' <div style="float: left; width: 70%">' | |
400 | + text | |
401 | + ' </div>' | |
402 | + ' <a href="javascript:removeGroup(\'' + cat + '\', ' + id + ')">' | |
403 | + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />' | |
404 | + ' </a>' | |
405 | + ' </td>' | |
406 | + '</tr>'; | |
407 | $('#' + cat).after(html); | |
408 | updateGroup(cat); | |
409 | } | |
410 | ||
411 | function updateGroupSubLink(cb) | |
412 | { | |
413 | var href = cb.value ? cb.value : "http://www.polytechnique.net"; | |
414 | document.getElementById("groupesx_sub").href = href; | |
415 | } | |
416 | ||
417 | ||
418 | // Medals | |
419 | ||
420 | function updateMedal() | |
421 | { | |
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'; | |
425 | } else { | |
426 | document.getElementById('medal_add').style.display = ''; | |
427 | } | |
428 | } | |
429 | ||
430 | function getMedalName(id) | |
431 | { | |
432 | document.getElementById('medal_name_' + id).innerHTML = names[id]; | |
433 | } | |
434 | ||
435 | function buildGrade(id, current) | |
436 | { | |
437 | var grade; | |
438 | var subg = subgrades[id]; | |
439 | var obj = $('#medal_grade_' + id); | |
440 | if (!subg) { | |
441 | obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />'); | |
442 | } else { | |
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"'; | |
449 | } | |
450 | html += '>' + subg[grade][1] + '</option>'; | |
451 | } | |
452 | ||
453 | html += '</select>'; | |
454 | obj.prepend(html); | |
455 | } | |
456 | } | |
457 | ||
458 | function makeAddProcess(id) | |
459 | { | |
460 | return function(data) | |
461 | { | |
462 | $('#medals').after(data); | |
463 | updateMedal(); | |
464 | getMedalName(id); | |
465 | buildGrade(id, 0); | |
466 | }; | |
467 | } | |
468 | ||
469 | function addMedal() | |
470 | { | |
471 | var id = document.forms.prof_annu['medal_sel'].value; | |
472 | $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id)); | |
473 | } | |
474 | ||
475 | function removeMedal(id) | |
476 | { | |
477 | $("#medal_" + id).remove(); | |
478 | updateMedal(); | |
479 | } | |
480 | ||
481 | ||
482 | // Jobs | |
483 | ||
484 | function removeJob(id, pref) | |
485 | { | |
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('<', '<'); | |
491 | } | |
492 | document.forms.prof_annu[pref + "[removed]"].value = "1"; | |
493 | } | |
494 | ||
495 | function restoreJob(id, pref) | |
496 | { | |
497 | document.getElementById(id + '_cont').style.display = ''; | |
498 | document.getElementById(id + '_grayed').style.display = 'none'; | |
499 | document.forms.prof_annu[pref + "[removed]"].value = "0"; | |
500 | } | |
501 | ||
502 | function updateJobSecteur(nb, id, pref, sel) | |
503 | { | |
504 | var secteur = document.forms.prof_annu[pref + '[secteur]'].value; | |
505 | if (secteur == '') { | |
506 | secteur = '-1'; | |
507 | } | |
c7139c07 SJ |
508 | Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id + '/' + pref + '/' + secteur + '/' + sel); |
509 | } | |
510 | ||
511 | function updateJobSousSecteur(nb, id, pref, sel) | |
512 | { | |
513 | var ssecteur = document.forms.prof_annu[pref + '[ss_secteur]'].value; | |
514 | if (ssecteur == '') { | |
515 | ssecteur = '-1'; | |
516 | } | |
517 | Ajax.update_html(id + '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur + '/' + sel); | |
518 | } | |
519 | ||
b814a8b8 | 520 | function displayAllSector(id) |
c7139c07 | 521 | { |
b814a8b8 SJ |
522 | $('.sector_text_' + id).remove(); |
523 | $('.sector_' + id).show(); | |
46ae38a9 FB |
524 | } |
525 | ||
526 | function makeAddJob(id) | |
527 | { | |
528 | return function(data) | |
529 | { | |
530 | $('#add_job').before(data); | |
16594a1a | 531 | registerEnterpriseAutocomplete(id); |
46ae38a9 FB |
532 | updateSecteur('job_' + id, 'jobs[' + id + ']', ''); |
533 | }; | |
534 | } | |
535 | ||
536 | function addJob() | |
537 | { | |
538 | var i = 0; | |
539 | while (document.getElementById('job_' + i) != null) { | |
540 | ++i; | |
541 | } | |
542 | $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i)); | |
543 | } | |
544 | ||
b814a8b8 SJ |
545 | function addEntreprise(id) |
546 | { | |
547 | $('.entreprise_' + id).toggle(); | |
548 | } | |
46ae38a9 FB |
549 | |
550 | // Skills | |
551 | ||
552 | function updateSkill(cat) | |
553 | { | |
554 | var val = document.forms.prof_annu[cat + '_sel'].value; | |
555 | var show = true; | |
556 | if (val == '') { | |
557 | show = false; | |
558 | } | |
559 | if (document.getElementById(cat + '_' + val) != null) { | |
560 | show = false; | |
561 | } | |
562 | document.getElementById(cat + '_add').style.display = show ? '' : 'none'; | |
563 | } | |
564 | ||
565 | function addSkill(cat) | |
566 | { | |
567 | var sel = document.forms.prof_annu[cat + '_sel']; | |
568 | var val = sel.value; | |
569 | var text = sel.options[sel.selectedIndex].text; | |
570 | $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val, | |
571 | function(data) { | |
572 | $('#' + cat).append(data); | |
573 | document.getElementById(cat + '_' + val + '_title').innerHTML = text; | |
574 | updateSkill(cat); | |
575 | }); | |
576 | } | |
577 | ||
578 | function removeSkill(cat, id) | |
579 | { | |
580 | $('#' + cat + '_' + id).remove(); | |
581 | updateSkill(cat); | |
582 | } | |
583 | ||
584 | ||
585 | // Mentor | |
586 | ||
587 | function updateCountry() | |
588 | { | |
589 | var val = document.forms.prof_annu.countries_sel.value; | |
590 | var show = true; | |
1d414e12 | 591 | if (val == '' || val == '00') { |
46ae38a9 FB |
592 | show = false; |
593 | } | |
594 | if (document.getElementById('countries_' + val) != null) { | |
595 | show = false; | |
596 | } | |
597 | document.getElementById('countries_add').style.display = show ? '' : 'none'; | |
598 | } | |
599 | ||
600 | function addCountry() | |
601 | { | |
602 | var cb = document.forms.prof_annu.countries_sel; | |
603 | var val = cb.value; | |
604 | var text = cb.options[cb.selectedIndex].text; | |
605 | var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">' | |
1d414e12 | 606 | + ' <a href="javascript:removeCountry(\'' + val + '\')" style="display: block; float:right">' |
46ae38a9 FB |
607 | + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />' |
608 | + ' </a>' | |
1d414e12 PC |
609 | + ' <div style="float: left; width: 50%">' + text + '</div>' |
610 | + ' <input type="hidden" name="countries[' + val + ']" value="' + text + '" />' | |
46ae38a9 FB |
611 | + '</div>'; |
612 | $('#countries').append(html); | |
613 | updateCountry(); | |
614 | } | |
615 | ||
616 | function removeCountry(id) | |
617 | { | |
618 | $('#countries_' + id).remove(); | |
619 | updateCountry(); | |
620 | } | |
621 | function updateSSecteur() | |
622 | { | |
623 | var s = document.forms.prof_annu.secteur_sel.value; | |
624 | var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value; | |
625 | var show = true; | |
626 | if (s == '' || ss == '') { | |
627 | show = false; | |
628 | } | |
629 | if (document.getElementById('secteurs_' + s + '_' + ss) != null) { | |
630 | show = false; | |
631 | } | |
632 | document.getElementById('secteurs_add').style.display = show ? 'block' : 'none'; | |
633 | } | |
634 | ||
635 | function updateSecteur() | |
636 | { | |
637 | var secteur = document.forms.prof_annu.secteur_sel.value; | |
638 | if (secteur == '') { | |
639 | secteur = '-1'; | |
76a2858c PC |
640 | document.getElementById('ss_secteur_sel').innerHTML = ''; |
641 | return; | |
46ae38a9 | 642 | } |
5fecdf6d | 643 | $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur, |
46ae38a9 | 644 | function(data) { |
5fecdf6d SJ |
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" />' | |
647 | + '</a>' + data; | |
648 | document.getElementById('ss_secteur_sel').innerHTML = data; | |
649 | $(document.forms.prof_annu['jobs[-1][ss_secteur]']).change(updateSSecteur); | |
46ae38a9 FB |
650 | }); |
651 | } | |
652 | ||
653 | function addSecteur() | |
654 | { | |
655 | var scb = document.forms.prof_annu.secteur_sel; | |
656 | var s = scb.value; | |
657 | var st = scb.options[scb.selectedIndex].text; | |
658 | ||
659 | var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]']; | |
660 | var ss = sscb.value; | |
661 | var sst = sscb.options[sscb.selectedIndex].text; | |
662 | ||
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" />' | |
666 | + ' </a>' | |
667 | + ' <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />' | |
668 | + ' ' + sst | |
669 | + '</div>'; | |
670 | $('#secteurs').append(html); | |
671 | updateSSecteur(); | |
672 | } | |
673 | ||
674 | function removeSecteur(s, ss) | |
675 | { | |
676 | $('#secteurs_' + s + '_' + ss).remove(); | |
677 | updateSSecteur(); | |
678 | } | |
679 | ||
16594a1a FB |
680 | function registerEnterpriseAutocomplete(id) |
681 | { | |
16594a1a FB |
682 | $(".enterprise_name").each( |
683 | function() { | |
16594a1a FB |
684 | if (id == -1 || this.name == "jobs[" + id + "][name]") { |
685 | $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise", | |
686 | { | |
687 | selectOnly:1, | |
688 | field:this.name, | |
689 | matchSubset:0, | |
690 | width:$(this).width() | |
691 | }); | |
692 | } | |
693 | } | |
694 | ); | |
c7139c07 SJ |
695 | |
696 | $(".sector_name").each( | |
697 | function() { | |
698 | if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") { | |
699 | $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur", | |
700 | { | |
701 | selectOnly:1, | |
702 | field:this.name, | |
703 | matchSubset:0, | |
704 | width:$(this).width() | |
705 | }); | |
706 | } | |
707 | } | |
708 | ); | |
16594a1a FB |
709 | } |
710 | ||
46ae38a9 | 711 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |