Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: included rendering #12

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading