Skip to content

Commit

Permalink
fix: included rendering (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
makinzm authored Dec 24, 2024
1 parent 31fdce2 commit 848591b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/options/options.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions src/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,39 @@ addExcludedDomainButton.addEventListener("click", async () => {
}
});

// DOM要素取得
const includedDomainInput = document.getElementById("includedDomainInput") as HTMLInputElement;
const addIncludedDomainButton = document.getElementById("addIncludedDomainButton") as HTMLButtonElement;
const includedDomainList = document.getElementById("includedDomainList") as HTMLUListElement;

// included_domainsリストの表示更新関数
async function renderIncludedDomains() {
const domains = await db.getAllIncludedDomains();
includedDomainList.innerHTML = "";
for (const d of domains) {
const li = document.createElement("li");
li.textContent = d.domain;
const removeBtn = document.createElement("button");
removeBtn.textContent = "削除";
removeBtn.addEventListener("click", async () => {
await db.removeIncludedDomain(d.domain);
renderIncludedDomains();
});
li.appendChild(removeBtn);
includedDomainList.appendChild(li);
}
}

// Includeドメイン追加ボタンのイベントリスナー
addIncludedDomainButton.addEventListener("click", async () => {
const domain = includedDomainInput.value.trim();
if (domain) {
await db.addIncludedDomain(domain);
includedDomainInput.value = ""; // 入力欄をクリア
renderIncludedDomains();
}
});

// 1) モード保存先キーを決める
const DOMAIN_FILTER_MODE_KEY = "domainFilterMode";

Expand Down Expand Up @@ -332,6 +365,7 @@ radioInclude.addEventListener("change", () => toggleSettings("include"));

initializeSettings();
renderExcludedDomains();
renderIncludedDomains();
loadData();
loadDomainFilterMode();
setupDomainFilterModeListeners();
Expand Down

0 comments on commit 848591b

Please sign in to comment.