FastAPI + SQLAlchemy/Alembic + MariaDB backend with Jinja2/htmx/Alpine server-rendered frontend. Multi-user via Google OAuth, daily habit tracking, monthly/weekly history views, Web Push reminders via APScheduler, and PWA support (manifest, service worker, offline caching). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
28 lines
890 B
JavaScript
28 lines
890 B
JavaScript
(function () {
|
|
function initSortable() {
|
|
var list = document.getElementById("habit-list");
|
|
if (!list || typeof Sortable === "undefined") return;
|
|
|
|
Sortable.create(list, {
|
|
handle: ".drag-handle",
|
|
animation: 150,
|
|
forceFallback: true, // iOS Safari는 네이티브 HTML5 D&D 터치 지원이 불안정해서 자체 포인터 시뮬레이션을 강제한다
|
|
fallbackTolerance: 3,
|
|
onEnd: function () {
|
|
var ids = Array.from(list.children)
|
|
.map(function (el) { return el.getAttribute("data-habit-id"); })
|
|
.filter(Boolean)
|
|
.map(Number);
|
|
|
|
fetch("/api/habits/reorder", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ habit_ids: ids }),
|
|
});
|
|
},
|
|
});
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", initSortable);
|
|
})();
|