File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ let wheelSegments = []; // 將 segments 定義為全局變量
10
10
// 更新轉盤的選項
11
11
function updateWheelSegments ( ) {
12
12
wheelSegments = inputContent . value . split ( '\n' ) . filter ( segment => segment . trim ( ) !== "" ) ; // 更新全局的 segments
13
+ if ( wheelSegments == "" ) {
14
+ wheelSegments = "#"
15
+ }
13
16
}
14
17
15
18
// 初始化轉盤內容
@@ -111,11 +114,15 @@ function recordPrize() {
111
114
112
115
// 顯示結果
113
116
function showSpinResult ( ) {
114
- const numSegments = wheelSegments . length ; // 獲取段數
115
- const winningSegmentIndex = Math . floor ( ( numSegments - ( rotationAngle % ( 2 * Math . PI ) ) / ( 2 * Math . PI / numSegments ) ) % numSegments ) ;
116
- displayResultElement . textContent = wheelSegments [ winningSegmentIndex ] ;
117
- recordPrize ( ) ;
118
- autoRemove ( ) ;
117
+ if ( wheelSegments != "#" ) {
118
+ const numSegments = wheelSegments . length ; // 獲取段數
119
+ const winningSegmentIndex = Math . floor ( ( numSegments - ( rotationAngle % ( 2 * Math . PI ) ) / ( 2 * Math . PI / numSegments ) ) % numSegments ) ;
120
+ displayResultElement . textContent = wheelSegments [ winningSegmentIndex ] ;
121
+ recordPrize ( ) ;
122
+ autoRemove ( ) ;
123
+ } else {
124
+ displayResultElement . textContent = "請輸入選項" ;
125
+ }
119
126
}
120
127
// 自動刪除
121
128
function autoRemove ( ) {
You can’t perform that action at this time.
0 commit comments