[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 /* 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 * 20 * -------------------------------------------------------- 21 * $Id: common.js,v 1.10.2.2 2007-10-21 22:39:47 giallu Exp $ 22 * -------------------------------------------------------- 23 */ 24 25 26 /* 27 * String manipulation 28 */ 29 30 function Trim( p_string ) { 31 if (typeof p_string != "string") { 32 return p_string; 33 } 34 35 var t_string = p_string; 36 var t_ch = ''; 37 38 // Trim beginning spaces 39 40 t_ch = t_string.substring( 0, 1 ); 41 while ( t_ch == " " ) { 42 t_string = t_string.substring( 1, t_string.length ); 43 t_ch = t_string.substring( 0, 1 ); 44 } 45 46 // Trim trailing spaces 47 48 t_ch = t_string.substring( t_string.length-1, t_string.length ); 49 while ( t_ch == " " ) { 50 t_string = t_string.substring( 0, t_string.length-1 ); 51 t_ch = t_string.substring( t_string.length-1, t_string.length ); 52 } 53 54 return t_string; 55 } 56 57 58 /* 59 * Cookie functions 60 */ 61 62 function GetCookie( p_cookie ) { 63 var t_cookie_name = "MANTIS_" + p_cookie; 64 var t_cookies = document.cookie; 65 66 t_cookies = t_cookies.split( ";" ); 67 68 var i = 0; 69 while( i < t_cookies.length ) { 70 var t_cookie = t_cookies[ i ]; 71 72 t_cookie = t_cookie.split( "=" ); 73 74 if ( Trim( t_cookie[ 0 ] ) == t_cookie_name ) { 75 return( t_cookie[ 1 ] ); 76 } 77 i++; 78 } 79 80 return -1; 81 } 82 83 function SetCookie( p_cookie, p_value ) { 84 var t_cookie_name = "MANTIS_" + p_cookie; 85 var t_expires = new Date(); 86 87 t_expires.setTime( t_expires.getTime() + (365 * 24 * 60 * 60 * 1000)); 88 89 document.cookie = t_cookie_name + "=" + p_value + "; expires=" + t_expires.toUTCString() + ";"; 90 } 91 92 93 /* 94 * Collapsible element functions 95 */ 96 97 var g_div_history = 0x0001; 98 var g_div_bugnotes = 0x0002; 99 var g_div_bugnote_add = 0x0004; 100 var g_div_bugnotestats = 0x0008; 101 var g_div_upload_form = 0x0010; 102 var g_div_monitoring = 0x0020; 103 var g_div_sponsorship = 0x0040; 104 var g_div_relationships = 0x0080; 105 var g_div_filter = 0x0100; 106 107 108 /* List here the sections open by default */ 109 var g_default_view_settings = 110 g_div_history | 111 g_div_bugnotes | 112 g_div_bugnote_add | 113 g_div_bugnotestats | 114 g_div_upload_form | 115 g_div_monitoring | 116 g_div_sponsorship | 117 g_div_relationships; 118 119 120 function GetViewSettings() { 121 var t_cookie = GetCookie( "VIEW_SETTINGS" ); 122 123 if ( -1 == t_cookie ) { 124 t_cookie = g_default_view_settings; 125 } else { 126 t_cookie = parseInt( t_cookie ); 127 } 128 129 return t_cookie; 130 } 131 132 function SetDiv( p_div, p_cookie_bit ) { 133 var t_view_settings = GetViewSettings(); 134 135 if( t_view_settings & p_cookie_bit ) { 136 document.getElementById( p_div + "_open" ).style.display = ""; 137 document.getElementById( p_div + "_closed" ).style.display = "none"; 138 } else { 139 document.getElementById( p_div + "_open" ).style.display = "none"; 140 document.getElementById( p_div + "_closed" ).style.display = ""; 141 } 142 } 143 144 function ToggleDiv( p_div, p_cookie_bit ) { 145 var t_view_settings = GetViewSettings(); 146 147 t_view_settings ^= p_cookie_bit; 148 SetCookie( "VIEW_SETTINGS", t_view_settings ); 149 150 SetDiv( p_div, p_cookie_bit ); 151 } 152 153 /* Check checkboxes */ 154 function checkall( p_formname, p_state) { 155 var t_elements = (eval("document." + p_formname + ".elements")); 156 157 for (var i = 0; i < t_elements.length; i++) { 158 if(t_elements[i].type == 'checkbox') { 159 t_elements[i].checked = p_state; 160 } 161 } 162 } 163 164 // global code to determine how to set visibility 165 var a = navigator.userAgent.indexOf("MSIE"); 166 var style_display; 167 168 if (a!= -1) { 169 style_display = 'block'; 170 } else { 171 style_display = 'table-row'; 172 } 173 style_display = 'block'; 174 175 function setDisplay(idTag, state) 176 { 177 if(!document.getElementById(idTag)) alert('SetDisplay(): id '+idTag+' is empty'); 178 // change display visibility 179 if ( state != 0 ) { 180 document.getElementById(idTag).style.display = style_display; 181 } else { 182 document.getElementById(idTag).style.display = 'none'; 183 } 184 } 185 186 function toggleDisplay(idTag) 187 { 188 setDisplay( idTag, (document.getElementById(idTag).style.display == 'none')?1:0 ); 189 } 190 191 /* Append a tag name to the tag input box, with repect for tag separators, etc */ 192 function tag_string_append( p_string ) { 193 t_tag_separator = document.getElementById('tag_separator').value; 194 t_tag_string = document.getElementById('tag_string'); 195 t_tag_select = document.getElementById('tag_select'); 196 if ( t_tag_string.value != '' ) { 197 t_tag_string.value = t_tag_string.value + t_tag_separator + p_string; 198 } else { 199 t_tag_string.value = t_tag_string.value + p_string; 200 } 201 t_tag_select.selectedIndex=0; 202 } 203
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |