Gestion simplissime des Todo

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

~~ / ADMIN / admin.js
Makefile admin.css admin.js index.php var.js var_get.php var_set.php user.js user_list.php user_info.php user_mod.php user_pwd.php user_del.php base.js base_create.php base_upgrade.php base_function.php backup.js backup_list.php backup_do.php backup_restor.php backup_download.php backup_delete.php sql.js sql.php empty.txt
    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 // -=> initialisation jquery : les actions sur le menu + defaut
   24 var _liste ;
   25 $(document).ready( function()
   26     {
   27     $("#if_fichier").attr( "src", "empty.txt" ) ;
   28     $("span.mi").click( function()
   29         {
   30         if ( ! _liste.can_change() ) return false ;
   31         switch( this.id )
   32             {
   33             case 'mi_var'       :
   34                 $(".mi").removeClass('active') ; $(this).addClass('active') ;
   35                 return var_init() ;
   36             case 'mi_user'      :
   37                 $(".mi").removeClass('active') ; $(this).addClass('active') ;
   38                 return user_init() ;
   39             case 'mi_base'      :
   40                 $(".mi").removeClass('active') ; $(this).addClass('active') ;
   41                 return base_init() ;
   42             case 'mi_backup'    :
   43                 $(".mi").removeClass('active') ; $(this).addClass('active') ;
   44                 return backup_init() ;
   45             case 'mi_sql'       :
   46                 $(".mi").removeClass('active') ; $(this).addClass('active') ;
   47                 return sql_init() ;
   48             }
   49         alert( $(this).html()+ " : later perhaps..." ) ;
   50         return false ;
   51         } ) ;
   52     _liste = new liste() ;
   53     $("#message").html( i18n_title ) ;
   54     $('#mi_var').addClass('active') ;
   55     var_init() ;
   56     } );
   57 
   58 var info_to = false ;
   59 function info( txt )
   60     {
   61     if ( info_to != false ) window.clearTimeout( info_to ) ;
   62     $("#message").html(txt)
   63     info_to = window.setTimeout( info_clear, 2000 ) ;
   64     }
   65 function info_clear()
   66     {
   67     $("#message").html('') ;
   68     }
   69 
   70 function liste_item( key, txt, cmt )
   71     {
   72     this.key = key ;
   73     this.txt = txt ;
   74     this.cmt = cmt ;
   75     }
   76 
   77 function liste()
   78     {
   79     this.refresh = false ;
   80     this.items = false ;
   81     this.clic = function( key ) { return true ; } ;
   82     this.valid = function( key ) { return true ; } ;
   83     this.active_id = false ;
   84     this.active_key = false ;
   85 
   86     this.reset = function()
   87         {
   88         if ( this.items ) this.items.length = 0 ;
   89         this.items = false ;
   90         this.refresh = true ;
   91         }
   92 
   93     this.item_add = function( key, txt, cmt )
   94         {
   95         if ( this.items == false ) this.items = new Array() ;
   96         this.items[this.items.length] = new liste_item( key, txt, cmt ) ;
   97         this.refresh = true ;
   98         }
   99     this.item = function( key )
  100         {
  101         if ( this.items == false ) return false ;
  102         for( var i=0; i<this.items.length; i++ )
  103             if ( this.items[i].key == key ) return this.items[i] ;
  104         return false ;
  105         }
  106     this.draw = function( default_item )
  107         {
  108         if ( !this.refresh ) return ;
  109         this.refresh = false ;
  110         $("#liste").html('') ;
  111         this.active_id = false ;
  112         if ( this.items == false ) return ;
  113         for( var i=0; i<this.items.length; i++ )
  114             {
  115             var key = this.items[i].key ;
  116             var txt = this.items[i].txt ;
  117             var cmt = this.items[i].cmt ;
  118             var did = "liste_"+i ;
  119             if ( default_item != undefined )
  120                 if ( key == default_item )
  121                     { this.active_id = "#"+did ; this.active_key = key ; }
  122             var cl = (i%2==0)?'pair':'impair' ;
  123             var div = "<div id=\""+did+"\" class=\""+cl+"\""
  124                 +" onmouseover=\"this.style.textDecoration='underline';\""
  125                 +" onmouseout=\"this.style.textDecoration='none';\""
  126                 +" onclick=\"_liste.event('#"+did+"','"+key+"');\"" ;
  127             if ( cmt ) div+= " title=\""+cmt+"\"" ;
  128             div+=">"+txt+"</div>" ;
  129             $("#liste").append( div ) ;
  130             }
  131         if ( this.active_id == false )
  132             {
  133             this.active_id = "#liste_0" ;
  134             this.active_key = this.items[0].key ;
  135             }
  136         $(this.active_id).css( "background", "#0000d0" ).css("color","white") ;
  137         window.setTimeout( "_liste.clic( _liste.active_key );", 200 ) ;
  138         }
  139     this.event = function( div, key )
  140         {
  141         if ( !this.can_change() ) return false ;
  142         $(this.active_id).css( "background", "#e0e0e0" ).css("color","black") ;
  143         this.active_id = div ;
  144         $(this.active_id).css( "background", "#0000d0" ).css("color","white") ;
  145         this.active_key = key ;
  146         return this.clic( key ) ;
  147         }
  148     this.can_change = function()
  149         {
  150         return this.valid( this.active_key ) ;
  151         }
  152     }
  153 
Makefile admin.css admin.js index.php var.js var_get.php var_set.php user.js user_list.php user_info.php user_mod.php user_pwd.php user_del.php base.js base_create.php base_upgrade.php base_function.php backup.js backup_list.php backup_do.php backup_restor.php backup_download.php backup_delete.php sql.js sql.php empty.txt
~~ / ADMIN / admin.js

Haut de page

Contacter crabs

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