crabs_firewall-3.0.1 ©2005-2011 - Christophe CAZAJUS (crabs-mettre_le_signe_at-crabs-world.com)
1 // 2 // ============================================================================= 3 // crabs_firewall-3.0.1 : Firewall-Masquerade avec interface http 4 // Copyright (C) 2005-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 var graphique_active = null ; 24 var sel_x0 ; 25 26 function graphique( img_id ) 27 { 28 this.id_name = img_id ; 29 this.img = document.getElementById( img_id ) ; 30 this.sel = document.getElementById( 'sel_'+img_id ) ; 31 this.img.onmousedown = graph_down ; 32 this.x0 = -1 ; this.y0 = -1 ; 33 this.v0 = -1 ; this.x1 = -1 ; 34 this.y1 = -1 ; this.v1 = -1 ; 35 this.xp0 = -1 ; this.yp0 = -1 ; 36 this.xp1 = -1 ; this.yp1 = -1 ; 37 this.dans_courbe = function( e ) 38 { 39 if ( e.pageX < this.xp0 ) return false ; 40 if ( e.pageX > this.xp1 ) return false ; 41 if ( e.pageY < this.yp0 ) return false ; 42 if ( e.pageY > this.yp1 ) return false ; 43 return true ; 44 } 45 this.set_value = function() 46 { 47 var debut = parseInt( this.sel.style.left ) ; 48 var fin = debut + parseInt( this.sel.style.width ) ; 49 debut -= this.xp0 ; fin -= this.xp0 ; 50 debut = this.v0 + debut * (this.v1-this.v0) / (this.x1-this.x0) ; 51 fin = this.v0 + fin * (this.v1-this.v0) / (this.x1-this.x0) ; 52 if ( debut < this.v0 ) debut = this.v0 ; 53 if ( fin > this.v1 ) fin = this.v1 ; 54 document.getElementById('fdd').value = sec_to_hh_mm( debut ) ; 55 document.getElementById('fdf').value = sec_to_hh_mm( fin ) ; 56 } 57 } 58 59 function sec_to_hh_mm( x ) 60 { 61 var sec = x|0 ; 62 var S = sec % 60 ; 63 var M = ( ( sec / 60 ) | 0 ) % 60 ; 64 var H = ( sec / 3600 ) | 0 ; 65 var heure = H + ":" ; 66 if ( M < 10 ) heure += "0" ; 67 heure += M ; 68 return heure ; 69 } 70 71 function graph_init() 72 { 73 for( var i=0; i<array_graph.length; i++ ) 74 { 75 if ( array_graph[i] ) delete array_graph[i] ; 76 array_graph[i] = null ; 77 } 78 79 for( var i=0; i<div_img.length; i++ ) 80 { 81 array_graph[i] = new graphique( 'i'+div_img[i] ) ; 82 } 83 } 84 85 function graph_by_id( img_id ) 86 { 87 for ( var i=0; i<array_graph.length; i++ ) 88 if ( array_graph[i].id_name == img_id ) 89 return array_graph[i] ; 90 return null ; 91 } 92 93 function graph_courbe_info( img_id, info ) 94 { 95 var g = graph_by_id( img_id ) ; 96 if ( g == null ) return ; 97 g.x0 = parseInt( info[2] ) ; g.x1 = parseInt( info[3] ) ; 98 g.y0 = parseInt( info[4] ) ; g.y1 = parseInt( info[5] ) ; 99 g.v0 = parseInt( info[6] ) ; g.v1 = parseInt( info[7] ) ; 100 g.xp0 = g.x0 ; g.yp0 = g.y0 ; g.xp1 = g.x1 ; g.yp1 = g.y1 ; 101 var element = g.img ; 102 while ( element ) 103 { 104 var ox = element.offsetLeft ; var oy = element.offsetTop ; 105 g.xp0 += ox ; g.yp0 += oy ; g.xp1 += ox ; g.yp1 += oy ; 106 element = element.offsetParent ; 107 } 108 g.sel.style.top = g.yp0 + 'px' ; 109 g.sel.style.height = ( g.yp1 - g.yp0 ) + 'px' ; 110 } 111 112 function graph_down( e ) 113 { 114 var g = graph_by_id( e.target.id ) ; 115 if ( g == null ) return ; 116 if ( ! g.dans_courbe( e ) ) return ; 117 118 sel_x0 = e.pageX ; 119 g.sel.onmousemove = graph_move ; 120 g.sel.onmouseup = graph_up ; 121 122 g.img.onmousemove = graph_move ; 123 g.img.onmouseup = graph_up ; 124 g.img.onmouseout = graph_out ; 125 graphique_active = g ; 126 127 e.preventDefault() ; 128 } 129 130 function graph_up( e ) 131 { 132 var g = graphique_active ; 133 if ( g ) 134 { 135 if ( g.dans_courbe( e ) ) 136 { 137 graph_move( e ) ; // juste au cas où 138 g.set_value() ; 139 graph_go() ; 140 } 141 g.img.onmousemove = null ; 142 g.img.onmouseup = null ; 143 g.img.onmouseout = null ; 144 } 145 for ( var i=0; i<array_graph.length; i++ ) 146 array_graph[i].sel.style.display = "none" ; 147 graphique_active = null ; 148 g.sel.onmousemove = null ; 149 g.sel.onmouseup = null ; 150 } 151 152 function graph_move( e ) 153 { 154 if ( !graphique_active ) return ; 155 if ( !graphique_active.dans_courbe( e ) ) return ; 156 157 var g = graphique_active ; 158 159 var w = 0 ; var x = 0 ; 160 if ( e.pageX < sel_x0 ) 161 { 162 x = e.pageX + 'px' ; 163 w = ( sel_x0 - e.pageX ) + 'px' ; 164 } 165 else 166 { 167 x = sel_x0 + 'px' ; 168 w = ( e.pageX - sel_x0 ) + 'px' ; 169 } 170 for ( var i=0; i<array_graph.length; i++ ) 171 { 172 var s = array_graph[i].sel ; 173 s.style.display = "block" ; 174 s.style.left = x ; 175 s.style.width = w ; 176 } 177 } 178 179 function graph_out( e ) 180 { 181 if ( !graphique_active ) return ; 182 if ( graphique_active.dans_courbe( e ) ) return ; // hors #sel 183 184 graphique_active.img.onmousemove = null ; 185 graphique_active.img.onmouseup = null ; 186 graphique_active.img.onmouseout = null ; 187 188 for ( var i=0; i<array_graph.length; i++ ) 189 array_graph[i].sel.style.display = "none" ; 190 graphique_active.sel.onmousemove = null ; 191 graphique_active.sel.onmouseup = null ; 192 graphique_active = null ; 193 } 194
Date de génération : 22/09/2011 21:48