Skip to content

Commit

Permalink
Revert "Merge pull request #22 from Aoki-Dai/main"
Browse files Browse the repository at this point in the history
This reverts commit 0fbd7fb, reversing
changes made to d328efc.
  • Loading branch information
leviosa42 committed Aug 4, 2024
1 parent 0fbd7fb commit c35a336
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 56 deletions.
36 changes: 9 additions & 27 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const countCompletedTodo = () => {
const progressCircle = document.getElementById("js-progress-circle");
const progressText = document.getElementById("js-progress-text");
const itemsJSON = todoStorage.loadTodoItems();
const totalTasks = 3; // 完了タスクの目標数
const totalTasks = 5; // 完了タスクの目標数

if (itemsJSON) {
itemsJSON.forEach((item) => {
Expand All @@ -135,36 +135,18 @@ const countCompletedTodo = () => {
});
}

if (countCompleted >= totalTasks) {
if (!localStorage.getItem('alertShown')) {
setTimeout(() => {
//alert("目標タスク数を超えました!カウントをリセットします。");
countCompleted = 0; // リセット
localStorage.setItem('alertShown', 'true');
updateDisplay();
}, 0); // 3秒後にアラートを表示
}
} else {
localStorage.removeItem('alertShown');
updateDisplay();
if (text) {
text.textContent = "完了Todo: " + countCompleted;
}

function updateDisplay() {
if (text) {
text.textContent = "完了Todo: " + countCompleted;
}

// 円形プログレスバーの更新
if (progressCircle && progressText) {
const percentage = Math.min((countCompleted / totalTasks) * 100, 100);
progressCircle.style.background = `conic-gradient(#4caf50 ${percentage}%, #bcd6bd ${percentage}%)`;
//progressText.textContent = `${Math.round(percentage)}%`;
progressText.textContent = `${countCompleted} / ${totalTasks}`;
}
if (progressCircle && progressText) {
const percentage = Math.min((countCompleted / totalTasks) * 100, 100);
progressCircle.style.background = `conic-gradient(#4caf50 ${percentage}%, #bcd6bd ${percentage}%)`;
//progressText.textContent = `${Math.round(percentage)}%`;
progressText.textContent = `${countCompleted} / ${totalTasks}`;
}
}
};

// シェアボタンをクリックしたときの処理
async function openShareScreen() {
const text = document.getElementById("js-count-completed");
const textString = `3 Days ToDoを使って、${text.textContent}個を達成しました!`
Expand Down
57 changes: 28 additions & 29 deletions dist/js/AchivementItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,57 @@ export class AchivementItem {
* @param {Function} options.checker
*/
constructor(options) {
this.id = options.id; // アチーブメントのIDを設定
this.title = options.title; // アチーブメントのタイトルを設定
this.description = options.description; // アチーブメントの説明を設定
this.isAchived = false; // 初期状態ではアチーブメントは未達成
this.checker = options.checker; // アチーブメント達成条件をチェックする関数を設定
this.achive = options.achive; // deprecated? アチーブメント達成時に実行する関数を設定
this.id = options.id;
this.title = options.title;
this.description = options.description;
this.isAchived = false;
this.checker = options.checker;
this.achive = options.achive; // deprecated?
}

/**
* アチーブメントを表現するHTML要素を生成する
*
* @returns {HTMLDivElement}
*/
generateHTMLElement() {
const item = document.createElement("div"); // .item要素を作成
// .item
const item = document.createElement("div");
item.classList.add("item");
this.isAchived = this.checker(); // アチーブメント達成条件をチェック
item.classList.add(this.isAchived ? "achived" : "not-achived"); // 達成状態に応じてクラスを追加
item.id = this.id; // 要素のIDを設定
item.classList.add(this.isAchived ? "achived" : "not-achived");
item.id = this.id;

// .item .top
const top = document.createElement("div"); // .top要素を作成
const top = document.createElement("div");
top.classList.add("top");
const icon = document.createElement("div"); // アイコン要素を作成
const icon = document.createElement("div");
icon.classList.add("icon");
icon.textContent = "🏆"; // アイコンの内容を設定
icon.textContent = "🏆";
top.appendChild(icon);
const title = document.createElement("div"); // タイトル要素を作成
const title = document.createElement("div");
title.classList.add("title");
title.textContent = this.title; // タイトルの内容を設定
title.textContent = this.title;
top.appendChild(title);

const bottom = document.createElement("div"); // .bottom要素を作成
const description = document.createElement("div"); // 説明要素を作成
// .item .bottom
const bottom = document.createElement("div");
const description = document.createElement("div");
description.classList.add("description");
description.textContent = this.description; // 説明の内容を設定
description.textContent = this.description;
bottom.appendChild(description);

item.appendChild(top); // .itemに.topを追加
item.appendChild(bottom); // .itemに.bottomを追加
return item; // .item要素を返す
item.appendChild(top);
item.appendChild(bottom);
return item;
}

/**
* アチーブメントをJSON形式に変換する
* @returns {Object}
*/

toJSON() {
return {
id: this.id, // IDをJSONに含める
title: this.title, // タイトルをJSONに含める
description: this.description, // 説明をJSONに含める
isAchived: this.isAchived, // 達成状態をJSONに含める
id: this.id,
title: this.title,
description: this.description,
isAchived: this.isAchived,
};
}
}

0 comments on commit c35a336

Please # to comment.