X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=htdocs%2Fjavascript%2Fprofile.js;h=d4899ecd2fbd1e5b404e62fa351436a63bef2f14;hb=e1e112b3e153c4f4a923676e6ea6024f48b5c62f;hp=527f8068af9a47b7fe1b46340c75176b0415fc5a;hpb=d30b83fa903a8a6f7b88df287884ed80cffff277;p=platal.git
diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js
index 527f806..d4899ec 100644
--- a/htdocs/javascript/profile.js
+++ b/htdocs/javascript/profile.js
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -37,11 +37,10 @@ function wizPage_onLoad(id)
updateGroupSubLink();
break;
case 'deco':
- for (var i in names) {
- if ($('#medal_' + i).length != 0) {
- getMedalName(i);
- buildGrade(i, $('#medal_' + i).find('[name*=medal_' + i + '_grade]').val());
- }
+ var i = 0;
+ while ($('#medal_' + i).length != 0) {
+ prepareMedal(i);
+ ++i;
}
break;
case 'emploi':
@@ -57,6 +56,7 @@ var educationDegreeAll;
var educationDegreeName;
var subgrades;
var names;
+var multiples;
// Publicity follows the following ordering: private < ax < public.
var publicity = [];
@@ -211,7 +211,7 @@ function addEdu()
i++;
$('#edu_add').addClass(prefix + i);
i--;
- $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
+ $.xget('profile/ajax/edu/' + i + '/' + class_parity,
function(data) {
$('#edu_add').before(data);
prepareType(i);
@@ -437,10 +437,17 @@ function updateGroupSubLink()
// {{{1 Medals
+function prepareMedal(i)
+{
+ getMedalName($('#medal_' + i).find('[name="medals[' + i + '][id]"]').val());
+ buildGrade(i);
+}
+
function updateMedal()
{
var val = $('#medals').find('[name*=medal_sel]').val();
- if (val && ($('#medal_' + val).length == 0)) {
+
+ if ((multiple[val] && subgrades[val]) || $('.medal_name_' + val).length == 0) {
$('#medal_add').show();
} else {
$('#medal_add').hide();
@@ -449,55 +456,80 @@ function updateMedal()
function getMedalName(id)
{
- $('#medal_name_' + id).html(names[id]);
+ $('.medal_name_' + id).html(names[id]);
}
-function buildGrade(id, current)
+function buildGrade(i)
{
- var grade;
- var subg = subgrades[id];
- var obj = $('#medal_grade_' + id);
+ var id = $('#medal_' + i).find('[name="medals[' + i + '][id]"]').val();
+ var current = $('#medal_' + i).find('[name="medals_' + i + '_grade"]').val();
+ var subg = subgrades[id];
+ var obj = $('#medal_grade_' + i);
if (!subg) {
- obj.prepend('');
+ obj.prepend('');
} else {
- var html = 'Agrafe :