1- function syncValue ( id , value ) {
2- document . getElementById ( id ) . value = value ;
1+ // 固定的Post Threshold Ratio為60%
2+ const ENHANCEMENT_PERCENT = 60 ;
3+
4+ function adjustValue ( id , delta ) {
5+ const input = document . getElementById ( id ) ;
6+ let currentValue = parseFloat ( input . value ) || 0 ;
7+ let newValue = currentValue + delta ;
8+
9+ // 設定範圍限制
10+ const min = parseFloat ( input . min ) || 0 ;
11+ const max = parseFloat ( input . max ) || Infinity ;
12+
13+ // 確保在範圍內
14+ newValue = Math . max ( min , Math . min ( max , newValue ) ) ;
15+
16+ // 根據不同欄位設定小數位數
17+ if ( id === 'contrastTotal' ) {
18+ newValue = Math . round ( newValue ) ;
19+ } else {
20+ newValue = Math . round ( newValue * 10 ) / 10 ; // 保留一位小數
21+ }
22+
23+ input . value = newValue ;
324 updateValues ( ) ;
425}
526
627function updateValues ( ) {
728 const contrastTotal = parseFloat ( document . getElementById ( 'contrastTotal' ) . value ) ;
829 const injectionRate = parseFloat ( document . getElementById ( 'injectionRate' ) . value ) ;
930 const scanTime = parseFloat ( document . getElementById ( 'scanTime' ) . value ) ;
10- const enhancementPercent = parseFloat ( document . getElementById ( 'enhancementPercent' ) . value ) ; // 更新
11-
12- document . getElementById ( 'enhancementPercentDisplay' ) . textContent = enhancementPercent + '%' ;
13- const ptd1 = ( ( ( contrastTotal / injectionRate ) - scanTime ) * ( enhancementPercent / 100 ) ) . toFixed ( 1 ) ;
31+
32+ // 使用固定的60%顯影百分比
33+ const ptd1 = ( ( ( contrastTotal / injectionRate ) - scanTime ) * ( ENHANCEMENT_PERCENT / 100 ) ) . toFixed ( 1 ) ;
1434 const ptd2 = ( parseFloat ( ptd1 ) + scanTime + 4 ) . toFixed ( 1 ) ;
1535 const ptd3 = ( parseFloat ( ptd2 ) + scanTime + 4 ) . toFixed ( 1 ) ;
16-
36+
1737 document . getElementById ( 'ptd1' ) . textContent = ptd1 ;
1838 document . getElementById ( 'ptd2' ) . textContent = ptd2 ;
1939 document . getElementById ( 'ptd3' ) . textContent = ptd3 ;
@@ -23,14 +43,6 @@ function resetDefaults() {
2343 document . getElementById ( 'contrastTotal' ) . value = 60 ;
2444 document . getElementById ( 'injectionRate' ) . value = 4.0 ;
2545 document . getElementById ( 'scanTime' ) . value = 4.0 ;
26- document . getElementById ( 'enhancementPercent' ) . value = 60 ; // 新增
27-
28- // 更新滑塊位置
29- document . getElementById ( 'contrastTotalSlider' ) . value = 60 ;
30- document . getElementById ( 'injectionRateSlider' ) . value = 4.0 ;
31- document . getElementById ( 'scanTimeSlider' ) . value = 4.0 ;
32- document . getElementById ( 'enhancementPercentSlider' ) . value = 60 ; // 新增
33-
3446 updateValues ( ) ;
3547}
3648
0 commit comments