Move profile/edit javascript in .js files and activate PlWizard eye-candies
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 23 Sep 2007 11:13:11 +0000 (13:13 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 23 Sep 2007 11:13:11 +0000 (13:13 +0200)
for this page

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
19 files changed:
htdocs/javascript/profile.js [new file with mode: 0644]
modules/profile.php
modules/profile/decos.inc.php
modules/profile/groups.inc.php
templates/core/plwizard.tpl
templates/profile/adresses.address.tpl
templates/profile/adresses.tel.tpl
templates/profile/adresses.tpl
templates/profile/applis.js.tpl
templates/profile/deco.medal.tpl
templates/profile/deco.tpl
templates/profile/general.tpl
templates/profile/grades.js.tpl [new file with mode: 0644]
templates/profile/groups.tpl
templates/profile/jobs.job.tpl
templates/profile/jobs.tpl
templates/profile/mentor.tpl
templates/profile/skill.skill.tpl
templates/profile/skill.tpl

diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js
new file mode 100644 (file)
index 0000000..bbffc58
--- /dev/null
@@ -0,0 +1,494 @@
+/***************************************************************************
+ *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// Page initialization
+
+function wizPage_onLoad(id)
+{
+    switch (id) {
+      case 'general':
+        fillType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1[id]'].selectedIndex-1);
+        selectType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1_tmp'].value);
+        fillType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2[id]'].selectedIndex-1);
+        selectType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2_tmp'].value);
+        break;
+      case 'poly':
+        updateGroupSubLink(document.forms.prof_annu.groupesx_sub);
+        break;
+      case 'deco':
+        for (var i in names) {
+            if (typeof names[i] != 'function') {
+                if (document.getElementById("medal_" + i) != null) {
+                    getMedalName(i);
+                    buildGrade(i, document.forms.prof_annu["medal_" + i + "_grade"].value);
+                }
+            }
+        }
+        break;
+      case 'emploi':
+        for (var i = 0 ; document.getElementById('job_' + i) != null ; ++i) {
+            updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
+                             document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
+        }
+        break;
+    }
+}
+
+var applisType;
+var applisTypeAll;
+
+// General
+
+var subgrades;
+var names;
+function fillType(selectCtrl, appli, fill)
+{
+    var i;
+    var i0=0;
+
+    for (i = selectCtrl.options.length; i >=0; i--) {
+        selectCtrl.options[i] = null;
+    }
+
+    if (fill || appli <0) {
+        selectCtrl.options[0] = new Option(' ');
+        i0=1;
+    }
+    if (appli>=0)
+        for (i=0; i < applisType[appli].length; i++)
+            selectCtrl.options[i0+i] = new Option(applisType[appli][i]);
+    else if (fill)
+        for (i=0; i < applisTypeAll.length; i++)
+            selectCtrl.options[i0+i] = new Option(applisTypeAll[i]);
+}
+
+
+function selectType(selectCtrl, type)
+{
+    for (i = 0; i < selectCtrl.options.length; i++) {
+        if (selectCtrl.options[i].text == type)
+            selectCtrl.selectedIndex=i;
+    }
+}
+
+
+
+// Addresses
+
+function removeObject(id, pref)
+{
+    document.getElementById(id).style.display = "none";
+    document.forms.prof_annu[pref + "[removed]"].value = "1";
+}
+
+function restoreObject(id, pref)
+{
+    document.getElementById(id).style.display = '';
+    document.forms.prof_annu[pref + "[removed]"].value = "0";
+}
+
+function getAddressElement(adrid, adelement)
+{
+    return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
+}
+
+function checkCurrentAddress(newCurrent)
+{
+    var hasCurrent = false;
+    var i = 0;
+    while (getAddressElement(i, 'pub') != null) {
+        var radio = getAddressElement(i, 'current');
+        var removed = getAddressElement(i, 'removed');
+        if (removed.value == "1" && radio.checked) {
+            radio.checked = false;
+        } else if (radio.checked && radio != newCurrent) {
+            radio.checked = false;
+        } else if (radio.checked) {
+            hasCurrent = true;
+        }
+        i++;
+    }
+    if (!hasCurrent) {
+        i = 0;
+        while (getAddressElement(i, 'pub') != null) {
+            var radio = getAddressElement(i, 'current');
+            var removed = getAddressElement(i, 'removed');
+            if (removed.value != "1") {
+                radio.checked= true;
+                return;
+            }
+            i++;
+        }
+    }
+}
+
+function removeAddress(id, pref)
+{
+    removeObject(id, pref);
+    checkCurrentAddress(null);
+    if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
+        document.getElementById(id + '_grayed').style.display = '';
+    }
+}
+
+function restoreAddress(id, pref)
+{
+    document.getElementById(id +  '_grayed').style.display = 'none';
+    checkCurrentAddress(null);
+    restoreObject(id, pref);
+}
+
+function addAddress()
+{
+    var i = 0;
+    while (getAddressElement(i, 'pub') != null) {
+        i++;
+    }
+    $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>');
+    Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
+}
+
+function addTel(id)
+{
+    var i = 0;
+    var adid = 'addresses_' + id;
+    var tel  = adid + '_tel_';
+    while (document.getElementById(tel + i) != null) {
+        i++;
+    }
+    $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>');
+    Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
+}
+
+
+// Geoloc
+
+function validGeoloc(id, pref)
+{
+    document.getElementById(id + '_geoloc').style.display = 'none';
+    document.getElementById(id + '_geoloc_error').style.display = 'none';
+    document.getElementById(id + '_geoloc_valid').style.display = 'none';
+    document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
+    document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
+    attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+                function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+    document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
+function validAddress(id, pref)
+{
+    document.getElementById(id + '_geoloc').style.display = 'none';
+    document.getElementById(id + '_geoloc_error').style.display = 'none';
+    document.getElementById(id + '_geoloc_valid').style.display = 'none';
+    document.forms.prof_annu[pref + "[parsevalid]"].value = "0";
+    attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+                function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+    document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
+
+// Groups
+
+function updateGroup(type)
+{
+    var val = document.forms.prof_annu[type + '_sel'].value;
+    if (val == '0' || document.getElementById(type + '_' + val) != null) {
+        document.getElementById(type + '_add').style.display = 'none';
+    } else {
+        document.getElementById(type + '_add').style.display = '';
+    }
+}
+
+function removeGroup(cat, id)
+{
+    $('#' + cat + '_' + id).remove();
+    updateGroup(cat);
+}
+
+function addGroup(cat)
+{
+    var cb   = document.forms.prof_annu[cat + '_sel'];
+    var id   = cb.value;
+    var text = cb.options[cb.selectedIndex].text;
+    var html = '<tr id="' + cat + '_' + id + '">'
+        + '  <td>'
+        + '    <input type="hidden" name="' + cat + '[' + id + ']" value="' + text + '" />'
+        + '  </td>'
+        + '  <td>'
+        + '    <div style="float: left; width: 70%">'
+        +        text
+        + '    </div>'
+        + '    <a href="javascript:removeGroup(\'' + cat + '\', ' + id + ')">'
+        + '      <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
+        + '    </a>'
+        + '  </td>'
+        + '</tr>';
+    $('#' + cat).after(html);
+    updateGroup(cat);
+}
+
+function updateGroupSubLink(cb)
+{
+    var href = cb.value ? cb.value : "http://www.polytechnique.net";
+    document.getElementById("groupesx_sub").href = href;
+}
+
+
+// Medals
+
+function updateMedal()
+{
+    var val = document.forms.prof_annu['medal_sel'].value;
+    if (val == '' || document.getElementById('medal_' + val) != null) {
+        document.getElementById('medal_add').style.display = 'none';
+    } else {
+        document.getElementById('medal_add').style.display = '';
+    }
+}
+
+function getMedalName(id)
+{
+    document.getElementById('medal_name_' + id).innerHTML = names[id];
+}
+
+function buildGrade(id, current)
+{
+    var grade;
+    var subg = subgrades[id];
+    var obj  = $('#medal_grade_' + id);
+    if (!subg) {
+        obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />');
+    } else {
+        var html = 'Agrafe : <select name="medals[' + id + '][grade]">';
+        html += '<option value="0">Non précisée</option>';
+        for (grade = 0 ; grade < subg.length ; grade++) {
+            html += '<option value="' + subg[grade][0] + '"';
+            if (subg[grade][0] == current) {
+                html += ' selected="selected"';
+            }
+            html += '>' + subg[grade][1] + '</option>';
+        }
+
+        html += '</select>';
+        obj.prepend(html);
+    }
+}
+
+function makeAddProcess(id)
+{
+    return function(data)
+    {
+        $('#medals').after(data);
+        updateMedal();
+        getMedalName(id);
+        buildGrade(id, 0);
+    };
+}
+
+function addMedal()
+{
+    var id = document.forms.prof_annu['medal_sel'].value;
+    $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
+}
+
+function removeMedal(id)
+{
+    $("#medal_" + id).remove();
+    updateMedal();
+}
+
+
+// Jobs
+
+function removeJob(id, pref)
+{
+    document.getElementById(id + '_cont').style.display = 'none';
+    if (document.forms.prof_annu[pref + '[new]'].value == '0') {
+        document.getElementById(id + '_grayed').style.display = '';
+        document.getElementById(id + '_grayed_name').innerHTML =
+            document.forms.prof_annu[pref + "[name]"].value.replace('<', '&lt;');
+    }
+    document.forms.prof_annu[pref + "[removed]"].value = "1";
+}
+
+function restoreJob(id, pref)
+{
+    document.getElementById(id + '_cont').style.display = '';
+    document.getElementById(id + '_grayed').style.display = 'none';
+    document.forms.prof_annu[pref + "[removed]"].value = "0";
+}
+
+function updateJobSecteur(nb, id, pref, sel)
+{
+    var secteur = document.forms.prof_annu[pref + '[secteur]'].value;
+    if (secteur == '') {
+        secteur = '-1';
+    }
+    Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel);
+}
+
+function makeAddJob(id)
+{
+    return function(data)
+    {
+        $('#add_job').before(data);
+        updateSecteur('job_' + id, 'jobs[' + id + ']', '');
+    };
+}
+
+function addJob()
+{
+    var i = 0;
+    while (document.getElementById('job_' + i) != null) {
+        ++i;
+    }
+    $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
+}
+
+
+// Skills
+
+function updateSkill(cat)
+{
+    var val  = document.forms.prof_annu[cat + '_sel'].value;
+    var show = true;
+    if (val == '') {
+        show = false;
+    }
+    if (document.getElementById(cat + '_' + val) != null) {
+        show = false;
+    }
+    document.getElementById(cat + '_add').style.display = show ? '' : 'none';
+}
+
+function addSkill(cat)
+{
+    var sel  = document.forms.prof_annu[cat + '_sel'];
+    var val  = sel.value;
+    var text = sel.options[sel.selectedIndex].text;
+    $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
+          function(data) {
+          $('#' + cat).append(data);
+          document.getElementById(cat + '_' + val + '_title').innerHTML = text;
+          updateSkill(cat);
+          });
+}
+
+function removeSkill(cat, id)
+{
+    $('#' + cat + '_' + id).remove();
+    updateSkill(cat);
+}
+
+
+// Mentor
+
+function updateCountry()
+{
+    var val = document.forms.prof_annu.countries_sel.value;
+    var show = true;
+    if (val == '') {
+        show = false;
+    }
+    if (document.getElementById('countries_' + val) != null) {
+        show = false;
+    }
+    document.getElementById('countries_add').style.display = show ? '' : 'none';
+}
+
+function addCountry()
+{
+    var cb   = document.forms.prof_annu.countries_sel;
+    var val  = cb.value;
+    var text = cb.options[cb.selectedIndex].text;
+    var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
+        + '  <div style="float: left; width: 50%">' + text + '</div>'
+        + '  <input type="hidden" name="countries[' + val + ']" value="' + text + '" />'
+        + '  <a href="javascript:removeCountry(\'' + val + '\')">'
+        + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
+        + '  </a>'
+        + '</div>';
+    $('#countries').append(html);
+    updateCountry();
+}
+
+function removeCountry(id)
+{
+    $('#countries_' + id).remove();
+    updateCountry();
+}
+function updateSSecteur()
+{
+    var s  = document.forms.prof_annu.secteur_sel.value;
+    var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value;
+    var show = true;
+    if (s == '' || ss == '') {
+        show = false;
+    }
+    if (document.getElementById('secteurs_' + s + '_' + ss) != null) {
+        show = false;
+    }
+    document.getElementById('secteurs_add').style.display = show ? 'block' : 'none';
+}
+
+function updateSecteur()
+{
+    var secteur = document.forms.prof_annu.secteur_sel.value;
+    if (secteur == '') {
+        secteur = '-1';
+    }
+    $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur,
+          function(data) {
+          data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
+          +  '  <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
+          +  '</a>' + data;
+          document.getElementById('ss_secteur_sel').innerHTML = data;
+          attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur);
+          });
+}
+
+function addSecteur()
+{
+    var scb = document.forms.prof_annu.secteur_sel;
+    var s  = scb.value;
+    var st = scb.options[scb.selectedIndex].text;
+
+    var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]'];
+    var ss = sscb.value;
+    var sst = sscb.options[sscb.selectedIndex].text;
+
+    var html = '<div id="secteurs_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">'
+        + '  <a href="javascript:removeSecteur(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">'
+        + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
+        + '  </a>'
+        + '  <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />'
+        + '  ' + sst
+        + '</div>';
+    $('#secteurs').append(html);
+    updateSSecteur();
+}
+
+function removeSecteur(s, ss)
+{
+    $('#secteurs_' + s + '_' + ss).remove();
+    updateSSecteur();
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index 00969c2..0559e6c 100644 (file)
@@ -38,6 +38,8 @@ class ProfileModule extends PLModule
             'profile/ajax/job'     => $this->make_hook('ajax_job',     AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH),
             'profile/ajax/skill'   => $this->make_hook('ajax_skill',   AUTH_COOKIE, 'user', NO_AUTH),
+            'javascript/applis.js' => $this->make_hook('applis_js', AUTH_COOKIE),
+            'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE),
             'profile/medal'    => $this->make_hook('medal', AUTH_PUBLIC),
             'profile/orange'   => $this->make_hook('p_orange',   AUTH_MDP),
             'profile/usage'    => $this->make_hook('p_usage',    AUTH_MDP),
@@ -272,7 +274,7 @@ class ProfileModule extends PLModule
         http_redirect("http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&anc_id=$mat");
     }
 
-    function handler_p_edit(&$page, $opened_tab = null)
+    function handler_p_edit(&$page, $opened_tab = null, $mode = null)
     {
         global $globals;
 
@@ -328,8 +330,10 @@ class ProfileModule extends PLModule
         // TODO: Block if birth date is missing ?
 
         $page->addJsLink('ajax.js');
-        $page->addJsLink('jquery.js');
-        $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, false);
+        $page->addJsLink('profile.js');
+        $page->addJsLink('applis.js');
+        $page->addJsLink('grades.js');
+        $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
         require_once dirname(__FILE__) . '/profile/page.inc.php';
         $wiz->addPage('ProfileGeneral', 'Général', 'general');
         $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
@@ -338,44 +342,82 @@ class ProfileModule extends PLModule
         $wiz->addPage('ProfileJobs', 'Informations professionnelles', 'emploi');
         $wiz->addPage('ProfileSkills', 'Compétences diverses', 'skill');
         $wiz->addPage('ProfileMentor', 'Mentoring', 'mentor');
-        $wiz->apply($page, 'profile/edit', $opened_tab);
+        $wiz->apply($page, 'profile/edit', $opened_tab, $mode);
 
         $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
     }
 
+    function handler_applis_js(&$page)
+    {
+        header('Content-Type: text/javascript; charset=utf-8');
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+        header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
+        header('Cache-Control: no-cache, must-revalidate');
+        header('Pragma: no-cache');
+        $page->changeTpl('profile/applis.js.tpl', NO_SKIN);
+        require_once "applis.func.inc.php";
+    }
+
+    function handler_grades_js(&$page)
+    {
+        header('Content-Type: text/javascript; charset=utf-8');
+        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+        header('Last-Modified:' . gmdate('D, d M Y H:i:s') . ' GMT');
+        header('Cache-Control: no-cache, must-revalidate');
+        header('Pragma: no-cache');
+        $page->changeTpl('profile/grades.js.tpl', NO_SKIN);
+        $res    = XDB::iterator("SELECT  *
+                                   FROM  profile_medals_grades
+                               ORDER BY  mid, pos");
+        $grades = array();
+        while ($tmp = $res->next()) {
+            $grades[$tmp['mid']][] = $tmp;
+        }
+        $page->assign('grades', $grades);
+
+        $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
+                                   FROM  profile_medals
+                               ORDER BY  type, text");
+        $mlist  = array();
+        while ($tmp = $res->next()) {
+            $mlist[$tmp['type']][] = $tmp;
+        }
+        $page->assign('medal_list', $mlist);
+    }
+
     function handler_ajax_address(&$page, $adid)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('profile/adresses.address.tpl', NO_SKIN);
         $page->assign('i', $adid);
         $page->assign('adr', array());
-        $page->assign('ajaxadr', true);
     }
 
     function handler_ajax_tel(&$page, $adid, $telid)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('profile/adresses.tel.tpl', NO_SKIN);
         $page->assign('i', $adid);
         $page->assign('adid', "addresses_$adid");
         $page->assign('adpref', "addresses[$adid]");
         $page->assign('t', $telid);
         $page->assign('tel', array());
-        $page->assign('ajaxtel', true);
     }
 
     function handler_ajax_medal(&$page, $id)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('profile/deco.medal.tpl', NO_SKIN);
         $page->assign('id', $id);
         $page->assign('medal', array('valid' => 0, 'grade' => 0));
-        $page->assign('ajaxdeco', true);
     }
 
     function handler_ajax_job(&$page, $id)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('profile/jobs.job.tpl', NO_SKIN);
         $page->assign('i', $id);
         $page->assign('job', array());
-        $page->assign('ajaxjob', true);
         $page->assign('new', true);
         $page->assign('secteurs', XDB::iterator("SELECT  id, label
                                                    FROM  emploi_secteur"));
@@ -386,6 +428,7 @@ class ProfileModule extends PLModule
 
     function handler_ajax_secteur(&$page, $id, $sect, $ssect = -1)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $res = XDB::iterator("SELECT  id, label
                                 FROM  emploi_ss_secteur
                                WHERE  secteur = {?}", $sect);
@@ -397,8 +440,8 @@ class ProfileModule extends PLModule
 
     function handler_ajax_skill(&$page, $cat, $id)
     {
+        header('Content-Type: text/html; charset=utf-8');
         $page->changeTpl('profile/skill.skill.tpl', NO_SKIN);
-        $page->assign('ajaxskill', true);
         $page->assign('cat', $cat);
         $page->assign('id', $id);
         if ($cat == 'competences') {
index 9aaea5e..1018e9b 100644 (file)
@@ -33,7 +33,7 @@ class ProfileDeco implements ProfileSetting
                                 S::i('uid'));
             $value = array();
             while (list($id, $grade) = $res->next()) {
-                $value[$id] = array('grade' => $grade, 
+                $value[$id] = array('grade' => $grade,
                                     'valid' => '1');
             }
 
@@ -118,15 +118,6 @@ class ProfileDecos extends ProfilePage
     public function prepare(PlatalPage &$page, $id)
     {
         parent::prepare($page, $id);
-        $res    = XDB::iterator("SELECT  *
-                                   FROM  profile_medals_grades
-                               ORDER BY  mid, pos");
-        $grades = array();
-        while ($tmp = $res->next()) {
-            $grades[$tmp['mid']][] = $tmp;
-        }
-        $page->assign('grades', $grades);
-
         $res    = XDB::iterator("SELECT  *, FIND_IN_SET('validation', flags) AS validate
                                    FROM  profile_medals
                                ORDER BY  type, text");
@@ -135,7 +126,6 @@ class ProfileDecos extends ProfilePage
             $mlist[$tmp['type']][] = $tmp;
         }
         $page->assign('medal_list', $mlist);
-
         $trad = Array('ordre'      => 'Ordres',
                       'croix'      => 'Croix',
                       'militaire'  => 'Médailles militaires',
index f274eb6..9a14ad8 100644 (file)
@@ -120,6 +120,7 @@ class ProfileGroups extends ProfilePage
                                                     WHERE  a.inscriptible != 0
                                                            AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')
                                                  ORDER BY  a.cat, a.dom, a.nom"));
+        $page->assign('old', (int)date('Y') >= S::i('promo_sortie'));
     }
 }
 
index 095765d..a1ea50e 100644 (file)
@@ -38,6 +38,9 @@
                               $(".wiz_tab").removeClass("active");
                               $("#wiz_tab_" + id).addClass("active");
                               $(".wiz_content").html(data).fadeIn('normal');
+                              if (typeof wizPage_onLoad == 'function') {
+                                wizPage_onLoad(id);
+                              }
                             });
                       }
           });
   }
   {/literal}
   {/if}
+  {literal}
+  $(document).ready(
+    function() {
+      if (typeof wizPage_onLoad == 'function') {
+        wizPage_onLoad({/literal}'{$lookup[$current]}'{literal});
+      }
+    });
+  {/literal}
 //]]></script>
 
 <div class="wizard" style="clear: both">
index 1ae3caa..857a3ef 100644 (file)
@@ -20,9 +20,6 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if $ajaxadr}
-<?xml version="1.0" encoding="utf-8"?>
-{/if}
 {assign var=adpref value="addresses[$i]"}
 {assign var=adid value="addresses_$i"}
 <input type="hidden" name="{$adpref}[removed]" value="0"/>
index a641895..952b01f 100644 (file)
@@ -20,9 +20,6 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if $ajaxtel}
-<?xml version="1.0" encoding="utf-8"?>
-{/if}
 {assign var=telpref value="`$adpref`[tel][`$t`]"}
 {assign var=telid value="`$adid`_tel_`$t`"}
 <div style="float: right" class="flags">
index 9d6f176..250922c 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<script type="text/javascript">//<![CDATA[
-{literal}
-function removeObject(id, pref)
-{
-  document.getElementById(id).style.display = "none";
-  document.forms.prof_annu[pref + "[removed]"].value = "1";
-}
-
-function restoreObject(id, pref)
-{
-  document.getElementById(id).style.display = '';
-  document.forms.prof_annu[pref + "[removed]"].value = "0";
-}
-
-function getAddressElement(adrid, adelement)
-{
-  return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"];
-}
-
-function checkCurrentAddress(newCurrent)
-{
-  var hasCurrent = false;
-  var i = 0;
-  while (getAddressElement(i, 'pub') != null) {
-    var radio = getAddressElement(i, 'current');
-    var removed = getAddressElement(i, 'removed');
-    if (removed.value == "1" && radio.checked) {
-      radio.checked = false;
-    } else if (radio.checked && radio != newCurrent) {
-      radio.checked = false;
-    } else if (radio.checked) {
-      hasCurrent = true;
-    }
-    i++;
-  }
-  if (!hasCurrent) {
-    i = 0;
-    while (getAddressElement(i, 'pub') != null) {
-      var radio = getAddressElement(i, 'current');
-      var removed = getAddressElement(i, 'removed');
-      if (removed.value != "1") {
-        radio.checked= true;
-        return;
-      }
-      i++;
-    }
-  }
-}
-
-function removeAddress(id, pref)
-{
-  removeObject(id, pref);
-  checkCurrentAddress(null);
-  if (document.forms.prof_annu[pref + '[datemaj]'].value != '') {
-    document.getElementById(id + '_grayed').style.display = '';
-  }
-}
-
-function restoreAddress(id, pref)
-{
-  document.getElementById(id +  '_grayed').style.display = 'none';
-  checkCurrentAddress(null);
-  restoreObject(id, pref);
-}
-
-function addAddress()
-{
-  var i = 0;
-  while (getAddressElement(i, 'pub') != null) {
-    i++;
-  }
-  $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>');
-  Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
-}
-
-function addTel(id)
-{
-  var i = 0;
-  var adid = 'addresses_' + id;
-  var tel  = adid + '_tel_';
-  while (document.getElementById(tel + i) != null) {
-    i++;
-  }
-  $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>');
-  Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
-}
-
-function validGeoloc(id, pref)
-{
-  document.getElementById(id + '_geoloc').style.display = 'none';
-  document.getElementById(id + '_geoloc_error').style.display = 'none';
-  document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
-  document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
-  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
-              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
-  document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-function validAddress(id, pref)
-{
-  document.getElementById(id + '_geoloc').style.display = 'none';
-  document.getElementById(id + '_geoloc_error').style.display = 'none';
-  document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"].value = "0";
-  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
-              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
-  document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-{/literal}
-//]]></script>
-
 {foreach key=i item=adr from=$addresses}
 <div id="{"addresses_`$i`_cont"}">
 {include file="profile/adresses.address.tpl" i=$i adr=$adr}
index 3134ee0..a0237b5 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<script type="text/javascript">
-//<![CDATA[
-    applisType = new Array(
-{applis_type}
-);
+applisType = new Array({applis_type});
+applisTypeAll = new Array({applis_type_all});
 
-applisTypeAll = new Array(
-{applis_type_all}
-);
-{literal}
-function fillType( selectCtrl, appli, fill ) {
-var i;
-var i0=0;
-
-for (i = selectCtrl.options.length; i >=0; i--) {
-selectCtrl.options[i] = null;
-}
-
-if (fill || appli <0) {
-  selectCtrl.options[0] = new Option(' ');
-  i0=1;
-}
-if (appli>=0) 
-  for (i=0; i < applisType[appli].length; i++) 
-    selectCtrl.options[i0+i] = new Option(applisType[appli][i]);
-else if (fill)
-  for (i=0; i < applisTypeAll.length; i++) 
-    selectCtrl.options[i0+i] = new Option(applisTypeAll[i]);
-}
-
-function selectType( selectCtrl, type ) {
-  for (i = 0; i < selectCtrl.options.length; i++) {
-    if (selectCtrl.options[i].text == type)
-      selectCtrl.selectedIndex=i;
-  }
-}
-{/literal}
-//]]>
-</script>
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 280d256..e6eb14e 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-{if $ajaxdeco}
-<?xml version="1.0" encoding="utf-8"?>
-{/if}
 <div id="medal_{$id}" style="clear: both; margin-top: 1em; height: 50px; vertical-align: middle">
   <div style="float: left; margin-right: 0.3em">
     <img src="profile/medal/{$id}" height="50" />
   </div>
   <div style="float: left; width: 70%">
     <div><b id="medal_name_{$id}"></b>
-    {if !$medal.valid}(en attente de {if $ajaxdeco}validation{else}modération{/if}){/if}</div>
+    {if !$medal.valid}(en attente de modération){/if}</div>
     <div id="medal_grade_{$id}"><input type="hidden" name="medals[{$id}][valid]" value="{$medal.valid}" /></div>
   </div>
-  <a href="javascript:remove({$id})" style="vertical-align: middle">{icon name="cross" title="Supprimer cette médaille"}</a>
-  {if !$ajaxdeco}
-  <script type="text/javascript">
-  getMedalName({$id});
-  buildGrade({$id}, {$medal.grade});
-  </script>
-  {/if}
+  <a href="javascript:removeMedal({$id})" style="vertical-align: middle">
+    {icon name="cross" title="Supprimer cette médaille"}
+  </a>
+  <input type="hidden" name="medal_{$id}_grade" value="{$medal.grade}" />
 </div>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index e28ee82..b59614f 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-<script type="text/javascript">//<![CDATA[
-{literal}
-var subgrades = new array();
-var names     = new array();
-
-function update()
-{
-  var val = document.forms.prof_annu['medal_sel'].value;
-  if (val == '' || document.getElementById('medal_' + val) != null) {
-    document.getElementById('medal_add').style.display = 'none';
-  } else {
-    document.getElementById('medal_add').style.display = '';
-  }
-}
-
-function getMedalName(id)
-{
-  document.getElementById('medal_name_' + id).innerHTML = names[id];
-}
-
-function buildGrade(id, current)
-{
-  var grade;
-  var subg = subgrades[id];
-  var obj  = $('#medal_grade_' + id);
-  if (!subg) {
-    obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />');
-  } else {
-    var html = 'Agrafe : <select name="medals[' + id + '][grade]">';
-    html += '<option value="0">Non précisée</option>';
-    for (grade = 0 ; grade < subg.length ; grade++) {
-      html += '<option value="' + subg[grade][0] + '"';
-      if (subg[grade][0] == current) {
-        html += ' selected="selected"';
-      }
-      html += '>' + subg[grade][1] + '</option>';
-    }
-
-    html += '</select>';
-    obj.prepend(html);
-  }
-}
-
-function makeAddProcess(id)
-{
-  return function(data)
-         {
-           $('#medals').after(data);
-           update();
-           getMedalName(id);
-           buildGrade(id, 0);
-         };
-}
-
-function add()
-{
-  var id = document.forms.prof_annu['medal_sel'].value;
-  $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
-}
-
-function remove(id)
-{
-  $("#medal_" + id).remove();
-  update();
-}
-
-{/literal}
-{foreach from=$medal_list key=type item=list}
-  {foreach from=$list item=m}
-  names[{$m.id}] = "{$m.text}";
-  {if $grades[$m.id]|@count}
-    names[{$m.id}] = "{$m.text}";
-    subgrades[{$m.id}] = new array({$grades[$m.id]|@count});
-    {foreach from=$grades[$m.id] item=g}
-      subgrades[{$m.id}][{$g.gid-1}] = [{$g.gid},"{$g.text}"];
-    {/foreach}
-  {/if}{/foreach}
-{/foreach}
-//]]></script>
-
 <table class="bicol">
   <tr>
     <th>
@@ -118,7 +37,7 @@ function remove(id)
         </div>
       </div>
       <div style="clear: both; margin-top: 0.2em" id="medals">
-        <select name="medal_sel" onchange="update()">
+        <select name="medal_sel" onchange="updateMedal()">
           <option value=''></option>
           {foreach from=$medal_list key=type item=list}
           <optgroup label="{$trad[$type]}...">
@@ -128,8 +47,8 @@ function remove(id)
           </optgroup>
           {/foreach}
         </select>
-        <span id="medal_add">
-          <a href="javascript:add();">{icon name=add title="Ajouter cette médaille"}</a>
+        <span id="medal_add" style="display: none">
+          <a href="javascript:addMedal();">{icon name=add title="Ajouter cette médaille"}</a>
         </span>
       </div>
       {foreach from=$medals item=medal key=id}
@@ -139,8 +58,4 @@ function remove(id)
   </tr>
 </table>
 
-<script type="text/javascript">
-update();
-</script>
-
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 8d7c569..e5b5a5d 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-{include file="profile/applis.js.tpl"}
-  <table class="bicol" style="margin-bottom: 1em"
-    summary="Profil : Informations générales">
-    <tr>
-      <th colspan="2">
-        Informations générales
-      </th>
-    </tr>
-    <tr>
-      <td colspan="2" class="flags">
-        <span class="vert">
-          <input type="checkbox" disabled="disabled" checked="checked" />
-        </span>
-        <span class="texte">
-          site public
-        </span>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Nom</span>
-        <span class="comm"></span>
-      </td>
-      <td class="cold">
-        <input type='text' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Prénom</span>
-        <span class="comm"></span>
-      </td>
-      <td class="cold">
-        <input type='text' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Promotion</span>
-      </td>
-      <td class="cold">
-        <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
-        <span class="lien"><a href="profile/orange">modifier</a>{if ($promo_sortie -3 == $promo)} pour les oranges{/if}</span>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Nom d'usage</span><br />
-        {if $smarty.session.sexe}
-        <span class="comm">(Notamment nom d'épouse)</span>
-        {else}
-        <span class="comm">(si différent de {$nom} seulement)</span>
-        {/if}
-      </td>
-      <td class="cold">
-        <span class="nom">{$nom_usage|default:"Aucun"}</span>
-        <span class="lien"><a href="profile/usage">modifier</a></span>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Nationalité</span>
-      </td>
-      <td class="cold">
-        <select name="nationalite">
-          {select_nat valeur=$nationalite}
-        </select>
-      </td>
-    </tr>
-    <tr class="pair">
-      <td class="colg">
-        <span class="titre">Application</span><br />
-        <span class="comm">(4ème année de l'X)</span>
-      </td>
-      <td class="cold">
-        <select name="appli1[id]" onchange="fillType(this.form['appli1[type]'], this.selectedIndex-1);">
-          {applis_options selected=$appli1.id}
-        </select>
-        <br />
-        <select name="appli1[type]">
-          <option value=""></option>
-        </select>
-        <script type="text/javascript">
-          <!--
-          fillType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1[id]'].selectedIndex-1);
-          selectType(document.forms.prof_annu['appli1[type]'], '{$appli1.type}');
-          //-->
-        </script>
-      </td>
-    </tr>
-    <tr class="pair">
-      <td class="dcolg">
-        <span class="titre">Post-application</span>
-      </td>
-      <td class="dcold">
-        <select name="appli2[id]" onchange="fillType(this.form['appli2[type]'], this.selectedIndex-1);">
-          {applis_options selected=$appli2.id}
-        </select>
-        <br />
-        <select name="appli2[type]">
-          <option value=""></option>
-        </select>
-        <script type="text/javascript">
-          <!--
-          fillType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2[id]'].selectedIndex-1);
-          selectType(document.forms.prof_annu['appli2[type]'], '{$appli2.type}');
-          //-->
-        </script>
-      </td>
-    </tr>
-  </table>
+<table class="bicol" style="margin-bottom: 1em"
+  summary="Profil : Informations générales">
+  <tr>
+    <th colspan="2">
+      Informations générales
+    </th>
+  </tr>
+  <tr>
+    <td colspan="2" class="flags">
+      <span class="vert">
+        <input type="checkbox" disabled="disabled" checked="checked" />
+      </span>
+      <span class="texte">
+        site public
+      </span>
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Nom</span>
+      <span class="comm"></span>
+    </td>
+    <td class="cold">
+      <input type='text' name='nom' {if $errors.nom}class="error"{/if} value="{$nom}" />
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Prénom</span>
+      <span class="comm"></span>
+    </td>
+    <td class="cold">
+      <input type='text' name='prenom' {if $errors.prenom}class="error"{/if} value="{$prenom}" />
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Promotion</span>
+    </td>
+    <td class="cold">
+      <span class="nom">X{$promo}{if ($promo != $promo_sortie - 3)} - X{math equation="a - b" a=$promo_sortie b=3}{/if}</span>
+      <span class="lien"><a href="profile/orange">modifier</a>{if ($promo_sortie -3 == $promo)} pour les oranges{/if}</span>
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Nom d'usage</span><br />
+      {if $smarty.session.sexe}
+      <span class="comm">(Notamment nom d'épouse)</span>
+      {else}
+      <span class="comm">(si différent de {$nom} seulement)</span>
+      {/if}
+    </td>
+    <td class="cold">
+      <span class="nom">{$nom_usage|default:"Aucun"}</span>
+      <span class="lien"><a href="profile/usage">modifier</a></span>
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Nationalité</span>
+    </td>
+    <td class="cold">
+      <select name="nationalite">
+        {select_nat valeur=$nationalite}
+      </select>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td class="colg">
+      <span class="titre">Application</span><br />
+      <span class="comm">(4ème année de l'X)</span>
+    </td>
+    <td class="cold">
+      <select name="appli1[id]" onchange="fillType(this.form['appli1[type]'], this.selectedIndex-1);">
+        {applis_options selected=$appli1.id}
+      </select>
+      <br />
+      <input type="hidden" name="appli1_tmp" value="{$appli1.type}" />
+      <select name="appli1[type]">
+        <option value=""></option>
+      </select>
+    </td>
+  </tr>
+  <tr class="pair">
+    <td class="dcolg">
+      <span class="titre">Post-application</span>
+    </td>
+    <td class="dcold">
+      <select name="appli2[id]" onchange="fillType(this.form['appli2[type]'], this.selectedIndex-1);">
+        {applis_options selected=$appli2.id}
+      </select>
+      <br />
+      <input type="hidden" name="appli2_tmp" value="{$appli2.type}" />
+      <select name="appli2[type]">
+        <option value=""></option>
+      </select>
+    </td>
+  </tr>
+</table>
 
 {if !$no_private_key}
-  <table class="bicol"  style="margin-bottom: 1em"
-    summary="Profil : Informations générales">
-    <tr>
-      <th>
-        Synchronisation avec l'AX
-      </th>
-    </tr>
-    <tr>
-      <td>
-        <p>
-          Le service annuaire de l'<a href='http://www.polytechniciens.com'>AX</a> met à jour l'annuaire papier à partir des informations que tu lui fournis. Tu peux choisir ici d'envoyer directement les données de ta fiche Polytechnique.org vers ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$matricule_ax}">fiche AX</a>.
-        </p>
-        <p>
-          L'opération de synchronisation prend en compte toutes les informations que tu as marquées comme transmises à l'AX (en orange ou en vert). Elle peut alors effacer, modifier ou rajouter des informations sur ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$matricule_ax}">fiche AX</a> selon ce qui s'y trouve déjà.
-        </p>
-        <p class="center">
-          <a href="profile/edit/general?synchro_ax=confirm" onclick="return confirm('Es-tu sûr de vouloir lancer la synchronisation ?')"><input type="button" value="Synchroniser"/></a>
-        </p>
-      </td>
-    </tr>
-    <tr>
-      <td class="col">
-        <table class="flags" cellspacing="0" summary="Flags">
-          <tr>
-            <td class="orange">
-              <input type="checkbox" name="synchro_ax" {if $synchro_ax}checked="checked" {/if}/>
-            </td>
-            <td class="texte">
-              Autoriser la synchronisation vers l'AX par des administrateurs ou des scripts automatiques.
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-  </table>
+<table class="bicol"  style="margin-bottom: 1em"
+  summary="Profil : Informations générales">
+  <tr>
+    <th>
+      Synchronisation avec l'AX
+    </th>
+  </tr>
+  <tr>
+    <td>
+      <p>
+        Le service annuaire de l'<a href='http://www.polytechniciens.com'>AX</a> met à jour l'annuaire papier à partir des informations que tu lui fournis. Tu peux choisir ici d'envoyer directement les données de ta fiche Polytechnique.org vers ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$matricule_ax}">fiche AX</a>.
+      </p>
+      <p>
+        L'opération de synchronisation prend en compte toutes les informations que tu as marquées comme transmises à l'AX (en orange ou en vert). Elle peut alors effacer, modifier ou rajouter des informations sur ta <a href="http://www.polytechniciens.com/?page=AX_FICHE_ANCIEN&amp;anc_id={$matricule_ax}">fiche AX</a> selon ce qui s'y trouve déjà.
+      </p>
+      <p class="center">
+        <a href="profile/edit/general?synchro_ax=confirm" onclick="return confirm('Es-tu sûr de vouloir lancer la synchronisation ?')"><input type="button" value="Synchroniser"/></a>
+      </p>
+    </td>
+  </tr>
+  <tr>
+    <td class="col">
+      <table class="flags" cellspacing="0" summary="Flags">
+        <tr>
+          <td class="orange">
+            <input type="checkbox" name="synchro_ax" {if $synchro_ax}checked="checked" {/if}/>
+          </td>
+          <td class="texte">
+            Autoriser la synchronisation vers l'AX par des administrateurs ou des scripts automatiques.
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+</table>
 {/if}
 
-  <table class="bicol"  style="margin-bottom: 1em"
-    summary="Profil: Trombinoscope">
-    <tr>
-      <th colspan="2">
-        Trombinoscope
-      </th>
-    </tr>
-    <tr>
-      <td class="flags" colspan="2">
-        <span class="vert"><input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/></span>
-        <span class="texte">site public</span>
-      </td>
-    </tr>
-    <tr>
-      <td {if !$nouvellephoto}colspan="2"{/if} class="center" style="width: 49%">
-        <div class="titre">Ta photo actuelle</div>
-        <img src="photo/{$smarty.session.forlife}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
-      </td>
-      {if $nouvellephoto}
-      <td class="center" style="width: 49%">
-        <div class="titre">Photo en attente de validation</div>
-        <div>
-          <a href="profile/{$smarty.session.forlife}?modif=new" class="popup2">
-            Ta fiche avec cette photo
-          </a>
-        </div>
-        <img src="photo/{$smarty.session.forlife}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
-      </td>
-      {/if}
-    </tr>
-    <tr class="pair">
-      <td colspan="2">
-        Pour profiter de cette fonction intéressante, tu dois disposer
-        quelque part (sur ton ordinateur ou sur Internet) d'une photo
-        d'identité (dans un fichier au format JPEG, PNG ou GIF).<br />
+<table class="bicol"  style="margin-bottom: 1em"
+  summary="Profil: Trombinoscope">
+  <tr>
+    <th colspan="2">
+      Trombinoscope
+    </th>
+  </tr>
+  <tr>
+    <td class="flags" colspan="2">
+      <span class="vert"><input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/></span>
+      <span class="texte">site public</span>
+    </td>
+  </tr>
+  <tr>
+    <td {if !$nouvellephoto}colspan="2"{/if} class="center" style="width: 49%">
+      <div class="titre">Ta photo actuelle</div>
+      <img src="photo/{$smarty.session.forlife}" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+    </td>
+    {if $nouvellephoto}
+    <td class="center" style="width: 49%">
+      <div class="titre">Photo en attente de validation</div>
+      <div>
+        <a href="profile/{$smarty.session.forlife}?modif=new" class="popup2">
+          Ta fiche avec cette photo
+        </a>
+      </div>
+      <img src="photo/{$smarty.session.forlife}/req" alt=" [ PHOTO ] " style="max-height: 250px; margin-top: 1em" />
+    </td>
+    {/if}
+  </tr>
+  <tr class="pair">
+    <td colspan="2">
+      Pour profiter de cette fonction intéressante, tu dois disposer
+      quelque part (sur ton ordinateur ou sur Internet) d'une photo
+      d'identité (dans un fichier au format JPEG, PNG ou GIF).<br />
+      <div class="center">
+        <a href="photo/change">Éditer ta photo</a>
+      </div>
+    </td>
+  </tr>
+</table>
+
+<table class="bicol" style="margin-bottom: 1em"
+  summary="Profil: Divers">
+  <tr>
+    <th colspan="2">
+      Divers
+    </th>
+  </tr>
+  <tr>
+    <td colspan="2" class="pflags">
+      <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+        <tr>
+          <td class="rouge">
+            <input type="checkbox" disabled="disabled" checked="checked" />
+          </td>
+          <td class="texte">
+            privé
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Surnom</span>
+    </td>
+    <td class="cold">
+      <input type="text" size="35" maxlength="64"
+             {if $errors.nick}class="error"{/if} name="nick" value="{$nick}" />
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" class="pflags">
+      <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+        <tr>
+          <td class="vert">
+            <input type="radio" name="mobile_pub" {if $mobile_pub eq 'public'}checked="checked"{/if} value='public' />
+          </td>
+          <td class="texte">
+            site public
+          </td>
+          <td class="orange">
+            <input type="radio" name="mobile_pub" {if $mobile_pub eq 'ax'}checked="checked"{/if} value='ax' />
+          </td>
+          <td class="texte">
+            transmis à l'AX
+          </td>
+          <td class="rouge">
+            <input type="radio" name="mobile_pub" {if $mobile_pub eq 'private'}checked="checked"{/if} value='private' />
+          </td>
+          <td class="texte">
+            privé
+          </td>
+          <td class="texte">
+            <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td class="colg">
+      <span class="titre">Téléphone mobile</span>
+    </td>
+    <td class="cold">
+      <input type="text" size="18" maxlength="18" name="mobile"
+             {if $errors.mobile}class="error"{/if} value="{$mobile}" />
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" class="flags">
+      <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+        <tr>
+          <td class="vert">
+            <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
+          </td>
+          <td class="texte">
+            site public
+          </td>
+          <td class="texte">
+            <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td class="dcolg">
+      <span class="titre">Page web Perso</span>
+    </td>
+    <td class="dcold">
+      <input type="text" size="35" maxlength="95" name="web"
+             {if $errors.web}class="error"{/if} value="{$web}" />
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2" class="pflags">
+      <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
+        <tr>
+          <td class="vert">
+            <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
+          </td>
+          <td class="texte">
+            site public
+          </td>
+          <td class="texte">
+            <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td class="dcolg">
+      <div>
+        <span class="titre">Complément libre</span>
+        <span class="comm">Commentaire ? ICQ ? etc...</span>
+      </div>
+      <div class="smaller" style="margin-top: 30px">
+        <a href="wiki_help/notitle" class="popup3">
+          {icon name=information title="Syntaxe wiki"} Voir la syntaxe wiki autorisée pour le commentaire
+        </a>
         <div class="center">
-          <a href="photo/change">Éditer ta photo</a>
-        </div>
-      </td>
-    </tr>
-  </table>
-  <table class="bicol" style="margin-bottom: 1em"
-    summary="Profil: Divers">
-    <tr>
-      <th colspan="2">
-        Divers
-      </th>
-    </tr>
-    <tr>
-      <td colspan="2" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="rouge">
-              <input type="checkbox" disabled="disabled" checked="checked" />
-            </td>
-            <td class="texte">
-              privé
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Surnom</span>
-      </td>
-      <td class="cold">
-        <input type="text" size="35" maxlength="64"
-               {if $errors.nick}class="error"{/if} name="nick" value="{$nick}" />
-      </td>
-    </tr>
-    <tr>
-      <td colspan="2" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="vert">
-              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'public'}checked="checked"{/if} value='public' />
-            </td>
-            <td class="texte">
-              site public
-            </td>
-            <td class="orange">
-              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'ax'}checked="checked"{/if} value='ax' />
-            </td>
-            <td class="texte">
-              transmis à l'AX
-            </td>
-            <td class="rouge">
-              <input type="radio" name="mobile_pub" {if $mobile_pub eq 'private'}checked="checked"{/if} value='private' />
-            </td>
-            <td class="texte">
-              privé
-            </td>
-            <td class="texte">
-              <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr>
-      <td class="colg">
-        <span class="titre">Téléphone mobile</span>
-      </td>
-      <td class="cold">
-        <input type="text" size="18" maxlength="18" name="mobile"
-               {if $errors.mobile}class="error"{/if} value="{$mobile}" />
-      </td>
-    </tr>
-    <tr>
-      <td colspan="2" class="flags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="vert">
-              <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
-            </td>
-            <td class="texte">
-              site public
-            </td>
-            <td class="texte">
-              <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr>
-      <td class="dcolg">
-        <span class="titre">Page web Perso</span>
-      </td>
-      <td class="dcold">
-        <input type="text" size="35" maxlength="95" name="web"
-               {if $errors.web}class="error"{/if} value="{$web}" />
-      </td>
-    </tr>
-    <tr>
-      <td colspan="2" class="pflags">
-        <table class="flags" summary="Flags" cellpadding="0" cellspacing="0">
-          <tr>
-            <td class="vert">
-              <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
-            </td>
-            <td class="texte">
-              site public
-            </td>
-            <td class="texte">
-              <a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ??</a>
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-    <tr>
-      <td class="dcolg">
-        <div>
-          <span class="titre">Complément libre</span>
-          <span class="comm">Commentaire ? ICQ ? etc...</span>
-        </div>
-        <div class="smaller" style="margin-top: 30px">
-          <a href="wiki_help/notitle" class="popup3">
-            {icon name=information title="Syntaxe wiki"} Voir la syntaxe wiki autorisée pour le commentaire
-          </a>
-          <div class="center">
-            <input type="submit" name="preview" value="Aperçu"
-                    onclick="previewWiki('freetext', 'ft_preview', true, 'ft_preview'); return false;" />
-          </div>
+          <input type="submit" name="preview" value="Aperçu"
+                  onclick="previewWiki('freetext', 'ft_preview', true, 'ft_preview'); return false;" />
         </div>
-      </td>
-      <td class="dcold">
-        <div id="ft_preview" style="display: none"></div>
-        <textarea name="freetext" {if $errors.freetext}class="error"{/if}
-                  id="freetext" rows="8" cols="35" >{$freetext}</textarea>
-      </td>
-    </tr>
-  </table>
+      </div>
+    </td>
+    <td class="dcold">
+      <div id="ft_preview" style="display: none"></div>
+      <textarea name="freetext" {if $errors.freetext}class="error"{/if}
+                id="freetext" rows="8" cols="35" >{$freetext}</textarea>
+    </td>
+  </tr>
+</table>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/profile/grades.js.tpl b/templates/profile/grades.js.tpl
new file mode 100644 (file)
index 0000000..57ac91d
--- /dev/null
@@ -0,0 +1,37 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2007 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+subgrades = new Array();
+names     = new Array();
+{foreach from=$medal_list key=type item=list}
+{foreach from=$list item=m}
+names[{$m.id}] = "{$m.text}";
+{if $grades[$m.id]|@count}
+names[{$m.id}] = "{$m.text}";
+subgrades[{$m.id}] = new Array({$grades[$m.id]|@count});
+{foreach from=$grades[$m.id] item=g}
+subgrades[{$m.id}][{$g.gid-1}] = [{$g.gid},"{$g.text}"];
+{/foreach}
+{/if}{/foreach}
+{/foreach}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index 67d9543..253c64b 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-{literal}
-<script type="text/javascript">//<![CDATA[
-  var gdt = new Date();
-  var year = gdt.getYear();
-  if (year < 1000) {
-    year += 1900;
-  }
-
-  var oldMate = year >= {/literal}{$smarty.session.promo_sortie}{literal};
-
-  function printTitle(text)
-  {
-    if (oldMate) {
-      document.write("ex-" + text);
-    } else {
-      document.write(text);
-    }
-  }
-
-  function update(type)
-  {
-    var val = document.forms.prof_annu[type + '_sel'].value;
-    if (val == '0' || document.getElementById(type + '_' + val) != null) {
-      document.getElementById(type + '_add').style.display = 'none';
-    } else {
-      document.getElementById(type + '_add').style.display = '';
-    }
-  }
-
-  function remove(cat, id)
-  {
-    $('#' + cat + '_' + id).remove();
-    update(cat);
-  }
-
-  function add(cat)
-  {
-    var cb   = document.forms.prof_annu[cat + '_sel'];
-    var id   = cb.value;
-    var text = cb.options[cb.selectedIndex].text;
-    var html = '<tr id="' + cat + '_' + id + '">'
-             + '  <td>'
-             + '    <input type="hidden" name="' + cat + '[' + id + ']" value="' + text + '" />'
-             + '  </td>'
-             + '  <td>'
-             + '    <div style="float: left; width: 70%">'
-             +        text
-             + '    </div>'
-             + '    <a href="javascript:remove(\'' + cat + '\', ' + id + ')">'
-             + '      <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
-             + '    </a>'
-             + '  </td>'
-             + '</tr>';
-    $('#' + cat).after(html);
-    update(cat);
-  }
-
-  function updateSubLink(cb)
-  {
-    var href = cb.value ? cb.value : "http://www.polytechnique.net";
-    document.getElementById("groupesx_sub").href = href;
-  }
-
-  //]]>
-</script>
-{/literal}
-
 <table class="bicol" style="margin-bottom: 1em" summary="Profil: Informations Polytechniciennes">
   <tr>
     <th colspan="2">
     </td>
   </tr>
   <tr class="top">
-    <td class="titre" style="width: 30%">
-      <script type="text/javascript">printTitle("Section")</script>
-    </td>
+    <td class="titre" style="width: 30%">{if $old}ex-{/if}Section</td>
     <td>
       <select name="section">
         {select_db_table table="sections" valeur=$section}
   </tr>
   <!-- Binets -->
   <tr id="binets">
-    <td class="titre">
-      <script type="text/javascript">printTitle("Binet(s)")</script>
-    </td>
+    <td class="titre">{if $old}ex-{/if}Binet(s)</td>
     <td>
-      <select name="binets_sel" onchange="update('binets')">
+      <select name="binets_sel" onchange="updateGroup('binets')">
         {select_db_table table="binets_def" valeur=0 champ="text" pad='1'}
       </select>
-      <a id="binets_add" href="javascript:add('binets')">{icon name="add" title="Ajouter ce binet"}</a>
+      <a id="binets_add" style="display: none"
+         href="javascript:addGroup('binets')">{icon name="add" title="Ajouter ce binet"}</a>
     </td>
   </tr>
   {foreach item=text key=bid from=$binets}
       <div style="float: left; width: 70%">
         {$text}
       </div>
-      <a href="javascript:remove('binets', {$bid})">{icon name="cross" title="Supprimer ce binet"}</a>
+      <a href="javascript:removeGroup('binets', {$bid})">{icon name="cross" title="Supprimer ce binet"}</a>
     </td>
   </tr>
   {/foreach}
   </tr>
 </table>
 
-<script type="text/javascript">
-update('binets');
-updateSubLink(document.forms.prof_annu.groupesx_sub);
-</script>
-
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index bcda539..110768b 100644 (file)
@@ -20,9 +20,6 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if $ajaxjob}
-<?xml version="1.0" encoding="utf-8"?>
-{/if}
 {assign var=jobid value="job_`$i`"}
 {assign var=jobpref value="jobs[`$i`]"}
 <div id="{$jobid}">
@@ -62,7 +59,7 @@
     <tr>
       <td class="titre">Secteur d'activité</td>
       <td>
-        <select name="{$jobpref}[secteur]" onchange="updateSecteur({$i}, '{$jobid}', '{$jobpref}', ''); return true;">
+        <select name="{$jobpref}[secteur]" onchange="updateJobSecteur({$i}, '{$jobid}', '{$jobpref}', ''); return true;">
           <option value="">&nbsp;</option>
           {iterate from=$secteurs item=secteur}
           <option value="{$secteur.id}" {if $secteur.id eq $job.secteur}selected="selected"{/if}>
@@ -75,6 +72,7 @@
     <tr>
       <td class="titre">Sous-Secteur d'activité</td>
       <td id="{$jobid}_ss_secteur">
+        <input type="hidden" name="{$jobpref}[ss_secteur]" value="{$job.ss_secteur|default='-1'}" />
       </td> 
     </tr>
     <tr>
index e42a14a..9f0d364 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<script type="text/javascript">//<![CDATA[
-{literal}
-
-function removeJob(id, pref)
-{
-  document.getElementById(id + '_cont').style.display = 'none';
-  if (document.forms.prof_annu[pref + '[new]'].value == '0') {
-    document.getElementById(id + '_grayed').style.display = '';
-    document.getElementById(id + '_grayed_name').innerHTML =
-      document.forms.prof_annu[pref + "[name]"].value.replace('<', '&lt;');
-  }
-  document.forms.prof_annu[pref + "[removed]"].value = "1";
-}
-
-function restoreJob(id, pref)
-{
-  document.getElementById(id + '_cont').style.display = '';
-  document.getElementById(id + '_grayed').style.display = 'none';
-  document.forms.prof_annu[pref + "[removed]"].value = "0";
-}
-
-function updateSecteur(nb, id, pref, sel)
-{
-  var secteur = document.forms.prof_annu[pref + '[secteur]'].value;
-  if (secteur == '') {
-    secteur = '-1';
-  }
-  Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel);
-}
-
-function makeAddJob(id)
-{
-  return function(data)
-         {
-           $('#add_job').before(data);
-           updateSecteur('job_' + id, 'jobs[' + id + ']', '');
-         };
-}
-
-function addJob()
-{
-  var i = 0;
-  while (document.getElementById('job_' + i) != null) {
-    ++i;
-  }
-  $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
-}
-
-function validGeoloc(id, pref)
-{
-  document.getElementById(id + '_geoloc').style.display = 'none';
-  document.getElementById(id + '_geoloc_error').style.display = 'none';
-  document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
-  document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
-  document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value;
-  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
-              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
-  document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-function validAddress(id, pref)
-{
-  document.getElementById(id + '_geoloc').style.display = 'none';
-  document.getElementById(id + '_geoloc_error').style.display = 'none';
-  document.getElementById(id + '_geoloc_valid').style.display = 'none';
-  document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
-  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
-              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
-  document.forms.prof_annu[pref + "[text]"].className = '';
-}
-
-{/literal}
-//]]></script>
-
 {foreach from=$jobs item=job key=i}
 {include file="profile/jobs.job.tpl" i=$i job=$job new=false}
-<script type="text/javascript">updateSecteur({$i}, '{"job_`$i`"}', '{"jobs[`$i`]"}', '{$job.ss_secteur}');</script>
 {/foreach}
 {if $jobs|@count eq 0}
 {include file="profile/jobs.job.tpl" i=0 job=0 new=true}
-<script type="text/javascript">updateSecteur(0, 'job_0', 'jobs[0]', '-1');</script></script>
 {/if}
 
 <div id="add_job" class="center">
index 4817dbe..dae04f6 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-<script type="text/javascript">//<![CDATA[
-{literal}
-
-function updateCountry()
-{
-  var val = document.forms.prof_annu.countries_sel.value;
-  var show = true;
-  if (val == '') {
-    show = false;
-  }
-  if (document.getElementById('countries_' + val) != null) {
-    show = false;
-  }
-  document.getElementById('countries_add').style.display = show ? '' : 'none';
-}
-
-function addCountry()
-{
-  var cb   = document.forms.prof_annu.countries_sel;
-  var val  = cb.value;
-  var text = cb.options[cb.selectedIndex].text;
-  var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
-           + '  <div style="float: left; width: 50%">' + text + '</div>'
-           + '  <input type="hidden" name="countries[' + val + ']" value="' + text + '" />'
-           + '  <a href="javascript:removeCountry(\'' + val + '\')">'
-           + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
-           + '  </a>'
-           + '</div>';
-  $('#countries').append(html);
-  updateCountry();
-}
-
-function removeCountry(id)
-{
-  $('#countries_' + id).remove();
-  updateCountry();
-}
-
-function updateSSecteur()
-{
-  var s  = document.forms.prof_annu.secteur_sel.value;
-  var ss = document.forms.prof_annu['jobs[-1][ss_secteur]'].value;
-  var show = true;
-  if (s == '' || ss == '') {
-    show = false;
-  }
-  if (document.getElementById('secteurs_' + s + '_' + ss) != null) {
-    show = false;
-  }
-  document.getElementById('secteurs_add').style.display = show ? 'block' : 'none';
-}
-
-function updateSecteur()
-{
-  var secteur = document.forms.prof_annu.secteur_sel.value;
-  if (secteur == '') {
-    secteur = '-1';
-  }
-  $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur,
-        function(data) {
-          data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
-               +  '  <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
-               +  '</a>' + data;
-          document.getElementById('ss_secteur_sel').innerHTML = data;
-          attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur);
-        });
-}
-
-function addSecteur()
-{
-  var scb = document.forms.prof_annu.secteur_sel;
-  var s  = scb.value;
-  var st = scb.options[scb.selectedIndex].text;
-
-  var sscb = document.forms.prof_annu['jobs[-1][ss_secteur]'];
-  var ss = sscb.value;
-  var sst = sscb.options[sscb.selectedIndex].text;
-
-  var html = '<div id="secteurs_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">'
-           + '  <a href="javascript:removeSecteur(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">'
-           + '    <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
-           + '  </a>'
-           + '  <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />'
-           + '  ' + sst
-           + '</div>';
-  $('#secteurs').append(html);
-  updateSSecteur();
-}
-
-function removeSecteur(s, ss)
-{
-  $('#secteurs_' + s + '_' + ss).remove();
-  updateSSecteur();
-}
-
-{/literal}
-//]]></script>
-
 <p>
   Si tu acceptes que ceux des camarades te contactent afin de te demander
   conseil, dans les domaines que tu connais bien, et pour lesquels tu pourrais
index 5579bc6..2dae743 100644 (file)
@@ -20,9 +20,6 @@
 {*                                                                        *}
 {**************************************************************************}
 
-{if $ajaxskill}
-<?xml version="1.0" encoding="utf-8"?>
-{/if}
 <div id="{$cat}_{$id}" style="clear: both; margin-top: 0.5em">
   <div style="float: left; width: 50%" class="titre" id="{$cat}_{$id}_title">
     {$skill.text}
@@ -33,7 +30,7 @@
     <option value="{$lid}" {if $skill.level eq $lid}selected="selected"{/if}>{$level}</option>
     {/foreach}
   </select>
-  <a href="javascript:remove('{$cat}', '{$id}')">{icon name=cross title="Supprimer"}</a>
+  <a href="javascript:removeSkill('{$cat}', '{$id}')">{icon name=cross title="Supprimer"}</a>
 </div>
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index aea9c70..4011825 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-
-<script type="text/javascript">//<![CDATA[
-{literal}
-
-function update(cat)
-{
-  var val  = document.forms.prof_annu[cat + '_sel'].value;
-  var show = true;
-  if (val == '') {
-    show = false;
-  }
-  if (document.getElementById(cat + '_' + val) != null) {
-    show = false;
-  }
-  document.getElementById(cat + '_add').style.display = show ? '' : 'none';
-}
-
-function add(cat)
-{
-  var sel  = document.forms.prof_annu[cat + '_sel'];
-  var val  = sel.value;
-  var text = sel.options[sel.selectedIndex].text;
-  $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
-        function(data) {
-          $('#' + cat).append(data);
-          document.getElementById(cat + '_' + val + '_title').innerHTML = text;
-          update(cat);
-        });
-}
-
-function remove(cat, id)
-{
-  $('#' + cat + '_' + id).remove();
-  update(cat);
-}
-
-{/literal}
-//]]></script>
-
 <table class="bicol" style="margin-bottom: 1em">
   <tr>
     <th>
@@ -73,7 +34,7 @@ function remove(cat, id)
       </div>
       <div>
         <span class="titre">Domaine&nbsp;:</span>
-        <select name="competences_sel" onchange="update('competences')">
+        <select name="competences_sel" onchange="updateSkill('competences')">
           <option value=""></option>
           {assign var=ingroup value=false}
           {iterate from=$comp_list item=comp}
@@ -87,7 +48,7 @@ function remove(cat, id)
           {if $ingroup}</optgroup>{/if}
         </select>
         <span id="competences_add" style="display: none">
-          <a href="javascript:add('competences')">{icon name=add title="Ajouter cette compétence"}</a>
+          <a href="javascript:addSkill('competences')">{icon name=add title="Ajouter cette compétence"}</a>
         </span>
       </div>
     </td>
@@ -113,14 +74,14 @@ function remove(cat, id)
       </div>
       <div>
         <span class="titre">Domaine&nbsp;:</span>
-        <select name="langues_sel" onchange="update('langues')">
+        <select name="langues_sel" onchange="updateSkill('langues')">
           <option value=""></option>
           {iterate from=$lang_list item=lang}
           <option value="{$lang.id}">{$lang.langue_fr}</option>
           {/iterate}
         </select>
         <span id="langues_add" style="display: none">
-          <a href="javascript:add('langues')">{icon name=add title="Ajouter cette langue"}</a>
+          <a href="javascript:addSkill('langues')">{icon name=add title="Ajouter cette langue"}</a>
         </span>
       </div>
     </td>