View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008860 | mantisbt | time tracking | public | 2008-02-06 05:56 | 2017-04-26 12:00 |
Reporter | kynx | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | acknowledged | Resolution | open | ||
Product Version | 1.3.0-beta.1 | ||||
Summary | 0008860: User entered time is overwritten | ||||
Description | If you enter a time (say '0:15:00') for a note then click the 'Start' button, the time you enter is overwritten with whatever value the stopwatch already has. This is annoying when you've already put time into the bug but have only just gone to the bug page. The attached patch adds an onblur handler to the time input that updates the stopwatch with the user-entered value. It also adds some (very basic) validation to the time entered. Tested in FF2.0.0.11 and IE6. | ||||
Tags | patch | ||||
Attached Files | time_tracking_edit.diff (1,473 bytes)
Index: javascript/time_tracking_stopwatch.js =================================================================== --- javascript/time_tracking_stopwatch.js (revision 4960) +++ javascript/time_tracking_stopwatch.js (working copy) @@ -42,5 +42,21 @@ } } +function time_tracking_swonblur(input) { + var time = input.value.split(/:/); + var mult = [3600, 60, 1]; + var new_ms = 0; + for (i=0; i<time.length && i<3; i++) + { + if (isNaN(parseInt(time[i]))) + { + alert('Please enter a valid time'); + return false; + } + new_ms += parseInt(time[i]) * mult[i] * 1000; + } + time_tracking_ms = new_ms; +} + setTimeout("time_tracking_display();", 1000); Index: bugnote_add_inc.php =================================================================== --- bugnote_add_inc.php (revision 4960) +++ bugnote_add_inc.php (working copy) @@ -77,7 +77,7 @@ <td> <?php if ( config_get('time_tracking_stopwatch') && ON == config_get( 'use_javascript' )) { ?> <script type="text/javascript" language="JavaScript" src="javascript/time_tracking_stopwatch.js"></script> - <input type="text" name="time_tracking" size="5" value="00:00" /> + <input type="text" name="time_tracking" onblur="time_tracking_swonblur(this)" size="5" value="00:00" /> <input type="button" name="time_tracking_ssbutton" value="Start" onclick="time_tracking_swstartstop()" /> <input type="button" name="time_tracking_reset" value="R" onclick="time_tracking_swreset()" /> <?php } else { ?> | ||||