Gestion simplissime des Todo

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

~~ / todo.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 // VARIABLES GLOBALES
   24 // - les valeurs des filtres pour la liste des todo
   25 var url_var = new Array() ;
   26 // - info sur le todo selectionne
   27 var todo_current = false ;          // le tableau des info du todo
   28 var todo_current_active = false ;   // id jquery de la ligne todo
   29 var todo_current_modified = false ;
   30 
   31 // FONCTIONS GENERALES
   32 // La fonction MAIN de JQuery
   33 $(document).ready( todo_start ) ;
   34 
   35 function todo_start()
   36     {
   37     filtre("fr0") ; filtre("fs0") ; filtre("fw0") ; filtre("fp0",true) ;
   38     url_var['projet']='0' ; url_var['pseudo']='0' ;
   39     fo_change( 'projet' ) ;
   40     }
   41 
   42 // selection d'un filtre par "checkbox"
   43 // si on vient d'une icone => force l'update
   44 function filtre( quoi, do_update )
   45     {
   46     if ( !resetCurrentTodo() ) return ;
   47     var element, nom ;
   48     if ( !!quoi.charAt )
   49         { nom = quoi ; element = $('#'+nom) ; }
   50     else
   51         { element = $(quoi) ; nom = element.attr('id') ; do_update = true ; }
   52     var filtre = nom.substring( 0, 2 ) ;
   53     url_var[ filtre ] = nom ;
   54     $( '.'+filtre).css( "border-color", "#e0e0e0" ) ;
   55     $( element ).css( "border-color", "#808080" ) ;
   56     $( '#'+filtre+'f').attr( 'src', element.attr( 'src' ) ) ;
   57     if ( do_update == true ) liste_charge() ;
   58     }
   59 
   60 function resetCurrentTodo()
   61     {
   62     if ( todo_current_modified )
   63         if ( !confirm( i18n_loose ) ) return false ;
   64     // on oublie les modifications non-sauvergardees
   65     todo_current_modified = false ;
   66     todo_current = false ;
   67     $('#detail').html( "" ) ;
   68     return true ;
   69     }
   70 
   71 function todo_new()
   72     {
   73     if ( !resetCurrentTodo() ) return ;
   74     var url = 'hr_todo_create.php' ; sep='?' ;
   75     for( var uv in url_var )
   76         { url += sep + uv + '=' + esc4url( url_var[uv] ) ; sep = '&' ; }
   77 
   78     $.ajax( {
   79         url: url,
   80         dataType : "text",
   81         success : function( data, textStatus, XMLHttpRequest )
   82             {
   83             if ( data == '' ) return ;
   84             var f = data.split("<!>") ;
   85             if ( f[0] != 'OK' ) { alert( data ) ; return ; }
   86             modif_todo( f[1] ) ;
   87             }
   88         } ) ;
   89     }
   90 
   91 function todo_change( change, charge_onglet )
   92     {
   93     $.ajax( {
   94         url: "hr_todo_change.php",
   95         type: "POST",
   96         dataType : "text",
   97         data: change,
   98         success : function( data, textStatus, XMLHttpRequest )
   99             {
  100             if ( data != 'OK' )
  101                 alert( data ) ;
  102             else
  103                 {
  104                 liste_charge() ;
  105                 if ( charge_onglet ) fo_reload( 'of' ) ;
  106                 }
  107             }
  108         } ) ;
  109     }
  110 
  111 //
  112 // UTILITAIRE
  113 //
  114 function esc4url( texte )
  115     {
  116     texte = texte.replace( /&/g, escape('&') ) ;
  117     texte = texte.replace( /=/g, escape('=') ) ;
  118     texte = texte.replace( /\+/g, '%2B' ) ;
  119     return texte ;
  120     }
  121 
  122 function element_visible( bloc, el )
  123     {
  124     $(bloc).scrollTop(0) ;
  125     var st = $(el).position().top + $(el).height()/2 - $(bloc).height()/2 ;
  126     $(bloc).scrollTop(st) ;
  127     }
  128 
  129 function state_icon( s )
  130     {
  131     if ( s < 0.33 ) return 1 ;
  132     if ( s < 0.67 ) return 2 ;
  133     return 3 ;
  134     }
  135 
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
~~ / todo.js

Haut de page

Contacter crabs

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