Files
devplacepy/devplacepy/static/js/BookmarkManager.js
T
retoor 7fc9b0f715 chore: add retoor header to all devplacepy source files and update style agent header rule
The diff adds the mandatory `retoor <retoor@molodetz.nl>` header comment to every `.py` file under `devplacepy/` (including `__init__.py` and `routers/__init__.py`), and updates the `StyleAgent` in `agents/style.py` to instruct agents to only add the header on created or already-edited files rather than sweeping the entire repo. The `agents/base.py` operating protocol is also revised to reorder and clarify tool discipline rules.
2026-06-11 23:58:46 +00:00

28 lines
878 B
JavaScript

// retoor <retoor@molodetz.nl>
import { OptimisticAction } from "./OptimisticAction.js";
export class BookmarkManager extends OptimisticAction {
constructor() {
super();
document.addEventListener("click", (event) => this.onClick(event));
}
async onClick(event) {
const button = event.target.closest(".bookmark-btn");
if (!button) {
return;
}
event.preventDefault();
const type = button.dataset.bookmarkType;
const uid = button.dataset.bookmarkUid;
await this.submit(`/bookmarks/${type}/${uid}`, {}, null, (result) => {
button.classList.toggle("bookmarked", result.saved);
const label = button.querySelector(".bookmark-label");
if (label) {
label.textContent = result.saved ? "Saved" : "Save";
}
});
}
}