Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
SWXDC committed Nov 3, 2024
1 parent 64e14f1 commit 4056d2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Tool/Wheel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ <h1>選項</h1>
<label class="auto-record-label" for="" >自動記錄</label>
<input id="auto-content-remove" class="auto-content-remove" type="checkbox" checked>
<label class="auto-content-remove-label" for="">自動刪除</label>
<input id="auto-draw" class="auto-draw" type="checkbox">
<label class="auto-draw-label" for="">自動抽籤</label>
</div>
<div class="setting-speed">
<label for="">旋轉速度</label>
Expand Down
19 changes: 16 additions & 3 deletions Tool/Wheel/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function setCookie(name, value, days) {
// 初始化 textarea 的內容
function initializeContent() {
const savedContent = readCookie("savedContent");
content.value = savedContent ? decodeURIComponent(savedContent) : DEFAULT_CONTENT;
inputContent.value = savedContent ? decodeURIComponent(savedContent) : DEFAULT_CONTENT;
}

// 儲存 textarea 的內容到 cookie
Expand All @@ -35,6 +35,8 @@ function loadContent() {
} else {
alert("沒有找到儲存的內容!"); // 如果沒有找到,則顯示提示
}
updateWheelSegments();
renderWheel();
}

// 用戶資料輸入
Expand All @@ -45,6 +47,7 @@ const DEFAULT_CONTENT = "1\n2\n3\n4\n5\n6";
const displayResultElement = document.querySelector("#resultDisplay");
const prizeRecordTable = document.querySelector("#recordList");

let autoDrawTime = 0;
let wheelSegments = []; // 將 segments 定義為全局變量

// 更新轉盤的選項
Expand Down Expand Up @@ -147,7 +150,7 @@ function recordPrize() {
if (checkbox.checked) {
const newRow = document.createElement("tr");
newRow.innerHTML = `<th>${prizeRecordTable.children.length + 1}.</th><td>${displayResultElement.textContent}</td>`;
prizeRecordTable.appendChild(newRow);
prizeRecordTable.appendChild(newRow);
console.log(prizeRecordTable.innerHTML);
}
}
Expand All @@ -163,6 +166,12 @@ function showSpinResult() {
} else {
displayResultElement.textContent = "請輸入選項";
}
if(document.getElementById("auto-draw").checked & wheelSegments.length > 0){
start();

}
updateWheelSegments()

}

// 批量生成數字
Expand Down Expand Up @@ -207,7 +216,9 @@ function autoRemove() {

// Console
function start() {
startWheelSpin();
if(wheelSegments.length != 0){
startWheelSpin();
}
}

function reset() {
Expand All @@ -217,4 +228,6 @@ function reset() {

// 初始化轉盤
initializeWheelContent();
initializeContent();
updateWheelSegments();
renderWheel();

0 comments on commit 4056d2d

Please sign in to comment.