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_'; | |
29 | while (document.getElementById(prefix + i) != null) { | |
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); | |
53 | } | |
16594a1a | 54 | registerEnterpriseAutocomplete(-1); |
46ae38a9 FB |
55 | break; |
56 | } | |
57 | } | |
58 | ||
59 | var applisType; | |
60 | var applisTypeAll; | |
043bbacf | 61 | var applisTypeName; |
46ae38a9 FB |
62 | |
63 | // General | |
64 | ||
65 | var subgrades; | |
66 | var names; | |
67 | function fillType(selectCtrl, appli, fill) | |
68 | { | |
69 | var i; | |
043bbacf | 70 | var i0 = 0; |
46ae38a9 | 71 | |
043bbacf | 72 | for (i = selectCtrl.options.length; i >= 0; i--) { |
46ae38a9 FB |
73 | selectCtrl.options[i] = null; |
74 | } | |
75 | ||
043bbacf | 76 | if (fill || appli < 0) { |
46ae38a9 | 77 | selectCtrl.options[0] = new Option(' '); |
043bbacf SJ |
78 | i0 = 1; |
79 | } | |
80 | if (appli >= 0) { | |
81 | for (i = 0; i < applisType[appli].length; i++) { | |
82 | selectCtrl.options[i0 + i] = new Option(applisTypeName[applisType[appli][i] - 1], applisType[appli][i]); | |
83 | } | |
84 | } else if (fill) { | |
85 | for (i = 0; i < applisTypeAll.length; i++) { | |
86 | selectCtrl.options[i0 + i] = new Option(applisTypeName[applisTypeAll[i] - 1], applisTypeAll[i]); | |
87 | } | |
46ae38a9 | 88 | } |
46ae38a9 FB |
89 | } |
90 | ||
91 | ||
92 | function selectType(selectCtrl, type) | |
93 | { | |
94 | for (i = 0; i < selectCtrl.options.length; i++) { | |
043bbacf SJ |
95 | if (selectCtrl.options[i].value == type) { |
96 | selectCtrl.selectedIndex = i; | |
97 | } | |
46ae38a9 FB |
98 | } |
99 | } | |
100 | ||
043bbacf SJ |
101 | function prepareType(i) |
102 | { | |
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); | |
105 | } | |
106 | ||
b04882ff PC |
107 | function addSearchName() |
108 | { | |
109 | var i = 0; | |
110 | while (document.getElementById('search_name_' + i) != null) { | |
111 | i++; | |
112 | } | |
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(); | |
116 | }); | |
117 | } | |
46ae38a9 | 118 | |
b04882ff PC |
119 | function removeSearchName(i) |
120 | { | |
121 | if (document.getElementById('search_name_'+i+'_new') != null) { | |
122 | $('#search_name_'+i).remove(); | |
123 | } else { | |
124 | removeObject('search_name_'+i, 'search_name['+i+']'); | |
125 | } | |
126 | } | |
46ae38a9 | 127 | |
8450c2aa SJ |
128 | function delNationality(i) |
129 | { | |
130 | $('#nationalite' + i).hide().find('select').val(''); | |
131 | } | |
132 | ||
133 | function addNationality() | |
134 | { | |
135 | var i = 0; | |
136 | if ($('#nationalite2').find('select').val() == "") { | |
137 | i = 2; | |
138 | } else if ($('#nationalite3').find('select').val() == "") { | |
139 | i = 3; | |
140 | } | |
141 | if ((i == 2) || (i == 3)) { | |
142 | $('#nationalite' + i).show(); | |
143 | } | |
144 | } | |
145 | ||
d1a2252a GB |
146 | function addNetworking() |
147 | { | |
148 | var i = 0; | |
92c3f9e5 GB |
149 | var nws = 'networking_'; |
150 | while (document.getElementById(nws + i) != null) { | |
d1a2252a GB |
151 | i++; |
152 | } | |
92c3f9e5 | 153 | var namefirst = ''; |
d1a2252a | 154 | var html = '<tr id="networking_' + i + '">' |
92c3f9e5 GB |
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">' | |
160 | + ' </span> ' | |
161 | + ' <select id="networking_type_' + i + '" name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">'; | |
162 | for (nw in nw_list) { | |
163 | if (namefirst == '') { | |
164 | namefirst = nw; | |
165 | } | |
166 | html += ' <option value="' + nw_list[nw] + '">' + nw + '</option>'; | |
167 | } | |
168 | html += '</select>' | |
169 | + ' <input type="hidden" id="networking_name_' + i + '" name="networking[' + i + '][name]" value="' + namefirst + '"/>' | |
170 | + ' </div>' | |
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"/>' | |
175 | + ' </a>' | |
176 | + ' </div>' | |
d1a2252a GB |
177 | + ' </td>' |
178 | + '</tr>'; | |
179 | ||
92c3f9e5 | 180 | $('#networking').before(html); |
d1a2252a GB |
181 | } |
182 | ||
183 | function removeNetworking(id) | |
184 | { | |
185 | $('#networking_' + id).remove(); | |
186 | } | |
187 | ||
92c3f9e5 | 188 | function updateNetworking(i) |
d1a2252a | 189 | { |
92c3f9e5 GB |
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; | |
d1a2252a | 194 | } |
92c3f9e5 | 195 | |
d1a2252a GB |
196 | } |
197 | ||
46ae38a9 FB |
198 | // Addresses |
199 | ||
200 | function removeObject(id, pref) | |
201 | { | |
202 | document.getElementById(id).style.display = "none"; | |
203 | document.forms.prof_annu[pref + "[removed]"].value = "1"; | |
204 | } | |
205 | ||
206 | function restoreObject(id, pref) | |
207 | { | |
208 | document.getElementById(id).style.display = ''; | |
209 | document.forms.prof_annu[pref + "[removed]"].value = "0"; | |
210 | } | |
211 | ||
212 | function getAddressElement(adrid, adelement) | |
213 | { | |
214 | return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"]; | |
215 | } | |
216 | ||
217 | function checkCurrentAddress(newCurrent) | |
218 | { | |
219 | var hasCurrent = false; | |
220 | var i = 0; | |
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) { | |
229 | hasCurrent = true; | |
230 | } | |
231 | i++; | |
232 | } | |
233 | if (!hasCurrent) { | |
234 | i = 0; | |
235 | while (getAddressElement(i, 'pub') != null) { | |
236 | var radio = getAddressElement(i, 'current'); | |
237 | var removed = getAddressElement(i, 'removed'); | |
238 | if (removed.value != "1") { | |
239 | radio.checked= true; | |
240 | return; | |
241 | } | |
242 | i++; | |
243 | } | |
244 | } | |
245 | } | |
246 | ||
247 | function removeAddress(id, pref) | |
248 | { | |
249 | removeObject(id, pref); | |
250 | checkCurrentAddress(null); | |
251 | if (document.forms.prof_annu[pref + '[datemaj]'].value != '') { | |
252 | document.getElementById(id + '_grayed').style.display = ''; | |
253 | } | |
254 | } | |
255 | ||
256 | function restoreAddress(id, pref) | |
257 | { | |
258 | document.getElementById(id + '_grayed').style.display = 'none'; | |
259 | checkCurrentAddress(null); | |
260 | restoreObject(id, pref); | |
261 | } | |
262 | ||
263 | function addAddress() | |
264 | { | |
265 | var i = 0; | |
266 | while (getAddressElement(i, 'pub') != null) { | |
267 | i++; | |
268 | } | |
269 | $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>'); | |
270 | Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); | |
271 | } | |
272 | ||
043bbacf SJ |
273 | function addEdu() |
274 | { | |
275 | var i = 0; | |
276 | var prefix = 'edu_'; | |
277 | while (document.getElementById(prefix + i) != null) { | |
278 | i++; | |
279 | } | |
280 | $('#edu_add').before('<div id="' + prefix + i + '"></div>'); | |
281 | $.get(platal_baseurl + 'profile/ajax/edu/' + i, | |
282 | function(data) { | |
283 | $("#" + prefix + i).html(data); | |
284 | prepareType(i); | |
285 | }); | |
286 | } | |
287 | ||
288 | function removeEdu(id) | |
289 | { | |
290 | $('#' + id).remove(); | |
291 | } | |
292 | ||
bde2be3b | 293 | function addTel(prefid, prefname) |
46ae38a9 FB |
294 | { |
295 | var i = 0; | |
bde2be3b GB |
296 | var prefix = prefid + '_'; |
297 | while (document.getElementById(prefix + i) != null) { | |
46ae38a9 FB |
298 | i++; |
299 | } | |
bde2be3b GB |
300 | $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>'); |
301 | Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); | |
46ae38a9 FB |
302 | } |
303 | ||
bde2be3b GB |
304 | function removeTel(id) |
305 | { | |
306 | $('#' + id).remove(); | |
307 | } | |
308 | ||
309 | function addPhoneComment(id, pref) | |
310 | { | |
311 | document.getElementById(id+'_comment').style.display = ''; | |
312 | document.getElementById(id+'_addComment').style.display = 'none'; | |
313 | } | |
314 | ||
315 | function removePhoneComment(id, pref) | |
316 | { | |
317 | document.getElementById(id+'_comment').style.display = 'none'; | |
318 | document.forms.prof_annu[pref+ '[comment]'].value = ''; | |
319 | document.getElementById(id+'_addComment').style.display = ''; | |
320 | } | |
46ae38a9 FB |
321 | |
322 | // Geoloc | |
323 | ||
324 | function validGeoloc(id, pref) | |
325 | { | |
326 | document.getElementById(id + '_geoloc').style.display = 'none'; | |
327 | document.getElementById(id + '_geoloc_error').style.display = 'none'; | |
328 | document.getElementById(id + '_geoloc_valid').style.display = 'none'; | |
329 | document.forms.prof_annu[pref + "[parsevalid]"].value = "1"; | |
330 | document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value; | |
af66b871 | 331 | document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value; |
46ae38a9 FB |
332 | attachEvent(document.forms.prof_annu[pref + "[text]"], "click", |
333 | function() { document.forms.prof_annu[pref + "[text]"].blur(); }); | |
334 | document.forms.prof_annu[pref + "[text]"].className = ''; | |
335 | } | |
336 | ||
337 | function validAddress(id, pref) | |
338 | { | |
339 | document.getElementById(id + '_geoloc').style.display = 'none'; | |
340 | document.getElementById(id + '_geoloc_error').style.display = 'none'; | |
341 | document.getElementById(id + '_geoloc_valid').style.display = 'none'; | |
af66b871 | 342 | document.forms.prof_annu[pref + "[parsevalid]"].value = "1"; |
46ae38a9 FB |
343 | attachEvent(document.forms.prof_annu[pref + "[text]"], "click", |
344 | function() { document.forms.prof_annu[pref + "[text]"].blur(); }); | |
345 | document.forms.prof_annu[pref + "[text]"].className = ''; | |
346 | } | |
347 | ||
348 | ||
349 | // Groups | |
350 | ||
351 | function updateGroup(type) | |
352 | { | |
353 | var val = document.forms.prof_annu[type + '_sel'].value; | |
354 | if (val == '0' || document.getElementById(type + '_' + val) != null) { | |
355 | document.getElementById(type + '_add').style.display = 'none'; | |
356 | } else { | |
357 | document.getElementById(type + '_add').style.display = ''; | |
358 | } | |
359 | } | |
360 | ||
361 | function removeGroup(cat, id) | |
362 | { | |
363 | $('#' + cat + '_' + id).remove(); | |
364 | updateGroup(cat); | |
365 | } | |
366 | ||
367 | function addGroup(cat) | |
368 | { | |
369 | var cb = document.forms.prof_annu[cat + '_sel']; | |
370 | var id = cb.value; | |
371 | var text = cb.options[cb.selectedIndex].text; | |
372 | var html = '<tr id="' + cat + '_' + id + '">' | |
373 | + ' <td>' | |
374 | + ' <input type="hidden" name="' + cat + '[' + id + ']" value="' + text + '" />' | |
375 | + ' </td>' | |
376 | + ' <td>' | |
377 | + ' <div style="float: left; width: 70%">' | |
378 | + text | |
379 | + ' </div>' | |
380 | + ' <a href="javascript:removeGroup(\'' + cat + '\', ' + id + ')">' | |
381 | + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />' | |
382 | + ' </a>' | |
383 | + ' </td>' | |
384 | + '</tr>'; | |
385 | $('#' + cat).after(html); | |
386 | updateGroup(cat); | |
387 | } | |
388 | ||
389 | function updateGroupSubLink(cb) | |
390 | { | |
391 | var href = cb.value ? cb.value : "http://www.polytechnique.net"; | |
392 | document.getElementById("groupesx_sub").href = href; | |
393 | } | |
394 | ||
395 | ||
396 | // Medals | |
397 | ||
398 | function updateMedal() | |
399 | { | |
400 | var val = document.forms.prof_annu['medal_sel'].value; | |
401 | if (val == '' || document.getElementById('medal_' + val) != null) { | |
402 | document.getElementById('medal_add').style.display = 'none'; | |
403 | } else { | |
404 | document.getElementById('medal_add').style.display = ''; | |
405 | } | |
406 | } | |
407 | ||
408 | function getMedalName(id) | |
409 | { | |
410 | document.getElementById('medal_name_' + id).innerHTML = names[id]; | |
411 | } | |
412 | ||
413 | function buildGrade(id, current) | |
414 | { | |
415 | var grade; | |
416 | var subg = subgrades[id]; | |
417 | var obj = $('#medal_grade_' + id); | |
418 | if (!subg) { | |
419 | obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />'); | |
420 | } else { | |
421 | var html = 'Agrafe : <select name="medals[' + id + '][grade]">'; | |
422 | html += '<option value="0">Non précisée</option>'; | |
423 | for (grade = 0 ; grade < subg.length ; grade++) { | |
424 | html += '<option value="' + subg[grade][0] + '"'; | |
425 | if (subg[grade][0] == current) { | |
426 | html += ' selected="selected"'; | |
427 | } | |
428 | html += '>' + subg[grade][1] + '</option>'; | |
429 | } | |
430 | ||
431 | html += '</select>'; | |
432 | obj.prepend(html); | |
433 | } | |
434 | } | |
435 | ||
436 | function makeAddProcess(id) | |
437 | { | |
438 | return function(data) | |
439 | { | |
440 | $('#medals').after(data); | |
441 | updateMedal(); | |
442 | getMedalName(id); | |
443 | buildGrade(id, 0); | |
444 | }; | |
445 | } | |
446 | ||
447 | function addMedal() | |
448 | { | |
449 | var id = document.forms.prof_annu['medal_sel'].value; | |
450 | $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id)); | |
451 | } | |
452 | ||
453 | function removeMedal(id) | |
454 | { | |
455 | $("#medal_" + id).remove(); | |
456 | updateMedal(); | |
457 | } | |
458 | ||
459 | ||
460 | // Jobs | |
461 | ||
462 | function removeJob(id, pref) | |
463 | { | |
464 | document.getElementById(id + '_cont').style.display = 'none'; | |
465 | if (document.forms.prof_annu[pref + '[new]'].value == '0') { | |
466 | document.getElementById(id + '_grayed').style.display = ''; | |
467 | document.getElementById(id + '_grayed_name').innerHTML = | |
468 | document.forms.prof_annu[pref + "[name]"].value.replace('<', '<'); | |
469 | } | |
470 | document.forms.prof_annu[pref + "[removed]"].value = "1"; | |
471 | } | |
472 | ||
473 | function restoreJob(id, pref) | |
474 | { | |
475 | document.getElementById(id + '_cont').style.display = ''; | |
476 | document.getElementById(id + '_grayed').style.display = 'none'; | |
477 | document.forms.prof_annu[pref + "[removed]"].value = "0"; | |
478 | } | |
479 | ||
480 | function updateJobSecteur(nb, id, pref, sel) | |
481 | { | |
482 | var secteur = document.forms.prof_annu[pref + '[secteur]'].value; | |
483 | if (secteur == '') { | |
484 | secteur = '-1'; | |
485 | } | |
486 | Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel); | |
487 | } | |
488 | ||
489 | function makeAddJob(id) | |
490 | { | |
491 | return function(data) | |
492 | { | |
493 | $('#add_job').before(data); | |
16594a1a | 494 | registerEnterpriseAutocomplete(id); |
46ae38a9 FB |
495 | updateSecteur('job_' + id, 'jobs[' + id + ']', ''); |
496 | }; | |
497 | } | |
498 | ||
499 | function addJob() | |
500 | { | |
501 | var i = 0; | |
502 | while (document.getElementById('job_' + i) != null) { | |
503 | ++i; | |
504 | } | |
505 | $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i)); | |
506 | } | |
507 | ||
508 | ||
509 | // Skills | |
510 | ||
511 | function updateSkill(cat) | |
512 | { | |
513 | var val = document.forms.prof_annu[cat + '_sel'].value; | |
514 | var show = true; | |
515 | if (val == '') { | |
516 | show = false; | |
517 | } | |
518 | if (document.getElementById(cat + '_' + val) != null) { | |
519 | show = false; | |
520 | } | |
521 | document.getElementById(cat + '_add').style.display = show ? '' : 'none'; | |
522 | } | |
523 | ||
524 | function addSkill(cat) | |
525 | { | |
526 | var sel = document.forms.prof_annu[cat + '_sel']; | |
527 | var val = sel.value; | |
528 | var text = sel.options[sel.selectedIndex].text; | |
529 | $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val, | |
530 | function(data) { | |
531 | $('#' + cat).append(data); | |
532 | document.getElementById(cat + '_' + val + '_title').innerHTML = text; | |
533 | updateSkill(cat); | |
534 | }); | |
535 | } | |
536 | ||
537 | function removeSkill(cat, id) | |
538 | { | |
539 | $('#' + cat + '_' + id).remove(); | |
540 | updateSkill(cat); | |
541 | } | |
542 | ||
543 | ||
544 | // Mentor | |
545 | ||
546 | function updateCountry() | |
547 | { | |
548 | var val = document.forms.prof_annu.countries_sel.value; | |
549 | var show = true; | |
1d414e12 | 550 | if (val == '' || val == '00') { |
46ae38a9 FB |
551 | show = false; |
552 | } | |
553 | if (document.getElementById('countries_' + val) != null) { | |
554 | show = false; | |
555 | } | |
556 | document.getElementById('countries_add').style.display = show ? '' : 'none'; | |
557 | } | |
558 | ||
559 | function addCountry() | |
560 | { | |
561 | var cb = document.forms.prof_annu.countries_sel; | |
562 | var val = cb.value; | |
563 | var text = cb.options[cb.selectedIndex].text; | |
564 | var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">' | |
1d414e12 | 565 | + ' <a href="javascript:removeCountry(\'' + val + '\')" style="display: block; float:right">' |
46ae38a9 FB |
566 | + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />' |
567 | + ' </a>' | |
1d414e12 PC |
568 | + ' <div style="float: left; width: 50%">' + text + '</div>' |
569 | + ' <input type="hidden" name="countries[' + val + ']" value="' + text + '" />' | |
46ae38a9 FB |
570 | + '</div>'; |
571 | $('#countries').append(html); | |
572 | updateCountry(); | |
573 | } | |
574 | ||
575 | function removeCountry(id) | |
576 | { | |
577 | $('#countries_' + id).remove(); | |
578 | updateCountry(); | |
579 | } | |
580 | function updateSSecteur() | |
581 | { | |
582 | var s = document.forms.prof_annu.secteur_sel.value; | |
583 | var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value; | |
584 | var show = true; | |
585 | if (s == '' || ss == '') { | |
586 | show = false; | |
587 | } | |
588 | if (document.getElementById('secteurs_' + s + '_' + ss) != null) { | |
589 | show = false; | |
590 | } | |
591 | document.getElementById('secteurs_add').style.display = show ? 'block' : 'none'; | |
592 | } | |
593 | ||
594 | function updateSecteur() | |
595 | { | |
596 | var secteur = document.forms.prof_annu.secteur_sel.value; | |
597 | if (secteur == '') { | |
598 | secteur = '-1'; | |
76a2858c PC |
599 | document.getElementById('ss_secteur_sel').innerHTML = ''; |
600 | return; | |
46ae38a9 FB |
601 | } |
602 | $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur, | |
603 | function(data) { | |
604 | data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">' | |
605 | + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />' | |
606 | + '</a>' + data; | |
607 | document.getElementById('ss_secteur_sel').innerHTML = data; | |
608 | attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur); | |
609 | }); | |
610 | } | |
611 | ||
612 | function addSecteur() | |
613 | { | |
614 | var scb = document.forms.prof_annu.secteur_sel; | |
615 | var s = scb.value; | |
616 | var st = scb.options[scb.selectedIndex].text; | |
617 | ||
618 | var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]']; | |
619 | var ss = sscb.value; | |
620 | var sst = sscb.options[sscb.selectedIndex].text; | |
621 | ||
622 | var html = '<div id="secteurs_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">' | |
623 | + ' <a href="javascript:removeSecteur(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">' | |
624 | + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />' | |
625 | + ' </a>' | |
626 | + ' <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />' | |
627 | + ' ' + sst | |
628 | + '</div>'; | |
629 | $('#secteurs').append(html); | |
630 | updateSSecteur(); | |
631 | } | |
632 | ||
633 | function removeSecteur(s, ss) | |
634 | { | |
635 | $('#secteurs_' + s + '_' + ss).remove(); | |
636 | updateSSecteur(); | |
637 | } | |
638 | ||
16594a1a FB |
639 | function registerEnterpriseAutocomplete(id) |
640 | { | |
16594a1a FB |
641 | $(".enterprise_name").each( |
642 | function() { | |
16594a1a FB |
643 | if (id == -1 || this.name == "jobs[" + id + "][name]") { |
644 | $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise", | |
645 | { | |
646 | selectOnly:1, | |
647 | field:this.name, | |
648 | matchSubset:0, | |
649 | width:$(this).width() | |
650 | }); | |
651 | } | |
652 | } | |
653 | ); | |
654 | } | |
655 | ||
46ae38a9 | 656 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |