Gestion simplissime des Todo

crabs_todo-2.0 ©2008-2011 - Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)

~~ / modif.js
Makefile todo.css todo.js onglet.js liste.js detail.js modif.js index.php logout.php todo.php hr_todo_create.php hr_todo_list.php hr_todo_info.php hr_todo_change.php hr_todo_del.php hr_projet_liste.php hr_pseudo_liste.php
    1 //
    2 // =============================================================================
    3 //  crabs_todo-2.0 : Gestion simplissime des Todo
    4 //  Copyright (C) 2008-2011 : Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)
    5 //
    6 //  Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer
    7 //  et/ou le modifier en respectant les termes de la GNU General Public License
    8 //  version 2 ou (suite a votre propre choix) une version ulterieure.
    9 //
   10 //  Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais
   11 //  sans aucune garantie, meme si il est associe a un produit qui vous en
   12 //  propose une. Conformez-vous a la GNU General Public License pour avoir
   13 //  plus de precisions.
   14 //
   15 //  L'auteur ne peut etre tenu responsable de l'utilisation faite des
   16 //  composantes associees a ce projet (en partie ou dans leur totalite).
   17 //
   18 //  Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC
   19 //  de ce projet sous le nom gnu_gpl.txt
   20 //
   21 // =============================================================================
   22 //
   23 function modif_todo( todo )
   24     {
   25     if ( todo == undefined )
   26         {
   27         if ( !todo_current ) return ;
   28         todo = todo_current[0] ;
   29         }
   30 
   31     $.ajax( {
   32         url: "hr_todo_info.php?todo="+todo,
   33         dataType : "text",
   34         success : modif_reponse
   35         } ) ;
   36     }
   37 
   38 function modif_reponse( data, textStatus, XMLHttpRequest )
   39     {
   40     if ( data == '' ) { $('#liste').html('pas d\'info'); return ; }
   41     var f = data.split("<!>") ;
   42     if ( f[11] != 'OK' )
   43         {
   44         $('#detail').html('<pre>'+data+'</pre>') ;
   45         return ;
   46         }
   47     // 0:id 1:s 2:w 3:p 4:projet 5:tache 6:ps 7:r 8:dt 9:pl 10:note
   48     todo_current = f ;
   49     var ht ='<table><tr><td>'
   50         +'<span class="a_gauche">'
   51         + '<img class="menu" src="IMAGES/save.png" alt="save"'
   52         + ' onclick="modif_save();" title="'+i18n_save+'">'
   53         + '<img class="menu" src="IMAGES/cancel.png" alt="cancel"'
   54         + ' onclick="modif_cancel();" title="'+i18n_cancel+'">'
   55         +'</span>'
   56         + '<span class="ml">Projet : </span>'
   57         +'<input id="mpro" type="text" size="16" value="'+f[4]+'"'
   58         + ' onchange="todo_current_modified=true;">'
   59         +'<select size="1" id="mlpro" onchange="modif_set_pro();"></select>'
   60         + '<span class="ml">Pour le : </span>'
   61         +'<input id="mpl" type="text" size="12" value="'+f[9]+'"'
   62         + ' onchange="todo_current_modified=true;">'
   63         +'<br><span class="ml">Tâche : </span>'
   64         +'<input id="mtask" type="text" size="48" value="'+f[5]+'"'
   65         + ' onchange="todo_current_modified=true;">'
   66         +'</td><td>'
   67         +'<div class="icone"><span class="ico_grp">'
   68         +'<img src="IMAGES/fr1.png" alt="r1" id="td_r1" class="tdico">'
   69         +'<img src="IMAGES/fr2.png" alt="r1" id="td_r2" class="tdico">'
   70         +'</span><span class="ico_grp">'
   71         +'<img src="IMAGES/fw1.png" alt="w1" id="td_w1" class="tdico">'
   72         +'<img src="IMAGES/fw2.png" alt="w2" id="td_w2" class="tdico">'
   73         +'<img src="IMAGES/fw3.png" alt="w3" id="td_w3" class="tdico">'
   74         +'</span></div><div class="icone"><span class="ico_grp">'
   75         +'<img src="IMAGES/fp1.png" alt="p1" id="td_p1" class="tdico">'
   76         +'<img src="IMAGES/fp2.png" alt="p2" id="td_p2" class="tdico">'
   77         +'<img src="IMAGES/fp3.png" alt="p3" id="td_p3" class="tdico">'
   78         +'</span></div>'
   79         +'</td></tr></table>'
   80         +'<div id="modif">'
   81         + '<textarea id="mnote" onchange="todo_current_modified=true;">'
   82         +  f[10]+'</textarea>'
   83         +'</div>' ;
   84     $('#detail').html( ht ) ;
   85     $('.tdico').click( function() { modif_change( $(this) ) ; } ) ;
   86     $('#td_r'+f[7]).addClass( 'active' ) ;
   87     $('#td_w'+f[2]).addClass( 'active' ) ;
   88     $('#td_p'+f[3]).addClass( 'active' ) ;
   89     modif_lst_pro() ;
   90     }
   91 
   92 function modif_change( je )
   93     {
   94     if ( todo_current == false ) return ;
   95     var quoi = $(je).attr('id').substring(3,4) ;
   96     var comment = $(je).attr('id').substring(4,5) ;
   97     var ancien ;
   98     switch( quoi )
   99         {
  100         case 'r' :
  101             ancien=todo_current[7]; todo_current[7]=comment;
  102         break ;
  103         case 'w' :
  104             ancien=todo_current[2]; todo_current[2]=comment;
  105         break ;
  106         case 'p' :
  107             ancien=todo_current[3]; todo_current[3]=comment;
  108         break ;
  109         default :  return ;
  110         }
  111     todo_current_modified = true ;
  112     $('#td_'+quoi+ancien).removeClass( 'active' ) ;
  113     $('#td_'+quoi+comment).addClass( 'active' ) ;
  114     }
  115 
  116 function modif_lst_pro()
  117     {
  118     $.ajax( {
  119         url: "hr_projet_liste.php",
  120         dataType : "text",
  121         success : function( data, textStatus, XMLHttpRequest )
  122             {
  123             if ( data == '' ) return ;
  124             var l = data.split("<#>") ;
  125             if ( l[0] != 'OK' ) return ;
  126             var o = '' ; var f=false ;
  127             for( var i=1; i<l.length; i++ )
  128                 {
  129                 var v = l[i] ;
  130                 if ( v == todo_current[4] )
  131                     {
  132                     o += '<option value="'+v+'" SELECTED>'+v+'</option>' ;
  133                     f = true ;
  134                     }
  135                 else
  136                     o += '<option value="'+v+'">'+v+'</option>' ;
  137                 }
  138             if ( f )
  139                 o = '<option value="">'+i18n_pro_sel+'</option>' + o ;
  140             else
  141                 o = '<option value="" SELECTED>'+i18n_pro_sel+'</option>' + o ;
  142             $('#mlpro').html(o) ;
  143             }
  144         } ) ;
  145     }
  146 
  147 function modif_set_pro()
  148     {
  149     $('#mpro').val( $('#mlpro').val() ) ;
  150     }
  151 
  152 function modif_cancel()
  153     {
  154     todo_current_modified = false ;
  155     detail_todo() ;
  156     }
  157 
  158 function modif_save()
  159     {
  160     // construit l'objet "POST" pour la modif
  161     // 0:id 1:s 2:w 3:p 4:projet 5:tache 6:ps 7:r 8:dt 9:pl 10:note
  162     change = {
  163         id:         todo_current[0],
  164         w:          todo_current[2],
  165         p:          todo_current[3],
  166         projet:     $('#mpro').val(),
  167         tache:      $('#mtask').val(),
  168         r:          todo_current[7],
  169         pour_le:    $('#mpl').val(),
  170         note:       $('#mnote').val()
  171         } ;
  172     $('#detail').html( '' ) ;
  173     todo_current_modified = false ;
  174     todo_change( change, true ) ;
  175     }
  176 
Makefile todo.css todo.js onglet.js liste.js detail.js modif.js index.php logout.php todo.php hr_todo_create.php hr_todo_list.php hr_todo_info.php hr_todo_change.php hr_todo_del.php hr_projet_liste.php hr_pseudo_liste.php
~~ / modif.js

Haut de page

Contacter crabs

Date de génération : 22/09/2011 21:49