![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 /* $Id: index_uncompressed.js 105 2008-03-20 00:33:54Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/projectdesigner/index_uncompressed.js $ */ 2 function update_workspace(id) { 3 var tr = document.getElementById(id); 4 (tr.style.display == "none") ? eval('document.frmWorkspace.opt_view_'+id+'.value=0') : eval('document.frmWorkspace.opt_view_'+id+'.value=1'); 5 (tr.style.display == "none") ? eval('document.editFrm.opt_view_'+id+'.value=0') : eval('document.editFrm.opt_view_'+id+'.value=1'); 6 (tr.style.display == "none") ? eval('document.frm_bulk.opt_view_'+id+'.value=0') : eval('document.frm_bulk.opt_view_'+id+'.value=1'); 7 } 8 9 function expandAll() { 10 expand_collapse('project', 'tblProjects', 'expand'); 11 expand_collapse('gantt', 'tblProjects', 'expand'); 12 expand_collapse('tasks', 'tblProjects', 'expand'); 13 expand_collapse('actions', 'tblProjects', 'expand'); 14 expand_collapse('addtsks', 'tblProjects', 'expand'); 15 expand_collapse('files', 'tblProjects', 'expand'); 16 update_workspace('project'); 17 update_workspace('gantt'); 18 update_workspace('tasks'); 19 update_workspace('actions'); 20 update_workspace('addtsks'); 21 update_workspace('files'); 22 } 23 24 function collapseAll() { 25 expand_collapse('project', 'tblProjects', 'collapse'); 26 expand_collapse('gantt', 'tblProjects', 'collapse'); 27 expand_collapse('tasks', 'tblProjects', 'collapse'); 28 expand_collapse('actions', 'tblProjects', 'collapse'); 29 expand_collapse('addtsks', 'tblProjects', 'collapse'); 30 expand_collapse('files', 'tblProjects', 'collapse'); 31 update_workspace('project'); 32 update_workspace('gantt'); 33 update_workspace('tasks'); 34 update_workspace('actions'); 35 update_workspace('addtsks'); 36 update_workspace('files'); 37 } 38 39 /** 40 * @modify_reason calculating duration does not include time information and cal_working_days stored in config.php 41 */ 42 function calcDuration(form,start_date,end_date,duration_fld,durntype_fld) { 43 44 var int_st_date = new String(start_date.value); 45 var int_en_date = new String(end_date.value); 46 47 var sDate = new Date(int_st_date.substring(0,4),(int_st_date.substring(4,6)-1),int_st_date.substring(6,8), int_st_date.substring(8,10), int_st_date.substring(10,12)); 48 var eDate = new Date(int_en_date.substring(0,4),(int_en_date.substring(4,6)-1),int_en_date.substring(6,8), int_en_date.substring(8,10), int_en_date.substring(10,12)); 49 var s = Date.UTC(int_st_date.substring(0,4),(int_st_date.substring(4,6)-1),int_st_date.substring(6,8), int_st_date.substring(8,10), int_st_date.substring(10,12)); 50 var e = Date.UTC(int_en_date.substring(0,4),(int_en_date.substring(4,6)-1),int_en_date.substring(6,8), int_en_date.substring(8,10), int_en_date.substring(10,12)); 51 var durn = (e - s) / hourMSecs; //hours absolute diff start and end 52 var durn_abs = durn; 53 54 //now we should subtract non-working days from durn variable 55 var duration = durn / 24; 56 var weekendDays = 0; 57 var myDate = new Date(int_st_date.substring(0,4), (int_st_date.substring(4,6)-1),int_st_date.substring(6,8), int_st_date.substring(8,10)); 58 for (var i = 0; i < duration; i++) { 59 //var myDate = new Date(int_st_date.substring(0,4), (int_st_date.substring(4,6)-1),int_st_date.substring(6,8), int_st_date.substring(8,10)); 60 var myDay = myDate.getDate(); 61 if ( !isInArray(working_days, myDate.getDay()) ) { 62 weekendDays++; 63 } 64 myDate.setDate(myDay + 1); 65 } 66 67 //calculating correct durn value 68 durn = durn - weekendDays*24; // total hours minus non-working days (work day hours) 69 70 // check if the last day is a weekendDay 71 // if so we subtracted some hours too much before, 72 // we have to fill up the last working day until cal_day_start + daily_working_hours 73 if ( !isInArray(working_days, eDate.getDay()) && eDate.getHours() != cal_day_start) { 74 durn = durn + Math.max(0, (cal_day_start + daily_working_hours - eDate.getHours())); 75 } 76 77 //could be 1 or 24 (based on TaskDurationType value) - We'll consider it 1 = hours 78 //var durnType = parseFloat(f.task_duration_type.value); 79 var durnType = parseFloat(durntype_fld.value); 80 durn /= durnType; 81 //alert(durn); 82 if (durnType == 1){ 83 // durn is absolute weekday hours 84 85 //if first day equals last day we're already done 86 if( durn_abs < daily_working_hours ) { 87 88 durn = durn_abs; 89 90 } else { //otherwise we need to process first and end day different; 91 92 // Hours worked on the first day 93 var first_day_hours = cal_day_end - sDate.getHours(); 94 if (first_day_hours > daily_working_hours) 95 first_day_hours = daily_working_hours; 96 97 // Hours worked on the last day 98 var last_day_hours = eDate.getHours() - cal_day_start; 99 if (last_day_hours > daily_working_hours) 100 last_day_hours = daily_working_hours; 101 102 // Total partial day hours 103 var partial_day_hours = first_day_hours + last_day_hours; 104 105 // Full work days 106 var full_work_days = (durn - partial_day_hours) / 24; 107 108 // Total working hours 109 durn = Math.floor(full_work_days) * daily_working_hours + partial_day_hours; 110 111 // check if the last day is a weekendDay 112 // if so we subtracted some hours too much before, 113 // we have to fill up the last working day until cal_day_start + daily_working_hours 114 if ( !isInArray(working_days, eDate.getDay()) && eDate.getHours() != cal_day_start) { 115 durn = durn + Math.max(0, (cal_day_start + daily_working_hours - eDate.getHours())); 116 } 117 } 118 119 } else if (durnType == 24 ) { 120 //we should talk about working days so a task duration of 41 hrs means 6 (NOT 5) days!!! 121 if (durn > Math.round(durn)) { 122 durn++; 123 } 124 } 125 126 if ( s > e ) { 127 //alert( 'End date is before start date!'); 128 } else { 129 duration_fld.value = Math.round(durn); 130 } 131 } 132 /** 133 * Get the end of the previous working day 134 */ 135 function prev_working_day( dateObj ) { 136 while ( ! isInArray(working_days, dateObj.getDay()) || dateObj.getHours() < cal_day_start || 137 ( dateObj.getHours() == cal_day_start && dateObj.getMinutes() == 0 ) ){ 138 139 dateObj.setDate(dateObj.getDate()-1); 140 dateObj.setHours( cal_day_end ); 141 dateObj.setMinutes( 0 ); 142 } 143 144 return dateObj; 145 } 146 /** 147 * Get the start of the next working day 148 */ 149 function next_working_day( dateObj ) { 150 while ( ! isInArray(working_days, dateObj.getDay()) || dateObj.getHours() >= cal_day_end ) { 151 dateObj.setDate(dateObj.getDate()+1); 152 dateObj.setHours( cal_day_start ); 153 dateObj.setMinutes(0); 154 } 155 156 return dateObj; 157 } 158 159 function addBulkComponent(li) { 160 //IE 161 if (document.all || navigator.appName == "Microsoft Internet Explorer") { 162 var form = document.frm_bulk; 163 var ni = document.getElementById('tbl_bulk'); 164 var newitem = document.createElement('input'); 165 var htmltxt = ""; 166 newitem.id = 'bulk_selected_task['+li+']'; 167 newitem.name = 'bulk_selected_task['+li+']'; 168 newitem.type = 'hidden'; 169 ni.appendChild(newitem); 170 } else { 171 //Non IE 172 var form = document.frm_bulk; 173 var ni = document.getElementById('tbl_bulk'); 174 var newitem = document.createElement('input'); 175 newitem.setAttribute("id",'bulk_selected_task['+li+']'); 176 newitem.setAttribute("name",'bulk_selected_task['+li+']'); 177 newitem.setAttribute("type",'hidden'); 178 ni.appendChild(newitem); 179 } 180 } 181 182 function removeBulkComponent(li) { 183 var t = document.getElementById('tbl_bulk'); 184 var old = document.getElementById('bulk_selected_task['+li+']'); 185 t.removeChild(old); 186 } 187 188 189 function getStyle(nodeName, sStyle, iStyle) { 190 var element = document.getElementById(nodeName); 191 if (window.getComputedStyle) { 192 var style=document.defaultView.getComputedStyle(element,null); 193 var value = style.getPropertyValue(sStyle); 194 } else { 195 var value = eval("element.currentStyle." + iStyle); 196 } 197 return value; 198 } 199 200 function mult_sel(cmbObj, box_name, form_name) { 201 var f = eval('document.'+form_name); 202 var check = cmbObj.checked; 203 204 for (var i=0, i_cmp=f.length;i < i_cmp;i++) { 205 fldObj = f.elements[i]; 206 var field_name = fldObj.id; 207 if (fldObj.type == 'checkbox' && field_name.indexOf(box_name) >= 0) { 208 id = field_name.replace('selected_task_',''); 209 //lets find the right row before continuing 210 var trs = document.getElementsByTagName('tr'); 211 for (var ri=0, ri_cmp=trs.length;ri<ri_cmp;ri++) { 212 rowObj = trs[ri]; 213 var row_id = rowObj.id; 214 if (row_id.indexOf('task_'+id+'_') >= 0) { 215 row = document.getElementById(row_id); 216 } 217 } 218 var oldcheck = fldObj.checked; 219 fldObj.checked = (check) ? true : false; 220 if (check) { 221 highlight_tds(row, 2, id); 222 //Only add the component if it didn't exist or else we get JS trouble 223 if (!oldcheck) { 224 addBulkComponent(id); 225 } 226 } else { 227 highlight_tds(row, 0, id); 228 //Only remove the component if it exists or else we get JS trouble 229 if (oldcheck) { 230 removeBulkComponent(id); 231 } 232 } 233 } 234 } 235 } 236 237 function highlight_tds(row, high, id) { 238 //high = 0 or false => remove highlight 239 //high = 1 or true => highlight 240 //high = 2 => select 241 //high = 3 => deselect 242 if (document.getElementsByTagName) { 243 var tcs = row.getElementsByTagName('td'); 244 var cell_name = ''; 245 if (!id) { 246 check = false; 247 } else { 248 var f = eval('document.frm_tasks'); 249 var check = eval('f.selected_task_'+id+'.checked'); 250 } 251 for (var j = 0, j_cmp=tcs.length; j < j_cmp; j+=1) { 252 cell_name = eval('tcs['+j+'].id'); 253 if(!(cell_name.indexOf('ignore_td_') >= 0)) { 254 if (high == 3) { 255 tcs[j].style.background = '#FFFFCC'; 256 } else if (high == 2 || check) { 257 tcs[j].style.background = '#FFCCCC'; 258 } else if (high == 1) { 259 tcs[j].style.background = '#FFFFCC'; 260 } else { 261 tcs[j].style.background = original_bgc; 262 } 263 } 264 } 265 } 266 } 267 268 var is_check; 269 function select_box(box, id, row_id, form_name){ 270 var f = eval('document.'+form_name); 271 var check = eval('f.'+box+'_'+id+'.checked'); 272 boxObj = eval('f.elements["'+box+'_'+id+'"]'); 273 if ((is_check && boxObj.checked && !boxObj.disabled) || (!is_check && !boxObj.checked && !boxObj.disabled)) { 274 row = document.getElementById(row_id); 275 boxObj.checked = true; 276 highlight_tds(row, 2, id); 277 addBulkComponent(id); 278 } else if ((is_check && !boxObj.checked && !boxObj.disabled) || (!is_check && boxObj.checked && !boxObj.disabled)) { 279 row = document.getElementById(row_id); 280 highlight_tds(row, 3, id); 281 boxObj.checked = false; 282 removeBulkComponent(id); 283 } 284 } 285 286 function toggle_users(id){ 287 var element = document.getElementById(id); 288 element.style.display = (element.style.display == '' || element.style.display == "none") ? "inline" : "none"; 289 } 290 291 function addUser(form) { 292 var fl = form.bulk_task_user; 293 var pc = form.bulk_task_assign_perc; 294 var au = form.bulk_task_assign.length -1; 295 //gets value of percentage assignment of selected resource 296 var perc = pc.options[pc.selectedIndex].value; 297 298 var users = "x"; 299 300 //build array of assiged users 301 for (au; au > -1; au--) { 302 users = users + "," + form.bulk_task_assign.options[au].value + ","; 303 } 304 305 //Pull selected resources and add them to list 306 if (fl.value > 0 && pc.value > 0) { 307 if (fl.options[fl.selectedIndex].selected && users.indexOf( "," + fl.options[fl.selectedIndex].value + "," ) == -1) { 308 t = form.bulk_task_assign.length; 309 opt = new Option( fl.options[fl.selectedIndex].text+" ["+perc+"%]", fl.options[fl.selectedIndex].value); 310 form.bulk_task_hperc_assign.value += fl.options[fl.selectedIndex].value+"="+perc+";"; 311 form.bulk_task_assign.options[t] = opt; 312 } 313 } 314 } 315 316 function removeUser(form) { 317 var fl = form.bulk_task_assign.length -1; 318 var au = form.bulk_task_assign.length -1; 319 320 var users = "x"; 321 322 //build array of assiged users 323 for (au; au > -1; au--) { 324 users = users + "," + form.bulk_task_assign.options[au].value + ","; 325 } 326 327 for (fl; fl > -1; fl--) { 328 if (form.bulk_task_assign.options[fl].selected && users.indexOf( "," + form.bulk_task_assign.options[fl].value + "," ) > -1) { 329 var selValue = form.bulk_task_assign.options[fl].value; 330 var re = ".*("+selValue+"=[0-9]*;).*"; 331 var hiddenValue = form.bulk_task_hperc_assign.value; 332 if (hiddenValue) { 333 var b = hiddenValue.match(re); 334 if (b[1]) { 335 hiddenValue = hiddenValue.replace(b[1], ''); 336 } 337 form.bulk_task_hperc_assign.value = hiddenValue; 338 form.bulk_task_assign.options[fl] = null; 339 } 340 } 341 } 342 } 343 344 function expand_selector(id, table_name) { 345 var trs = document.getElementsByTagName('tr'); 346 347 for (var i=0, i_cmp=trs.length;i < i_cmp;i++) { 348 var tr_name = trs.item(i).id; 349 350 if (tr_name.indexOf(id) >= 0) { 351 var tr = document.getElementById(tr_name); 352 if (navigator.family == "gecko" || navigator.family == "opera"){ 353 tr.style.visibility = (tr.style.visibility == '' || tr.style.visibility == "collapse") ? "visible" : "collapse"; 354 tr.style.display = (tr.style.display == "none") ? "" : "none"; 355 var img_expand = document.getElementById(id+'_expand'); 356 var img_collapse = document.getElementById(id+'_collapse'); 357 img_collapse.style.display = (tr.style.visibility == 'visible') ? "inline" : "none"; 358 img_expand.style.display = (tr.style.visibility == '' || tr.style.visibility == "collapse") ? "inline" : "none"; 359 } else { 360 tr.style.display = (tr.style.display == "none") ? "" : "none"; 361 var img_expand = document.getElementById(id+'_expand'); 362 var img_collapse = document.getElementById(id+'_collapse'); 363 img_collapse.style.display = (tr.style.display == '') ? "inline" : "none"; 364 img_expand.style.display = (tr.style.display == 'none') ? "inline" : "none"; 365 } 366 } 367 } 368 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |